-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed DatePicker's DateSelected event not firing on Windows - NET 10 Preview 6 #30748
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
|
/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 a bug where the DatePicker's DateSelected event was not firing on Windows in .NET 10 Preview 6. The issue was caused by an incorrect null check condition that prevented the event from being triggered when the date changed.
- Fixed the conditional logic in DatePickerHandler.Windows.cs to properly detect date changes
- Added comprehensive device tests to verify the DateSelected event fires across all platforms
- Removed unnecessary access modifier from the DateChanged method
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs | Fixed condition check from null comparison to actual date comparison and cleaned up method signature |
| src/Controls/tests/DeviceTests/Elements/DatePicker/DatePickerTests.cs | Added comprehensive test coverage for DateSelected event firing across all platforms |
| if (handler.DatePickerDialog != null) | ||
| { | ||
| handler.DatePickerDialog.SetDate(newDate.ToNSDate(), false); | ||
| } |
Copilot
AI
Jul 23, 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.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| if (handler.DatePickerDialog != null) | |
| { | |
| handler.DatePickerDialog.SetDate(newDate.ToNSDate(), false); | |
| } | |
| if (handler.DatePickerDialog != null) | |
| { | |
| handler.DatePickerDialog.SetDate(newDate.ToNSDate(), false); | |
| } |
Copilot uses AI. Check for mistakes.
| #elif IOS | ||
| if (handler.DatePickerDialog != null) | ||
| { | ||
| handler.DatePickerDialog.SetDate(newDate.ToNSDate(), false); |
Copilot
AI
Jul 23, 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.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| handler.DatePickerDialog.SetDate(newDate.ToNSDate(), false); | |
| handler.DatePickerDialog.SetDate(newDate.ToNSDate(), false); |
Copilot uses AI. Check for mistakes.
| if (handler.DatePickerDialog != null) | ||
| { | ||
| handler.DatePickerDialog.SetDate(newDate.ToNSDate(), false); | ||
| } |
Copilot
AI
Jul 23, 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.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| } | |
| } |
Copilot uses AI. Check for mistakes.
| if (handler.PlatformView != null) | ||
| { | ||
| handler.PlatformView.Date = newDate; | ||
| } |
Copilot
AI
Jul 23, 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.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| if (handler.PlatformView != null) | |
| { | |
| handler.PlatformView.Date = newDate; | |
| } | |
| if (handler.PlatformView != null) | |
| { | |
| handler.PlatformView.Date = newDate; | |
| } |
Copilot uses AI. Check for mistakes.
| #elif WINDOWS | ||
| if (handler.PlatformView != null) | ||
| { | ||
| handler.PlatformView.Date = newDate; |
Copilot
AI
Jul 23, 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.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| handler.PlatformView.Date = newDate; | |
| handler.PlatformView.Date = newDate; |
Copilot uses AI. Check for mistakes.
| if (handler.PlatformView != null) | ||
| { | ||
| handler.PlatformView.Date = newDate; | ||
| } |
Copilot
AI
Jul 23, 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.
Inconsistent indentation detected. This line uses spaces while the surrounding code uses tabs. Please maintain consistent indentation throughout the file.
| } | |
| } |
Copilot uses AI. Check for mistakes.
| handler.PlatformView.Date = newDate; | ||
| } | ||
| #elif MACCATALYST | ||
| handler.PlatformView.Date = newDate.ToNSDate(); |
Copilot
AI
Jul 23, 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.
Inconsistent indentation detected. This line has an extra space before the tab character. Please maintain consistent indentation throughout the file.
| handler.PlatformView.Date = newDate.ToNSDate(); | |
| handler.PlatformView.Date = newDate.ToNSDate(); |
Copilot uses AI. Check for mistakes.
This is not entirely true. A change we made in .NET 10 is to make the Also please resolve the conflicts and address the feedback. |
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.
See above
e28a932 to
0593d78
Compare
@jfversluis I have updated the PR description to reflect that the Date property is nullable in .NET 10. I also verified that the fix correctly checks whether the new date differs from the existing one before firing the DateSelected event. attempted to add a test case that sets the Date to null, but it currently throws an exception. This issue will be handled in a separate PR, and a subsequent test case would be added in the same PR. |
|
@Dhivya-SF4094 Can you resolve the conflict please? :) |
0593d78 to
2559fb3
Compare
2559fb3 to
afcd64c
Compare
Conflicts has been resolved. |
|
/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.
See above
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 detail:
DatePicker's DateSelected event not firing on Windows - .NET 10 Preview 6
Root Cause
The DateSelected event was not firing on Windows due to an incorrect condition check. The original code used if (VirtualView.Date is null), which did not properly capture changes to the selected date. Although Date can be set to null, the check was not sufficient to determine whether the date had actually changed. As a result, the selected date was not updated, and the event was not triggered.
Description of Change
To resolve these issues, the condition was updated to if (VirtualView.Date != args.NewDate.Value.DateTime) to ensure the event triggers only when the selected date actually changes.
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #30736
Screenshots
30736_BeforeFix.mp4
30736_AfterFix.mp4