Skip to content

Conversation

@SyedAbdulAzeemSF4852
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

  • On Windows, TimePicker renders a default time when its value is null, both on first load and after runtime updates, instead of showing an empty state.
  • On macOS, DatePicker and TimePicker render the default date/time when their values are null, again both initially and dynamically, rather than remaining empty.

Root Cause

Windows :

  • The TimePicker handler uses the null-coalescing operator with TimeSpan.Zero when the Time property is null. As a result, it defaults to 12:00 AM in 12-hour format and 00:00 in 24-hour format.

Description of Change

  • Updated TimePickerExtensions.UpdateTime to clear the native control's time value when the logical time is null, instead of defaulting to midnight.
  • Documentation : Time Picker

Regarding Mac Platform :

  • The same behavior is observed on the native platform as well. The values are not cleared when the date or time picker is set to null. In such cases, the default date or time is rendered.

Issues Fixed

Fixes #32266

Validated the behaviour in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Before After

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 31, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@SyedAbdulAzeemSF4852! 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 Oct 31, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

nativeTimePicker.Time = timePicker.Time ?? TimeSpan.Zero;
if (timePicker.Time is null)
{
nativeTimePicker.ClearValue(TimePicker.TimeProperty);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think WinUI expose a nullable SelectedTime that controls the unset state. Could set a null value directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz , Following the suggestion, I updated the code to assign timePicker.Time directly to the SelectedTime property, since WinUI exposes it as a nullable property.


[Test]
[Category(UITestCategories.TimePicker)]
public void VerifyTimePickerNotMidnightOnNull()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Could include a specific UITest for initial null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz , As suggested, I’ve added a test for the initial null case.


[Test]
[Category(UITestCategories.TimePicker)]
public void VerifyTimePickerNotMidnightOnNull()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshots on Mac and Windows already available in the latest build.

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz , Since I’ve modified the test case and its method name, I will add the snapshots for Mac and Windows platforms after the next CI run.

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@SyedAbdulAzeemSF4852 SyedAbdulAzeemSF4852 marked this pull request as ready for review November 4, 2025 06:03
Copilot AI review requested due to automatic review settings November 4, 2025 06:03
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 an issue where the Windows TimePicker incorrectly defaults to displaying midnight (00:00) when the Time value is null, instead of showing an empty/placeholder state. The fix changes the Windows platform implementation to use the SelectedTime property directly, which properly supports null values.

Key changes:

  • Updated Windows platform time assignment from Time (with null-coalescing to TimeSpan.Zero) to SelectedTime (supports nullable)
  • Added comprehensive UI tests verifying null initial state and cleared time behavior
  • Added platform-specific screenshot snapshots for iOS, macOS, and Android

Reviewed Changes

Copilot reviewed 3 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Core/src/Platform/Windows/TimePickerExtensions.cs Changed from Time property with null-coalescing to SelectedTime property for proper null handling
src/Controls/tests/TestCases.HostApp/Issues/Issue32266.cs Added test page with TimePicker initialized to null and buttons to set/clear time
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32266.cs Added UI tests verifying null state and clear behavior
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/*.png Added iOS screenshot baselines for both test scenarios
src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/*.png Added macOS screenshot baselines for both test scenarios
src/Controls/tests/TestCases.Android.Tests/snapshots/android/*.png Added Android screenshot baselines for both test scenarios

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

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/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nullable support is not working properly on Windows TimePicker and macOS DatePicker and TImePicker

2 participants