diff --git a/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor.cs index c03662b6..58e37f38 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor.cs @@ -468,7 +468,7 @@ protected async Task SyncMultiselectionValues(bool singleToMultiselection) } else { - if (Value is string && string.IsNullOrEmpty(Converter.Set(Value))) + if (Value is string && string.IsNullOrWhiteSpace(Converter.Set(Value))) { SelectedValues = new HashSet(); } @@ -601,7 +601,7 @@ protected Task UpdateDataVisualiserTextAsync() var item = Items.FirstOrDefault(x => x != null && (x.Value == null ? val == null : Comparer != null ? Comparer.Equals(x.Value, val) : x.Value.Equals(val))); if (item != null) { - textList.Add(!string.IsNullOrEmpty(item.Text) ? item.Text : Converter.Set(item.Value)); + textList.Add(!string.IsNullOrWhiteSpace(item.Text) ? item.Text : Converter.Set(item.Value)); } } } @@ -632,7 +632,7 @@ protected Task UpdateDataVisualiserTextAsync() var item = Items.FirstOrDefault(x => Value == null ? x.Value == null : Comparer != null ? Comparer.Equals(Value, x.Value) : Value.Equals(x.Value)); _dataVisualiserText = item is null ? Converter.Set(Value) - : (!string.IsNullOrEmpty(item.Text) ? item.Text : Converter.Set(item.Value)); + : (!string.IsNullOrWhiteSpace(item.Text) ? item.Text : Converter.Set(item.Value)); return Task.CompletedTask; } @@ -934,16 +934,13 @@ protected internal async Task HandleOnBlur(FocusEventArgs obj) // Restore the previous selected item, if any. if (Value is not null) { - if (!Editable) - { - item = Items.FirstOrDefault(x => x.Value.Equals(Value)); - if (item is not null) - await ToggleOption(item, true); - - // Remove non-matching search string. - else - await Clear(); - } + item = Items.FirstOrDefault(x => x.Value.Equals(Value)); + if (item is not null) + await ToggleOption(item, true); + + // Remove non-matching search string. + else + await Clear(); } // There was no previous selected item. Remove non-matching search string. diff --git a/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBoxItem.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBoxItem.razor.cs index b1f32d3c..97de8724 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBoxItem.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBoxItem.razor.cs @@ -24,7 +24,7 @@ public partial class MudComboBoxItem : MudBaseSelectItem, IDisposable .Build(); protected string HighlighterClassname => new CssBuilder() - .AddClass("mud-combobox-highlighter", MudComboBox is not null && MudComboBox.Highlight && string.IsNullOrEmpty(MudComboBox.HighlightClass)) + .AddClass("mud-combobox-highlighter", MudComboBox is not null && MudComboBox.Highlight && string.IsNullOrWhiteSpace(MudComboBox.HighlightClass)) .AddClass(MudComboBox?.HighlightClass, MudComboBox is not null && MudComboBox.Highlight) .Build(); @@ -97,8 +97,8 @@ protected string DisplayString } if (converter == null) - return $"{(string.IsNullOrEmpty(Text) ? Value : Text)}"; - return !string.IsNullOrEmpty(Text) ? Text : converter.Set(Value); + return $"{(string.IsNullOrWhiteSpace(Text) ? Value : Text)}"; + return !string.IsNullOrWhiteSpace(Text) ? Text : converter.Set(Value); } } @@ -158,7 +158,7 @@ protected bool IsEligible() return true; } - if (string.IsNullOrEmpty(MudComboBox._searchString)) + if (string.IsNullOrWhiteSpace(MudComboBox._searchString)) { return true; } @@ -168,7 +168,7 @@ protected bool IsEligible() return MudComboBox.SearchFunc.Invoke(Value, Text, MudComboBox.GetSearchString()); } - if (string.IsNullOrEmpty(Text) == false) + if (string.IsNullOrWhiteSpace(Text) == false) { if (Text.Contains(MudComboBox._searchString ?? string.Empty, StringComparison.CurrentCultureIgnoreCase)) {