Closed Bug 1446722 Opened 2 years ago Closed 1 year ago

Onchange-event not triggered when resetting non-focused date-input-field (same for time-input-field)

Categories

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

60 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: gabriel, Assigned: mbrodesser)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files, 2 obsolete files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6

Steps to reproduce:

Clicked on the "x"-button of a date-input-field (that was not focused) to reset the date.
Clicked on the "x"-button of a time-input-field (that was not focused) to reset the date.

Both works fine if the field has focus (blue border).


Actual results:

The onchange-event is NOT fired.


Expected results:

The onchange-event should have been fired.
Hi Gabriel, thanks for reporting the issue.

What websites were you visiting where you can replicate this issue?
Component: Untriaged → DOM: Events
Flags: needinfo?(gabriel)
Product: Firefox → Core
no website needed.
you can replicate it with every <input type="date" onchange="alert('changed');" />

Gabriel
Flags: needinfo?(gabriel)
I see an alert when following the steps to reproduce on
data:text/html;charset=utf-8,<input type="date" onchange="alert('changed');" />
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
With what version on what system?

Thank you

(In reply to Henri Sivonen (:hsivonen) from comment #3)
> I see an alert when following the steps to reproduce on
> data:text/html;charset=utf-8,<input type="date" onchange="alert('changed');"
> />
(In reply to Gabriel Gritsch from comment #4)
> With what version on what system?

61.0a1 (2018-04-27) 64-bit on Ubuntu 16.04.
Hi,

its still reproducible, but I found out when it is reproducible with version 60.0:
it does NOT work if a value is preset when the page is loaded and you click on the "reset"-button.

You can test it with the code on that page:

https://www.gritsch-soft.com/ff/date.html

I have also created a short screencast to show the error:

https://ufile.io/itzau (link valid for 30 days).
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Version: 59 Branch → 60 Branch
I cannot reproduce this on Nightly 62
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago2 years ago
Resolution: --- → WORKSFORME
Sorry but I have to re-open it.
It is still reproducible on Nightly 62.0a1 (2018-05-26) on macOS 10.13.4 (not tested on other Systems).
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Priority: -- → P3
I just camed here because i encoutered the exact same issue.

I'll attach this issue a html test case. The input[date] have a default value and as you can see in the console if you clic the reset buton right after the page load the onChange event is not triggered. However if the input get the focus and then the reset buton trigger the onChange event.

The expected behavior is that no matter what the input have the focus or not if his value change then the onChange event should be triggered.
Attached file testcase.html
Can confirm i run into the same problem.
The Bug only appers
1. On a fresh request (because F5 and Strg+R let the predefined value disappear)
2. if the first interaction with the date field is the click on the X Icon (Once the date field get the focus, it works)
3. the value param is set (If no value is set the X Icon does not appear)

Test Code:
<input type="date" onchange="alert('changed')" value="2018-09-09" /> 

Environment: Firefox Quantum 62.0.3 (64-Bit), Ubuntu 18.04
I can reproduce this bug on Firefox Quantum 64b4 (64bit), Windows 10.
Component: DOM: Events → DMD
Component: DMD → DOM: Core & HTML
Still no fix?
Duplicate of this bug: 1518028
Duplicate of this bug: 1525552

this issue is not resolved from almost an year.😤

Assignee: nobody → mbrodesser
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

In order to trigger the 'onchange' event when resetting the 'date' or
'time' html input elements.

This review is only basis for discussion in order to determine if the
fix goes in the correct direction.

:smaug: can you please have a look at the attached review (https://bugzilla.mozilla.org/attachment.cgi?id=9051306). It is just a first version, reflecting my current understanding of the code. I'm interested if the fix is going in the correct direction. Any feedback is appreciated.

Flags: needinfo?(bugs)

Took a bit time to figure out that stuff, but looks reasonable.
Store the initial value early so that we can compare later when value is set to "";

Flags: needinfo?(bugs)

In order to trigger the 'onchange' event when resetting the 'date' or
'time' html input elements.

Attachment #9051975 - Attachment is obsolete: true

In order to trigger the 'onchange' event when resetting the 'date' or
'time' html input elements.

Attachment #9051306 - Attachment is obsolete: true

The try run (https://treeherder.mozilla.org/#/jobs?repo=try&revision=fb92b88e86520088bd63f140da4f19d0afcf0849,) for the attached patch looks OK. It contains a few failures, but they are not related to this change.

Keywords: checkin-needed
Blocks: 1538124

Pushed by rmaries@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/98343ff41322
set default value for 'mFocusedValue' for the html input elements 'date' and 'time'. r=smaug

Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 2 years ago1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Duplicate of this bug: 1541394
You need to log in before you can comment on or make changes to this bug.