-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[MacCatalyst] DatePicker null date handling #31365
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
Conversation
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 adds a UI test to validate DatePicker behavior when its Date property is set to null on macOS platforms. The test ensures that when a DatePicker's Date is set to null, the picker maintains today's date when opened while the virtual view Date property correctly remains null.
- Adds comprehensive UI test infrastructure for Issue 31124
- Creates test page with DatePicker, button, and label components for validation
- Implements automated test to verify null date handling behavior
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Controls/tests/TestCases.HostApp/Issues/Issue31124.cs |
Creates UI test page with DatePicker, button to set null date, and label to display current date |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31124.cs |
Implements NUnit test to validate DatePicker behavior when date is set to null |
| _datePicker.Date = null; | ||
|
|
||
| // Update the label to show the current date | ||
| _dateLabel.Text = $"Current Date: {_datePicker.Date:d}"; |
Copilot
AI
Aug 27, 2025
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.
This line will throw a NullReferenceException when _datePicker.Date is null. The format specifier :d cannot be applied to a null DateTime?. Consider using conditional formatting like _datePicker.Date?.ToString("d") ?? "(null)" or similar null-safe approach.
| _dateLabel.Text = $"Current Date: {_datePicker.Date:d}"; | |
| _dateLabel.Text = $"Current Date: {_datePicker.Date?.ToString("d") ?? "(null)"}"; |
| @@ -0,0 +1,54 @@ | |||
| using System.Text.RegularExpressions; | |||
Copilot
AI
Aug 27, 2025
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.
The System.Text.RegularExpressions namespace is imported but never used in this file. Consider removing this unused import.
| using System.Text.RegularExpressions; |
Description of Change
Created an UITest to validate the behavior and seems to be the same on iOS MacCatalyst. When the DatePicker Date value is set to null and the date picker is opened, the picker keeps today date.
Expected behavior
Issues Fixed
Fixes #31124