Skip to content

Conversation

@HarishwaranVijayakumar
Copy link
Contributor

Issue Details

  • Android DatePicker minimum/maximum date constraints don't update properly when changed dynamically. In a dependent DatePicker scenario (LEFT picker's date sets RIGHT picker's minimum), the RIGHT picker fails to respect the updated minimum date constraint.

Behavior:

  • First time setting MinimumDate/MaximumDate → Works correctly
  • Second time (or subsequent times) setting MinimumDate/MaximumDate → Fails to update

Root Cause of the issue

  • Android's DatePicker internally caches MinDate/MaxDate values and ignores subsequent setMinDate()/setMaxDate() calls unless the values are first reset.

Reference: StackOverflow

Description of Change

Android DatePicker Minimum/Maximum Date Update Fix:

  • Framework Fixes:

    • In DatePickerHandler.Android.cs, a handler is added for the dialog's ShowEvent to always re-apply the minimum and maximum dates after the dialog is initialized, ensuring changes are respected even when the dialog is reused.
    • In DatePickerExtensions.cs, both UpdateMinimumDate and UpdateMaximumDate methods now reset the underlying Android values (MinDate to 0, MaxDate to long.MaxValue) before setting the new constraint, forcing Android to invalidate its cached values and accept updates. [1] [2]
  • Testing Improvements:

    • Added a new UI test page (Issue19256.cs) to the host app that sets up two dependent DatePicker controls and buttons to simulate the bug scenario and verify the fix.
    • Added a corresponding NUnit UI test that automates the scenario and uses screenshots to verify that the minimum date updates dynamically as expected.

These changes collectively ensure that the Android DatePicker now correctly updates its constraints in response to changes, matching expected behavior.

Issues Fixed

Fixes #19256

Output

Before After
Before_fix.mov
After_fix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 23, 2026
@dotnet-policy-service
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 23, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review January 27, 2026 11:23
Copilot AI review requested due to automatic review settings January 27, 2026 11:23
@sheiksyedm
Copy link
Contributor

/azp run maui-pr-uitests 

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

Copilot AI left a 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

@PureWeen
Copy link
Member

/rebase

@PureWeen PureWeen added s/ai-reproduction-failed AI verified that tests pass without the fix, meaning they don't catch the bug s/ai-reproduction-confirmed AI verified that tests fail without the fix, confirming they catch the bug and removed s/ai-reproduction-failed AI verified that tests pass without the fix, meaning they don't catch the bug labels Jan 30, 2026
@PureWeen
Copy link
Member

/azp run maui-pr-uitests, maui-pr-devicetests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@PureWeen
Copy link
Member

PureWeen commented Feb 2, 2026

/rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-datetimepicker DatePicker, TimePicker community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/ai-reproduction-confirmed AI verified that tests fail without the fix, confirming they catch the bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[regression/8.0.3] [Android] DatePicker control minimum date issue

4 participants