From be8a0cf217c577a75abb07bd6e8dfce04ca32004 Mon Sep 17 00:00:00 2001 From: chinboy Date: Sat, 27 Dec 2025 21:35:17 +0800 Subject: [PATCH] Fix Selection isEnabled bug --- .../Views/DataEntry/SelectShowCase.axaml | 2 +- src/AtomUI.Desktop.Controls/Select/Select.cs | 6 ++- .../Select/SelectOptions.cs | 6 ++- .../Select/Themes/SelectOptionItemTheme.axaml | 43 +++++++++---------- .../Select/Themes/SelectTheme.axaml | 13 ++++-- 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/controlgallery/AtomUIGallery/ShowCases/Views/DataEntry/SelectShowCase.axaml b/controlgallery/AtomUIGallery/ShowCases/Views/DataEntry/SelectShowCase.axaml index 5b8d45533..b0cdffc15 100644 --- a/controlgallery/AtomUIGallery/ShowCases/Views/DataEntry/SelectShowCase.axaml +++ b/controlgallery/AtomUIGallery/ShowCases/Views/DataEntry/SelectShowCase.axaml @@ -13,7 +13,7 @@ - + diff --git a/src/AtomUI.Desktop.Controls/Select/Select.cs b/src/AtomUI.Desktop.Controls/Select/Select.cs index feac4e9f4..24293116c 100644 --- a/src/AtomUI.Desktop.Controls/Select/Select.cs +++ b/src/AtomUI.Desktop.Controls/Select/Select.cs @@ -799,7 +799,11 @@ public class Select : TemplatedControl, { if (Mode == SelectMode.Single) { - SetCurrentValue(IsDropDownOpenProperty, false); + var optionItem = source.FindAncestorOfType(); + if (optionItem != null && optionItem.IsEnabled) + { + SetCurrentValue(IsDropDownOpenProperty, false); + } } e.Handled = true; } diff --git a/src/AtomUI.Desktop.Controls/Select/SelectOptions.cs b/src/AtomUI.Desktop.Controls/Select/SelectOptions.cs index e39bad497..e350e75ff 100644 --- a/src/AtomUI.Desktop.Controls/Select/SelectOptions.cs +++ b/src/AtomUI.Desktop.Controls/Select/SelectOptions.cs @@ -294,8 +294,12 @@ internal class SelectOptions : List { for (var i = 0; i < ItemCount; i++) { + var item = ListDefaultView.Items[i]; var container = ListDefaultView.ContainerFromIndex(i); - container?.SetCurrentValue(IsEnabledProperty, true); + if (item is ISelectOption selectOption) + { + container?.SetCurrentValue(IsEnabledProperty, selectOption.IsEnabled); + } } } } diff --git a/src/AtomUI.Desktop.Controls/Select/Themes/SelectOptionItemTheme.axaml b/src/AtomUI.Desktop.Controls/Select/Themes/SelectOptionItemTheme.axaml index 24bbf94dd..dcceb534b 100644 --- a/src/AtomUI.Desktop.Controls/Select/Themes/SelectOptionItemTheme.axaml +++ b/src/AtomUI.Desktop.Controls/Select/Themes/SelectOptionItemTheme.axaml @@ -9,31 +9,28 @@ - - - - - - - + + + + + + + + + - diff --git a/src/AtomUI.Desktop.Controls/Select/Themes/SelectTheme.axaml b/src/AtomUI.Desktop.Controls/Select/Themes/SelectTheme.axaml index 95d3282cf..9c57805a4 100644 --- a/src/AtomUI.Desktop.Controls/Select/Themes/SelectTheme.axaml +++ b/src/AtomUI.Desktop.Controls/Select/Themes/SelectTheme.axaml @@ -151,7 +151,10 @@ + @@ -177,7 +180,9 @@