-
Notifications
You must be signed in to change notification settings - Fork 19
#1422 Textarea enable linebreak (submitOnEnter) #1517
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a changelog item in changelog/unreleased/
, linking to the issue this is addressing (if applicable)
Also, please run yarn lint:eslint --fix
to fix linter issues locally (they're failing in CI currently) ;)
@pascalwengerter yes sorry only wanted to create a WIP PR ^^ but ofc you are right I fixed it |
No worries, was under the impression it's ready to review since you requested it ;) good work, either way! |
src/components/OcTextarea.vue
Outdated
@@ -158,9 +168,10 @@ export default { | |||
this.$emit("focus", value) | |||
}, | |||
onKeyDown(e) { | |||
if (e.keyCode === 13) { | |||
if (this.submitOnEnter && e.keyCode === 13 && !e.ctrlKey && !e.shiftKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this.submitOnEnter && e.keyCode === 13 && !e.ctrlKey && !e.shiftKey) { | |
if (this.submitOnEnter && e.enterKey && !e.ctrlKey && !e.shiftKey) { |
I like that you're using named keys. Please also change the keyCode === 13
to the named enterKey then for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sadly keyenter doesn't exist on the event, but I created a mini workaround to make it more readable
All issues mentioned should be resolved |
src/components/OcTextarea.vue
Outdated
@@ -158,9 +168,11 @@ export default { | |||
this.$emit("focus", value) | |||
}, | |||
onKeyDown(e) { | |||
if (e.keyCode === 13) { | |||
e.keyEnter = e.key === "Enter"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm.... personally in favor of not altering the event. Since e.enterKey
doesn't exist, you could just create a const
and use it in the if
statement, that still improves the readability a bit.
I.e. like this:
const enterKey = e.key === "Enter"
if (this.submitOnEnter && enterKey && !e.ctrlKey && !e.shiftKey) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks fine to me ^^
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be superb to have working examples of both configs, but changes in general LGTM and props for adding tests! 💪🏽
Description
See #1422
Related Issue
Types of changes
Checklist: