Bug 225639 - [iOS] HTML datepicker's min-max attribute not working
Summary: [iOS] HTML datepicker's min-max attribute not working
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: Other
Hardware: iPhone / iPad iOS 14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-11 00:12 PDT by Kalpeshkumar Jain
Modified: 2024-07-22 10:51 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kalpeshkumar Jain 2021-05-11 00:12:04 PDT
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.
Comment 1 Radar WebKit Bug Importer 2021-05-18 00:13:17 PDT
<rdar://problem/78142509>
Comment 2 Ahmad Saleem 2023-05-31 14:54:59 PDT
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.
Comment 3 Aditya Keerthi 2023-05-31 15:50:36 PDT
This is still relevant on iOS.
Comment 4 Karl Dubost 2023-05-31 20:01:45 PDT
* macOS is working well and enforcing the max date
* iOS still doesn't enforce the max date
Comment 5 Darryl Pogue 2024-04-20 16:36:05 PDT
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.
Comment 6 Haroen Viaene 2024-07-22 10:51:17 PDT
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.