dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.16k stars 1.74k forks source link

Setting MinimumDate and MaximumDate in DatePicker breaks the calendar view. #15309

Open MichaelShapiro opened 1 year ago

MichaelShapiro commented 1 year ago

Description

Setting MinimumDate and MaximumDate AFTER the DatePicker was tapped and calendar popup was displayed breaks the calendar view and shows wrong month. This happens on Android.

DatePickerBug.webm

Steps to Reproduce

Repo is linked.

A page has a DatePicker and a Button. Button has a Clicked event

<Button Text="Set range from  2/13/23  to  2/18/23" Clicked="Button_Clicked_1"/>

<DatePicker x:Name="bigBug"/>

In the code-behind, the button's Clicked event simply sets the MinimumDate and MaximumDate value for the DatePicker

    private void Button_Clicked_1(object sender, EventArgs e)
    {
        bigBug.MinimumDate = new DateTime(2023, 2, 13);
        bigBug.MaximumDate = new DateTime(2023, 2, 18);

        bigBug.Date = new DateTime(2023, 2, 15);
    }

Now do the following sequence of steps:

  1. Tap the DatePicker: the calendar popup shows the CURRENT date and month. Min and max dates have not been applied yet.
  2. Tap "Cancel" or "OK" on a calendar. The calendar popup goes away.
  3. Tap the Button. The code-behind sets the Min and Max dates and the selected date to be February 15 for the DatePicker.
  4. Tap the DatePicker again.

Expected outcome

A calendar popup with the February as a displayed month

Actual outcome

The top (Header) section shows the correct date but the actual calendar display wrong month.

InkedScreenshot_1685217024

Link to public reproduction project repository

https://github.com/MichaelShapiro/DatePickerBug.git

Version with bug

7.0.86

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

No

Relevant log output

No response

MichaelShapiro commented 1 year ago

curious if there are any next steps that would bring this to a potential fix?

XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.7.0 Preview 3.0. Repro on Android 13.0-API33 .NET 8, not repro on Windows 11 and iOS 16.4 with below Project: DatePickerBug.zip

image