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)
Tracking
()
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
| Reporter | ||
Updated•2 years ago
|
Running a bisect it seems this got introduced by bug 1694413.
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 2•2 years ago
|
||
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.
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
Comment 3•2 years ago
|
||
Set release status flags based on info from the regressing bug 1694413
Comment 5•2 years ago
|
||
| bugherder | ||
Updated•2 years ago
|
Comment 6•2 years ago
|
||
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-firefox124towontfix.
For more information, please visit BugBot documentation.
Updated•2 years ago
|
Description
•