[iOS] Fix DatePicker to default to Today's date when Date is null/MinimumDate#30642
[iOS] Fix DatePicker to default to Today's date when Date is null/MinimumDate#30642
Conversation
…Date Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
73e4e28 to
736aa95
Compare
|
I've rebased this PR to a different branch which has a different API surface for DatePicker Can you restart this work with a fresh perspective based on the current state of the code vs your initial plan |
…ew nullable API Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
I've restarted the work with a fresh perspective based on the current code state. The solution now properly handles the new nullable DateTime API and implements the fix for both iOS and Mac Catalyst platforms. Key changes in commit 106d4a9:
The fix ensures that when Date is null, the iOS/Mac Catalyst picker displays today's date instead of 1/1/1900 or crashing. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description
This PR fixes an issue where the iOS DatePicker would display the MinimumDate (1900-01-01) instead of Today's date when the Date property is set to null or default values.
Problem
When a DatePicker's Date property is set to null or
DateTime.MinValue, the value gets coerced toMinimumDate(1900-01-01) due to the DatePicker's validation logic. The iOS picker then displays this historical date instead of defaulting to Today's date as users would expect.Solution
The fix checks if the Date equals MinimumDate in the iOS platform code and uses
DateTime.Todayfor the native picker dialog instead, while preserving the actual Date value in the virtual view.Key changes:
DatePickerHandler.iOS.csConnectHandler method to detect MinimumDate and use Today's dateDatePickerExtensions.iOS.csUpdateDate methods with the same logicTesting
Behavior
This provides a significantly better user experience when initializing DatePickers with null/default dates while maintaining backward compatibility.
Fixes #30641.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.