From 46d1aa6c64cfa694ccfc6ade3ebc276d6889dc6b Mon Sep 17 00:00:00 2001 From: Dong Bin Date: Fri, 28 Feb 2025 14:23:30 +0800 Subject: [PATCH] fix: minor fix for datepicker, simplify code. --- src/Ursa/Controls/DateTimePicker/DatePicker.cs | 6 ++---- src/Ursa/Controls/DateTimePicker/DateRangePicker.cs | 2 +- src/Ursa/Controls/DateTimePicker/DateTimePicker.cs | 2 +- src/Ursa/Controls/DateTimePicker/TimePicker.cs | 2 +- src/Ursa/Controls/DateTimePicker/TimeRangePicker.cs | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Ursa/Controls/DateTimePicker/DatePicker.cs b/src/Ursa/Controls/DateTimePicker/DatePicker.cs index 256cb7a..d557c7b 100644 --- a/src/Ursa/Controls/DateTimePicker/DatePicker.cs +++ b/src/Ursa/Controls/DateTimePicker/DatePicker.cs @@ -203,10 +203,8 @@ public class DatePicker: DatePickerBase, IClearControl FocusChanged(IsKeyboardFocusWithin); var top = TopLevel.GetTopLevel(this); var element = top?.FocusManager?.GetFocusedElement(); - if (element is Visual v && _popup?.IsInsidePopup(v)==true) - { - return; - } + if (element is Visual v && _popup?.IsInsidePopup(v) == true)return; + if (Equals(element, _textBox))return; CommitInput(true); SetCurrentValue(IsDropdownOpenProperty, false); } diff --git a/src/Ursa/Controls/DateTimePicker/DateRangePicker.cs b/src/Ursa/Controls/DateTimePicker/DateRangePicker.cs index 2bef08b..6f28da5 100644 --- a/src/Ursa/Controls/DateTimePicker/DateRangePicker.cs +++ b/src/Ursa/Controls/DateTimePicker/DateRangePicker.cs @@ -487,7 +487,7 @@ public class DateRangePicker : DatePickerBase, IClearControl return; } - if (element == _startTextBox || element == _endTextBox) + if (Equals(element, _startTextBox) || Equals(element, _endTextBox)) { return; } diff --git a/src/Ursa/Controls/DateTimePicker/DateTimePicker.cs b/src/Ursa/Controls/DateTimePicker/DateTimePicker.cs index 9fa1b06..8a8249b 100644 --- a/src/Ursa/Controls/DateTimePicker/DateTimePicker.cs +++ b/src/Ursa/Controls/DateTimePicker/DateTimePicker.cs @@ -234,7 +234,7 @@ public class DateTimePicker : DatePickerBase return; } - if (element == _textBox) + if (Equals(element, _textBox)) { return; } diff --git a/src/Ursa/Controls/DateTimePicker/TimePicker.cs b/src/Ursa/Controls/DateTimePicker/TimePicker.cs index 2661bad..09ff919 100644 --- a/src/Ursa/Controls/DateTimePicker/TimePicker.cs +++ b/src/Ursa/Controls/DateTimePicker/TimePicker.cs @@ -222,7 +222,7 @@ public class TimePicker : TimePickerBase, IClearControl var top = TopLevel.GetTopLevel(this); var element = top?.FocusManager?.GetFocusedElement(); if (element is Visual v && _popup?.IsInsidePopup(v) == true) return; - if (element == _textBox) return; + if (Equals(element, _textBox)) return; CommitInput(true); SetCurrentValue(IsDropdownOpenProperty, false); } diff --git a/src/Ursa/Controls/DateTimePicker/TimeRangePicker.cs b/src/Ursa/Controls/DateTimePicker/TimeRangePicker.cs index a331bce..b828b26 100644 --- a/src/Ursa/Controls/DateTimePicker/TimeRangePicker.cs +++ b/src/Ursa/Controls/DateTimePicker/TimeRangePicker.cs @@ -277,7 +277,7 @@ public class TimeRangePicker : TimePickerBase, IClearControl var top = TopLevel.GetTopLevel(this); var element = top?.FocusManager?.GetFocusedElement(); if (element is Visual v && _popup?.IsInsidePopup(v) == true) return; - if (element == _startTextBox || element == _endTextBox) return; + if (Equals(element, _startTextBox) || Equals(element, _endTextBox)) return; CommitInput(true); SetCurrentValue(IsDropdownOpenProperty, false); }