Skip to content

Nullable DatePicker (make Date, MinimumDate & MaximumDate nullable) #27921

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

Merged
merged 12 commits into from
Apr 29, 2025

Conversation

jfversluis
Copy link
Member

@jfversluis jfversluis commented Feb 20, 2025

Description of Change

The long awaited feature of making the Date, MinimumDate, and MaximumDate properties of the DatePicker class nullable has been implemented!

Changes

  • DateTime DatePicker.Date -> DateTime? DatePicker.Date
  • DateTime DatePicker.MaximumDate -> DateTime? DatePicker.MaximumDate
  • DateTime DatePicker.MinimumDate -> DateTime? DatePicker.MinimumDate
  • Minor code styling and API docs changes

In #1100 it is proposed to also make the type DateOnly, while I like that, unfortunately that type is not available in netstandard so that would cause a lot of duplication of code and not great APIs and might even just be impossible because of that to make the XAML parsing and design time tooling work.

Instead, I think we should take #21989 in addition to this to still allow people to use DateOnly (and TimeOnly).

Issues Fixed

Contributes to #1100 (TimePicker PR in #27930)

@jfversluis

This comment was marked as outdated.

@jfversluis

This comment was marked as off-topic.

@jfversluis jfversluis force-pushed the net10-nullable-datepicker branch 4 times, most recently from de61f8b to 0adeaed Compare April 10, 2025 10:15
@jfversluis

This comment was marked as off-topic.

@github-actions github-actions bot force-pushed the net10-nullable-datepicker branch from 0adeaed to d971c7c Compare April 18, 2025 12:42
@jfversluis jfversluis marked this pull request as ready for review April 18, 2025 19:53
@Copilot Copilot AI review requested due to automatic review settings April 18, 2025 19:53
@jfversluis jfversluis requested a review from a team as a code owner April 18, 2025 19:53
@jfversluis jfversluis moved this from Todo to Ready To Review in MAUI SDK Ongoing Apr 18, 2025
Copy link
Contributor

@Copilot 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 pull request implements nullable support for the DatePicker properties in the core controls by transitioning Date, MinimumDate, and MaximumDate from non-nullable to nullable types.

  • Updated DatePicker properties and associated BindableProperties in DatePicker.cs and IDatePicker.cs.
  • Adapted platform renderers (Android, iOS, Windows) and handlers to handle nullable dates correctly.
  • Adjusted unit tests and PublicAPI documentation to reflect the changes.

Reviewed Changes

Copilot reviewed 37 out of 39 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Core/src/Handlers/DatePicker/DatePickerHandler.Android.cs Updated nullable handling in dialog creation and event attachment.
src/Core/src/Core/IDatePicker.cs Modified DatePicker interface to use nullable DateTime properties.
src/Controls/tests/… Updated unit tests to validate nullable date behavior.
src/Controls/src/Core/DatePicker/DatePicker.cs Converted bindable properties and coercion/validation logic to work with DateTime?
src/Compatiblity/…/DatePickerRenderer.cs (iOS/Windows/Android) Adjusted renderers to safely handle nullable dates and update formatting.
PublicAPI.Unshipped.txt files Updated API surface descriptions to reflect the nullable changes.
Files not reviewed (2)
  • src/Controls/docs/Microsoft.Maui.Controls/DateChangedEventArgs.xml: Language not supported
  • src/Controls/samples/Controls.Sample/Pages/Controls/DatePickerPage.xaml: Language not supported

@jfversluis jfversluis force-pushed the net10-nullable-datepicker branch from dfe03f0 to 176768e Compare April 21, 2025 15:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Apr 29, 2025
@rmarinho rmarinho merged commit 21ae686 into net10.0 Apr 29, 2025
128 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Apr 29, 2025
@rmarinho rmarinho deleted the net10-nullable-datepicker branch April 29, 2025 09:08
@github-actions github-actions bot locked and limited conversation to collaborators May 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants