-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Fix DatePicker MinimumDate/MaximumDate not updating dynamically #33687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Android] Fix DatePicker MinimumDate/MaximumDate not updating dynamically #33687
Conversation
|
Hey there @@HarishwaranVijayakumar! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a long-standing Android platform bug where DatePicker minimum and maximum date constraints fail to update dynamically after the initial setting. The issue manifests in dependent DatePicker scenarios where changing one picker's date should update another picker's minimum/maximum constraint.
Changes:
- Implements the established Android workaround by resetting min/max values before setting new constraints
- Adds ShowEvent handler to ensure constraints are re-applied after Android's internal dialog initialization
- Includes comprehensive UI tests with screenshot verification to validate the fix
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Core/src/Platform/Android/DatePickerExtensions.cs |
Added reset logic (MinDate=0, MaxDate=long.MaxValue) before setting new constraint values to force Android to invalidate cached values |
src/Core/src/Handlers/DatePicker/DatePickerHandler.Android.cs |
Added ShowEvent handler to re-apply min/max dates after dialog initialization, working around Android's dialog reuse caching issue |
src/Controls/tests/TestCases.HostApp/Issues/Issue19256.cs |
Created UI test page with two dependent DatePickers and buttons to reproduce the issue scenario |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19256.cs |
Created NUnit test with two-screenshot verification approach to validate dynamic MinimumDate updates |
src/Controls/tests/TestCases.Android.Tests/snapshots/android/DatePickerMinimumDateShouldUpdateDynamically_*.png |
Reference screenshots for automated visual verification (2 files) |
.github/agent-pr-session/pr-19256.md |
Agent session documentation tracking the fix development process |
|
/rebase |
172932c to
b4a8906
Compare
|
/azp run maui-pr-uitests, maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/rebase |
Issue Details
Behavior:
MinimumDate/MaximumDate→ Works correctlyMinimumDate/MaximumDate→ Fails to updateRoot Cause of the issue
Reference: StackOverflow
Description of Change
Android DatePicker Minimum/Maximum Date Update Fix:
Framework Fixes:
DatePickerHandler.Android.cs, a handler is added for the dialog'sShowEventto always re-apply the minimum and maximum dates after the dialog is initialized, ensuring changes are respected even when the dialog is reused.DatePickerExtensions.cs, bothUpdateMinimumDateandUpdateMaximumDatemethods now reset the underlying Android values (MinDateto 0,MaxDatetolong.MaxValue) before setting the new constraint, forcing Android to invalidate its cached values and accept updates. [1] [2]Testing Improvements:
Issue19256.cs) to the host app that sets up two dependentDatePickercontrols and buttons to simulate the bug scenario and verify the fix.These changes collectively ensure that the Android
DatePickernow correctly updates its constraints in response to changes, matching expected behavior.Issues Fixed
Fixes #19256
Output
Before_fix.mov
After_fix.mov