Closed Bug 1881419 Opened 2 years ago Closed 2 years ago

Programmatically setting the date input's value in a change event handler triggers change event in Firefox when it should not.

Categories

(Core :: DOM: Events, defect)

Firefox 123
defect

Tracking

()

RESOLVED FIXED
125 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox123 --- wontfix
firefox124 --- wontfix
firefox125 --- fixed

People

(Reporter: aayushkarna6191, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0

Steps to reproduce:

function onChange(event) {
  console.log('changed to ' + dateInput.value)
  dateInput.value = ''; // somehow triggers a second event
};

dateInput.addEventListener('change', onChange);
dateInput.value = '2024-02-07'; // does not trigger the event!

Actual results:

The chnage event is somehow caused by programmatically setting the value of the input field (and this should not be the case according to the specs: HTML Living Standard - Common input element events. The value printed to the console in the second event is identical to the value of the first event. Furthermore, setting the value outside the event handler does not trigger the event at all (as it should be).

Expected results:

In the event handler function, programmatically setting the date's value should not trigger the change event.

Spec: HTML Living Standard - Common input element events

More about this: Stack Overflow - How to temporarily remove event Listener in JavaScript

Component: Untriaged → DOM: Events
Product: Firefox → Core

Running a bisect it seems this got introduced by bug 1694413.

Flags: needinfo?(emilio)
Keywords: regression
Regressed by: 1694413

This was a latent bug exposed by the regressing bug (it was probably
possible to trigger it in some other ways before my patch).

Let changes just be communicated via the regular change event, otherwise
we send a redundant message which can trigger a duplicate change event,
if the change event itself modifies the input value.

Assignee: nobody → emilio
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(emilio)

Set release status flags based on info from the regressing bug 1694413

Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c2d34bbd3e78 Don't redundantly set input box value in datetime box. r=Gijs
Regressions: 1882173
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
Flags: in-testsuite+

The patch landed in nightly and beta is affected.
:emilio, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval. Also, don't forget to request an uplift for the patches in the regression caused by this fix.
  • If no, please set status-firefox124 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(emilio)

This can probably ride the trains.

Flags: needinfo?(emilio)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: