Summary: There is a long standing issue about the event order of `|compositionend|` and `|input|` at committing composition. Gecko dispatches them as:

1. `|beforeinput|` whose `|isComposing|` is `|true|`
2. `|compositionend|`
3. `|input|` whose `|isComposing|` is `|false|`

However, Chrome dispatches them as:

1. `|beforeinput|` whose `|isComposing|` is `|true|`
2. `|input|` whose `|isComposing|` is `|true|`
3. `|compositionend|`

The reason why we cannot align this behavior to Chrome is, there is no `input` event whose `isComposing` is `false`. Therefore, web apps cannot handle `input` events only with `input` events to avoid to do something during IME composition, i.e., web apps needs to listen `compositionstart` and `compositionend` for doing that. So, once we align the behavior to Chrome as-is, we may need to rewrite our chrome JS code with more event listeners. Therefore, I filed a spec issue <https://github.com/w3c/uievents/issues/202> several years ago, but it's still not agreed between browser vendors.

However, now, we have a web-compat report <https://bugzilla.mozilla.org/show_bug.cgi?id=1910865> which is caused by this event order difference. The web site explicitly sets `|HTMLInputElement.value|` at every `|input|` event except during IME composition. For supporting IME, they set the value from `|compositionend|` too with new value which is stored at the last `|input|` event. Therefore, they set previous composition on Firefox if the user selects a commit string from the candidate list without updating the composition string.

For avoiding the web-compat issue on the web site, I think Gecko can dispatch redundant `|input|` event before `|compositionend|`, so,

1. `|beforeinput|` whose `|isComposing|` is `|true|`
2. `|input|` whose `|isComposing|` is `|true|`
3. `|compositionend|`
4. `|input|` whose `|isComposing|` is `|false|`

So, the new behavior causes alone `|input|` event which is not following a corresponding `|beforeinput|` event, but I guess this does not cause new web-compat issue.

Bug: <https://bugzilla.mozilla.org/show_bug.cgi?id=1941973>

Specification: UI Events <https://w3c.github.io/uievents/#events-composition-input-events>

Platform coverage: All

Preference: `|dom.input_events.dispatch_before_compositionend|`

DevTools bug: N/A

web-platform-tests: N/A (cannot synthesize composition with TestDriver)

--
Masayuki Nakano<[email protected]>
Working on DOM, Events, editor and IME handling for Gecko

--
You received this message because you are subscribed to the Google Groups 
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/141daa20-c9b5-4923-90af-7200c727ba78%40d-toybox.com.

Reply via email to