Skip to content
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

[Bug] Clearing a DatePickerField doesn't allow you to pick the same date without changing it first #84

Closed
BinaryAssault opened this issue Nov 4, 2022 · 8 comments · Fixed by #804
Labels
bug Something isn't working control-datepickerfield platform-android Something is related to Android platform-ios Something is related to iOS stuck 🚧
Milestone

Comments

@BinaryAssault
Copy link
Contributor

BinaryAssault commented Nov 4, 2022

Using the following steps, you will see that the DatePickerField will not allow you to reselect the same date after clearing it:

  1. In a DatePickerField, select some date
  2. Clear the date via the clear 'X' button
  3. Reselect the same date
  4. Notice that the new date is not in the DatePickerField

Edit --
This is also true when nothing is selected and you attempt to select today's date.

@enisn enisn added bug Something isn't working control-datepickerfield labels Nov 7, 2022
@enisn enisn modified the milestones: 1.1, 2.0.x Nov 8, 2022
@enisn enisn added platform-android Something is related to Android platform-ios Something is related to iOS labels Nov 18, 2022
@enisn
Copy link
Owner

enisn commented Nov 18, 2022

This is strange behavior. I found the reason but hadn't seen any solution yet.

@enisn enisn modified the milestones: 2.0.x, 2.1 Nov 19, 2022
@enisn enisn modified the milestones: 2.1, 2.2 Dec 6, 2022
@enisn enisn modified the milestones: 2.2, 2.3 Jan 30, 2023
@StepKie
Copy link
Contributor

StepKie commented May 8, 2023

I found the reason but hadn't seen any solution yet.

Can you shed some light as to what you found the reason to be, and what the problem is (i.e., why is it stuck?). This is still affecting us...

Alternatively, any workarounds?

Thanks.

@enisn
Copy link
Owner

enisn commented May 8, 2023

Since it uses default MAUI datepicker, clearing works only on the UI side. The original datepicker still keeps the date because it doesn't support null values. I'll try add some native code with Custom Handlers to overcome this issue.

Content of the DatePickerField is a regular MAUI DatePicker

https://github.com/enisn/UraniumUI/blob/cc0928368057de92601cef3020bc9a49cb862dbc/src/UraniumUI.Material/Controls/DatePickerField.cs#LL13C62-L13C62

@StepKie
Copy link
Contributor

StepKie commented Jan 15, 2024

I just wanted to give this issue a gentle bump. ;)

This is still the case and observable in the demo DatePickerFieldPage, where Date is initially null, and cannot even be set to the current date by invoking the picker and clicking ok.

@lamotuab
Copy link

lamotuab commented Feb 9, 2024

I have an issue where the initial value is displayed, with a low opacity, behind the title until a new value is selected. XAML code is as follows:

                    <material:DatePickerField
                        Date="{Binding OpeningBalance.Date, Mode=TwoWay}"
                        Format="dd-MMM-yy"
                        Title="Date"
                        WidthRequest="150" >
                        <validation:RequiredValidation />
                    </material:DatePickerField>
Screenshot 2024-02-09 at 13 14 03

Is this related to this issue or something different?

@dean-toolhound
Copy link

Regarding the original bug, it is the Maui DatePicker that is the issue. This issue has been open for over a year without resolution - [(https://github.com/dotnet/maui/issues/13156)].

There is a work around mentioned in the issue that could be implemented here.

 public class FormDatePicker : Microsoft.Maui.Controls.DatePicker, IDatePicker
 {
     DateTime IDatePicker.Date
     {
         get => Date;
         set
         {
             if (value.Equals(DateTime.Today.Date))
                 Date = value.AddDays(-1);
             Date = value;
             OnPropertyChanged(nameof(Date));
         }
     }
 }

@StepKie
Copy link
Contributor

StepKie commented Oct 10, 2024

@enisn I created a pull request, please take a look. Tested successfully in UraniumApp.

edit: I also requested it to be considered again in dotnet/maui#13156, since this is not really a desirable state.

@enisn
Copy link
Owner

enisn commented Oct 10, 2024

Thanks for your contribution, I'll check as soon as possible and try to release it quickly after merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working control-datepickerfield platform-android Something is related to Android platform-ios Something is related to iOS stuck 🚧
Projects
None yet
5 participants