-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2369 chat paste bug #2370
#2369 chat paste bug #2370
Conversation
group-income Run #3221
Run Properties:
|
Project |
group-income
|
Branch Review |
sebin/task/#2369-chat-paste-bug
|
Run status |
Passed #3221
|
Run duration | 09m 31s |
Commit |
23b81cac9f ℹ️: Merge 52ad0c44789756887af679636c48dea6b3b358c0 into a8cbe02389bc3f56d5c566574d42...
|
Committer | Sebin Song |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
10
|
Skipped |
0
|
Passing |
111
|
View all changes introduced in this branch ↗︎ |
This works! However, I wonder if using the |
@corrideat (Don't know if you write Vue code too but) It's more typical/generic approach to use But I'm sure the front-end author(s) of this component didn't use neither of them for a reason: So, adding |
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.
Thanks @SebinSong! There's a critical bug here:
@@ -553,6 +554,11 @@ export default ({ | |||
this.updateMentionKeyword() | |||
} | |||
}, | |||
handlePaste (e) { | |||
const pastedText = e.clipboardData.getData('text') | |||
this.$refs.textarea.value = pastedText |
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.
This will replace all existing text with the pasted text, overwriting the value.
Instead of that, we want the pasted value to be inserted where the cursor is like normal.
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.
My suggestion of using the input
event doesn't need this handlePaste
handler (it needs a much simpler handler, as shown in my example). However, I didn't thoroughly test it.
and they decided that using keydown event is more suitable to account for all of them.
I did see the duplicate logic for triggering the update (actually, it could possibly be duplicate, if you paste without using keys it won't be a duplicate), however it doesn't seem like a big issue considering that it's not expensive to call it.
As for conflicts, I didn't really see anything that would conflict.
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.
It does not make sense to add input
when there is keyodwn
already in place. It has to be either one of them. They are two events that look similar but behave differently in certain cases in my experience. For that reason it's a type of change I would be very cautious to do at this point (Considering this code has been this way for a long while). Also, as I said above, I think other front-end devs chose to use keydown
instead of input
for a reason.
@taoeffect Updated the fix again! |
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.
Nice work @SebinSong! 👏
closes #2369
The textarea element needed a 'paste' event handler.