w3c / input-events

Input Events
https://w3c.github.io/input-events/
Other
23 stars 16 forks source link

How browsers should handle default action of `beforeinput` event if it's NOT canceled by modified editor contents #106

Open masayuki-nakano opened 4 years ago

masayuki-nakano commented 4 years ago

For example, insertReplacementText indicates modifying all or partial text in editor. If the replacing text is modified by a beforeinput event listener, but it's not canceled, what should browsers do? Keep inserting new value at selection after beforeinput event?

Similarly, if selection is changed by beforeinput event listener when its inputType is delete*, browsers should keep deleting something with new selection?

Currently, nothing is declared by the specs.

johanneswilm commented 4 years ago

The spec does not specify what dom change the browser is to do if the event is not canceled. Notice that the browser should emit the event even when the action is not possible in the view of the browser (for example: user hits shortcut keys for bold, but the selection is collapsed).

A user agent MUST agent MUST dispatch [UI-EVENTS] this event when the user has attempted to input in a contenteditable element. It does not necessarily mean the user agent [UI-EVENTS] will then update the DOM.

Given that we do not specify how the browser should modify the DOM is not changed by an event listener, I think it would be consistent to also not specify the behavior if it has been modified. Alternatively, if consistency is desired and it is not too difficult to program, I would say that the DOM should not be modified in this case.