- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.9k
 
[Windows] Fix for TimePicker rendering a default time when its value is null #32314
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
base: main
Are you sure you want to change the base?
Conversation
| 
           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.  | 
    
| 
           /azp run  | 
    
| 
          
Azure Pipelines successfully started running 3 pipeline(s). | 
    
| nativeTimePicker.Time = timePicker.Time ?? TimeSpan.Zero; | ||
| if (timePicker.Time is null) | ||
| { | ||
| nativeTimePicker.ClearValue(TimePicker.TimeProperty); | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() | 
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
| 
           /azp run  | 
    
| 
          
Azure Pipelines successfully started running 3 pipeline(s). | 
    
There was a problem hiding this 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 toTimeSpan.Zero) toSelectedTime(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 | 
| 
           /azp run  | 
    
| 
          
Azure Pipelines successfully started running 3 pipeline(s). | 
    
…hots for Windows platform

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
Root Cause
Windows :
Description of Change
Regarding Mac Platform :
Issues Fixed
Fixes #32266
Validated the behaviour in the following platforms
Output