[w3c/uievents] Cancelable/default action for keydown, composition*, beforeinput, textInput, input (Issue #361)

While trying to figure out what spec text to propose for the `textInput` event (#353) I found that the spec doesn't seem to match implementations for the default action for the keydown, composition*, beforeinput, textInput, input events, and whether/when they're cancelable.

Demo: https://software.hixie.ch/utilities/js/live-dom-viewer/saved/12161

For example, https://w3c.github.io/uievents/#keydown says

> If the key is associated with a character, the default action MUST be to dispatch a [beforeinput](https://w3c.github.io/uievents/#beforeinput) event followed by an [input](https://w3c.github.io/uievents/#input) event.

However, in Chrome, Safari and Firefox, if you cancel a `beforeinput` event, no `input` event is fired.

Chrome and Safari support `textInput`, and if you cancel that event, no `input` event is fired.

So, assuming the correct event order for typing a single non-composing character in a text field is: 

1. keydown
2. beforeinput
3. textInput
4. input
5. keyup
 
...the default actions should be:

event | default action
--|---
keydown | fire beforeinput
beforeinput | fire textInput
textInput | fire input
input | none
keyup | none

During composition I think beforeinput isn't cancelable as implemented (try typing `ยจ` in the demo).

The spec also says that `compositionupdate` and `compositionend` are not cancelable, but in Chrome and Safari they are. In Firefox they are not cancelable, and `compositionstart` is also not cancelable.

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

Message ID: <w3c/uievents/issues/361@github.com>

Received on Thursday, 23 November 2023 22:46:19 UTC