fix: minor fix for datepicker, simplify code.

This commit is contained in:
Dong Bin
2025-02-28 14:23:30 +08:00
parent 3dd15f57e3
commit 46d1aa6c64
5 changed files with 6 additions and 8 deletions

View File

@@ -203,10 +203,8 @@ public class DatePicker: DatePickerBase, IClearControl
FocusChanged(IsKeyboardFocusWithin); FocusChanged(IsKeyboardFocusWithin);
var top = TopLevel.GetTopLevel(this); var top = TopLevel.GetTopLevel(this);
var element = top?.FocusManager?.GetFocusedElement(); var element = top?.FocusManager?.GetFocusedElement();
if (element is Visual v && _popup?.IsInsidePopup(v)==true) if (element is Visual v && _popup?.IsInsidePopup(v) == true)return;
{ if (Equals(element, _textBox))return;
return;
}
CommitInput(true); CommitInput(true);
SetCurrentValue(IsDropdownOpenProperty, false); SetCurrentValue(IsDropdownOpenProperty, false);
} }

View File

@@ -487,7 +487,7 @@ public class DateRangePicker : DatePickerBase, IClearControl
return; return;
} }
if (element == _startTextBox || element == _endTextBox) if (Equals(element, _startTextBox) || Equals(element, _endTextBox))
{ {
return; return;
} }

View File

@@ -234,7 +234,7 @@ public class DateTimePicker : DatePickerBase
return; return;
} }
if (element == _textBox) if (Equals(element, _textBox))
{ {
return; return;
} }

View File

@@ -222,7 +222,7 @@ public class TimePicker : TimePickerBase, IClearControl
var top = TopLevel.GetTopLevel(this); var top = TopLevel.GetTopLevel(this);
var element = top?.FocusManager?.GetFocusedElement(); 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 (element == _textBox) return; if (Equals(element, _textBox)) return;
CommitInput(true); CommitInput(true);
SetCurrentValue(IsDropdownOpenProperty, false); SetCurrentValue(IsDropdownOpenProperty, false);
} }

View File

@@ -277,7 +277,7 @@ public class TimeRangePicker : TimePickerBase, IClearControl
var top = TopLevel.GetTopLevel(this); var top = TopLevel.GetTopLevel(this);
var element = top?.FocusManager?.GetFocusedElement(); 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 (element == _startTextBox || element == _endTextBox) return; if (Equals(element, _startTextBox) || Equals(element, _endTextBox)) return;
CommitInput(true); CommitInput(true);
SetCurrentValue(IsDropdownOpenProperty, false); SetCurrentValue(IsDropdownOpenProperty, false);
} }