Skip to content

Conversation

@jsuarezruiz
Copy link
Contributor

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

  • When DatePicker.Date is null, the MacCatalyst picker will display today's date when opened
  • The virtual view Date property remains null (as expected)
  • Transitions between null and specific dates work correctly
  • Existing functionality with non-null dates remains unchanged

Issues Fixed

Fixes #31124

@jsuarezruiz jsuarezruiz added the area-testing Unit tests, device tests label Aug 27, 2025
Copilot AI review requested due to automatic review settings August 27, 2025 11:50
@jsuarezruiz jsuarezruiz added the area-controls-datetimepicker DatePicker, TimePicker label Aug 27, 2025
@jsuarezruiz jsuarezruiz requested a review from a team as a code owner August 27, 2025 11:50
@jsuarezruiz jsuarezruiz changed the title Fix 31124 [MacCatalyst] DatePicker null date handling Aug 27, 2025
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 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}";
Copy link

Copilot AI Aug 27, 2025

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.

Suggested change
_dateLabel.Text = $"Current Date: {_datePicker.Date:d}";
_dateLabel.Text = $"Current Date: {_datePicker.Date?.ToString("d") ?? "(null)"}";

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,54 @@
using System.Text.RegularExpressions;
Copy link

Copilot AI Aug 27, 2025

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.

Suggested change
using System.Text.RegularExpressions;

Copilot uses AI. Check for mistakes.
@jfversluis jfversluis added this to the .NET 10.0-rc2 milestone Aug 27, 2025
@jfversluis jfversluis enabled auto-merge August 27, 2025 20:22
@jfversluis jfversluis merged commit 98128ef into net10.0 Aug 27, 2025
148 checks passed
@jfversluis jfversluis deleted the fix-31124 branch August 27, 2025 21:47
@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-datetimepicker DatePicker, TimePicker area-testing Unit tests, device tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants