Open Bug 1918254 Opened 5 months ago Updated 5 months ago

preventDefault() in "beforeinput" doesn't prevent "input" and "change" events when using arrow keys or clicking the spin up/down buttons

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

People

(Reporter: whimboo, Unassigned)

References

Details

Attachments

(1 file)

Attached file testcase.html

On bug 1918049 I'm fixing the input event tests for input fields of type number. While doing so I noticed that the following tests are still failing. This happens because the use of preventDefault in the beforeinput handler doesn't stop us from emitting the input and change events, as well as incrementing or decrementing the actual displayed number.

  • testing/web-platform/tests/input-events/input-events-arrow-key-on-number-input-prevent-default.html
  • testing/web-platform/tests/input-events/input-events-spin-button-click-on-number-input-prevent-default.html

Using Chrome it works but as Olli pointed out this is most likely a recent change which we didn't follow-up on yet.

Steps to reproduce:

  1. Open the attached testcase
  2. Focus the input field
  3. Press the arrow up or down key
  4. Click the up/down spin button

For both steps 3 and 4 we emit all the events and also update the number accordingly. This should not happen given that preventDefault in beforeinput should actually prevent any update.

Component: DOM: Events → DOM: Core & HTML

Hi Masayuki,
Chrome changes this behavior recently and added the new test cases. Is this something we should/could put into your queue to fix?

Flags: needinfo?(masayuki)

Yeah, but currently my queue is full, but it seems that this is not so important since beforeinput event listeners usually don't close the window and redundant change event may be okay. Let's go back when I'm available.

Severity: -- → S3
Flags: needinfo?(masayuki)
Summary: preventDefault() in "beforeunload" doesn't prevent "input" and "change" events when using arrow keys or clicking the spin up/down buttons → preventDefault() in "beforeinput" doesn't prevent "input" and "change" events when using arrow keys or clicking the spin up/down buttons
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: