Bug 225639
| Summary: | [iOS] HTML datepicker's min-max attribute not working | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Kalpeshkumar Jain <kalpeshjain89> |
| Component: | Forms | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | ahmad.saleem792, akeerthi, cdumez, dvpdiner2, hello, karlcow, webkit-bug-importer, wenson_hsieh |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Other | ||
| Hardware: | iPhone / iPad | ||
| OS: | iOS 14 | ||
Kalpeshkumar Jain
Using html input type date in the hybrid application launches the native datepicker in the app.
At certain instances the date selection should be restricted till present date only.
We have used the max attribute to achieve this feature, however for some reasons the datepicker does not respect this attribute and allows the User to select future dates.
Below is the markup to replicate the behavior:
<form>
<label for="dob">Choose your date of birth:</label>
<input type="date" name="dob" id="dob" max="2017-04-30" />
</form>
Expected Behavior:
User should not be allowed to select future dates.
Actual Behavior:
User can select future dates.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/78142509>
Ahmad Saleem
I changed the test from Comment 0 in below JSFiddle:
https://jsfiddle.net/dkju3a5g/
I am unable to select 'future' date as expected behavior even in Safari 16.5. I think we can mark this as 'RESOLVED CONFIGURATION CHANGED'.
Just wanted to get another opinion so will CC - Aditya & Karl to reconfirm my testing.
Aditya Keerthi
This is still relevant on iOS.
Karl Dubost
* macOS is working well and enforcing the max date
* iOS still doesn't enforce the max date
Darryl Pogue
This seems to be due to the iOS date picker being a custom implementation through WKContentViewInteraction rather than implementing a WebDateTimePicker through the page client. My guess is because the iOS implementation predates the refactoring done to bring this to desktop platforms like macOS and GTK.
https://github.com/WebKit/WebKit/blob/e004ae642c29d20e9684279124065f07a98883fb/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm#L990-L995
WKContentViewInteraction sets up the WKDateTimeInputControl based on the focusedElementInformation, which does not contain the min/max values.
WebDateTimePicker is meant to get called with WebCore::DateTimeChooserParameters that provides all the values needed to set up the picker correctly.
To further complicate the situation, the iOS side also has some special case handling for date/time pickers on watchOS that use a different UI library.
Haroen Viaene
I'd like to add that the macOS implementation does indeed not allow people to select a value outside of the range, visually it's impossible to see which is a valid date and which isn't.