From 3ca00a8e795493cbd592a9cff5d1d7ea5ac7021b Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 21 Oct 2025 10:41:07 +0200 Subject: [PATCH 1/2] Fix #4250 --- src/Core/Components/List/ListComponentBase.razor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Core/Components/List/ListComponentBase.razor.cs b/src/Core/Components/List/ListComponentBase.razor.cs index d35d3a010e..085e21692e 100644 --- a/src/Core/Components/List/ListComponentBase.razor.cs +++ b/src/Core/Components/List/ListComponentBase.razor.cs @@ -483,7 +483,7 @@ protected virtual bool GetOptionSelected(TOption item) { return OptionSelected.Invoke(item); } - else if (SelectedOption == null) + else if (SelectedOption == null && string.IsNullOrEmpty(Value)) { return false; } @@ -491,6 +491,10 @@ protected virtual bool GetOptionSelected(TOption item) { return GetOptionValue(item) == GetOptionValue(SelectedOption); } + else if (!string.IsNullOrEmpty(Value) || !string.IsNullOrEmpty(InternalValue)) + { + return string.Equals(GetOptionValue(item), Value, StringComparison.Ordinal); + } else { return Equals(item, SelectedOption); From b97a6e4f9ad5f034cba1e4f6e306ce3801f369f9 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 21 Oct 2025 11:03:25 +0200 Subject: [PATCH 2/2] Refactor condition to check Value only Remove some test code --- src/Core/Components/List/ListComponentBase.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Components/List/ListComponentBase.razor.cs b/src/Core/Components/List/ListComponentBase.razor.cs index 085e21692e..a21bef098b 100644 --- a/src/Core/Components/List/ListComponentBase.razor.cs +++ b/src/Core/Components/List/ListComponentBase.razor.cs @@ -491,7 +491,7 @@ protected virtual bool GetOptionSelected(TOption item) { return GetOptionValue(item) == GetOptionValue(SelectedOption); } - else if (!string.IsNullOrEmpty(Value) || !string.IsNullOrEmpty(InternalValue)) + else if (!string.IsNullOrEmpty(Value)) { return string.Equals(GetOptionValue(item), Value, StringComparison.Ordinal); }