No "input" event should be fired immediately after "compositionend" event
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
People
(Reporter: duanyao.ustc, Unassigned)
References
Details
Comment 1•8 years ago
|
||
Comment 2•7 years ago
|
||
Updated•7 years ago
|
Comment 3•7 years ago
|
||
Comment 4•7 years ago
|
||
Comment 5•7 years ago
|
||
Comment 6•7 years ago
|
||
Comment 7•7 years ago
|
||
Comment 8•6 years ago
|
||
Comment 9•6 years ago
|
||
Comment 10•6 years ago
|
||
Comment 11•6 years ago
|
||
Comment 12•5 years ago
|
||
Just wanted to add some context—although this might already be accounted for.
Safari and Chrome currently have different behaviors here, and I think Safari's is the most correct. The key is not just the order that input
events fire in, but also the inputType
property. Here are the results for each browser:
- Safari: https://input-inspector.now.sh/profiles/Q7wkfGvEzdI2bffDSBhU
- Chrome: https://input-inspector.now.sh/profiles/MF6Wd5TTt8qFaXAG7uqX
- Firefox: https://input-inspector.now.sh/profiles/QkGKVWNPV5Zmf0BQcdEP
Results when simply typing Option-E
then E
, which results in: é
I think the correct ordering is:
- Composition starts
- Any amount of input events, with
insertCompositionText
ordeleteCompositionText
as theinputType
(non-cancellable) - A single input event with
insertFromComposition
to "commit" the change (cancellable) - Composition ends
Safari does this. Chrome doesn't ever fire an insertFromComposition
event to commit the change, so none of the events are cancellable and you're never sure what the committed input was just by looking at the input events.
From my experimenting so far, Safari's behavior is all that's required to handle them gracefully. I actually haven't needed to check the isComposing
flag in Safari at all or ever attach to composition*
events, because you're guaranteed that insertCompositionText/deleteCompositionText
are input types that only fire for interim composition edits, and that you'll get an insertFromComposition
at the end with the new data (which you can cancel and handle yourself too).
I think looking at React is going to be problematic because their input
events (and beforeinput
events) are polyfilled in weird ways.
Comment 13•5 years ago
|
||
This might be the reason for a webcompat bug on Firefox.
https://webcompat.com/issues/44208
Updated•5 years ago
|
Comment 15•4 years ago
|
||
Resetting assignee which I don't work on in this several months.
Updated•2 years ago
|
Comment 16•2 years ago
|
||
Just wanted to say that this issue has created a lot discussions on another GitHub project - Select2:
https://github.com/select2/select2/issues/5457
It took us a while to figure out that the usability problem we were facing was related to Firefox and not Select2.
Description
•