Open masayuki-nakano opened 4 months ago
For context, see:
- None otherwise.
Well, it does say "None otherwise" so that should cover all those not mentioned previously. So basically the ~dom~ value change and the before input event are not related in those cases. However, it sounds like that is not how it is implemented and not what is expected. So I agree we should probably make some change here.
https://issues.chromium.org/issues/40948436 is also related. It changed recently the behavior in Chrome so that one can call preventDefault() when changing type=number values using the spin buttons (assuming I understood it correctly).
UIEvents spec has a bit different definition: https://w3c.github.io/uievents/#event-type-beforeinput Based on that the target at least can be input or textarea (although that is quite vaguely said), but it still talks about DOM being updated. Form controls' value isn't part of the DOM tree.
From TPAC 2024 minutes:
RESOLUTION: for relevant input types and textarea, the default action should update the value and it’s cancelable. Browser makers find out which input types this should apply to (Olli will test).
This is still unclear to me:
the default action should update the value and it’s cancelable
When pressing Enter in an \<input> (which is single-line), it doesn't insert a newline, thus it doesn't change the value. Therefore, this action is not the default one. Here the action is universally to submit the form.
So, is it also in the scope of "cancelable" from the quote? I would tend to say yes.
Let me rephrase the quote to show how I perceive it:
The action is by default to update the value. The action is cancelable.
Also, as a reminder, the arguments I had posted in my comment 7 on Bugzilla:
- Users expect that preventDefault() does what is written on the tin: discards browser actions, as if the browser is no longer seeing the key input.
- That's what
keypress
andkeydown
do. But the former is deprecated, and the latter is less adequate, being about physical keyboard.- Using a
beforeinput
event (which is the recommended one), if removing the preventDefault() way, there would be no other way to avoid form submission…
https://w3c.github.io/input-events/#event-type-beforeinput
Currently, it's talking about only
contenteditable
andEditContext
.So, it does not define about
<input>
and<textarea>
.