Bug 223465

Summary: input[type=date] fires a change event before user can select a date if no initial value
Product: WebKit Reporter: Bob Brown <bugs>
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: akeerthi, cdumez, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: iPhone / iPad   
OS: iOS 14   
URL: https://jsfiddle.net/e8ngLvmp/

Description Bob Brown 2021-03-18 12:13:33 PDT
Steps to Reproduce
Use this page: https://jsfiddle.net/e8ngLvmp/ or build a page with input type=date and no value attribute: <input type="date" name="date1" id="date1">
Hook the change event:
document.getElementById("date1").addEventListener("change",function() {
	alert('Change event signaled; value='+document.getElementById("date1").value);
});

Load the page using an iPad running iOS 14.41 and Safari 14.4, then touch or tap the date input element. (Not tested with other Apple devices.)

Expected behavior

The alert is shown after the user has selected a date using the date picker and the alert displays the selected date.

Actual behavior

The change event is fired as soon as the input field is tapped, the alert displays the current date, and the date picker is not shown until the alert is dismissed. Regardless of the date selected in the date picker, the input element shows the current date.

Notes:
This failure occurs only in the case that the input element has no value attribute. The date picker is focused on the current date, which is the only reasonable thing to do, but the current date is also set as a value on the input element and the change event signaled. That is the error.  This only happens when a page showing this behavior is initially loaded.
Comment 1 Radar WebKit Bug Importer 2021-03-25 12:14:14 PDT
<rdar://problem/75847384>