[w3c/uievents] Event order between "compositionend" and "input" (#202)

Currently, UI Events declares event order of "composititionend" and "input" are:

1. beforeinput
2. (compositionupdate)
3. input
4. compositionend
5. (no input)

At <https://w3c.github.io/uievents/#events-composition-input-events>

However, Firefox and Edge's order is:

1. (beforeinput not yet supported on them)
2. (compositionupdate)
3. (no input)
4. compositionend
5. input

I.e., "input" event is fired after "compositionend".

On the other hand, Chrome and Safari dispatches as the spec declared.

I tried to make Firefox take the same event order as the draft in <https://bugzilla.mozilla.org/show_bug.cgi?id=1305387>. However, after changing the order, I needed following change in some places even in Firefox's UI: <https://hg.mozilla.org/try/rev/9dbba7ff1d6f7f72a33dccc93fdda60f04d9942e>

Then, I feel that the event order of Chrome, Safari and the spec does **not** make sense for web application developers. The reason is, if all browsers use the event order of Firefox and Edge, isComposing value of "input" event becomes false. So, if a web application needs to do something at every input except during composition, web application needs to listen to **only** input event if it's run on Firefox or Edge. I.e., can be implemented like:

```
foo.addEventListener("input", (event) => {
  if (event.isComposing) {
    // Nothing to do during composition
    return;
  }
  // Do something what you need.
});
```

On the other hand, it's run on Chrome or Safari, needs to be implemented like:

```
function onInput() {
  // Do something what you need.
}
foo.addEventListener("input", (event) => {
  if (event.isComposing) {
    // Nothing to do during composition
    return;
  }
  onInput();
});
foo.addEventListener("compositionend", (event) => {
  // Need to run "input" event handler here because "input" event whose isComposing is false
  // won't be fired until user inputs something without IME later. 
  onInput();
});
```

I believe that the behavior of Chrome, Safari and UI Events may make web applications not aware of IME.

>From point of view of browser developer, this behavior is easier to implement actually since browser does not check whether it's followed by compositionend event when it tries to fire "input" event at every composition change. However, usefulness for web application developers must be more important than easier to implement by browsers.

What do you think, @garykac ?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/uievents/issues/202

Received on Saturday, 21 April 2018 04:37:21 UTC