Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.3.1-beta32</Version>
<Version>9.3.1-beta33</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 7 additions & 2 deletions src/BootstrapBlazor/Components/Select/Select.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ private SelectedItem? SelectedRow

private SelectedItem? GetSelectedRow()
{
var item = Rows.Find(i => i.Value == CurrentValueAsString)
var item = GetItemWidthEnumValue()
?? Rows.Find(i => i.Value == CurrentValueAsString)
?? Rows.Find(i => i.Active)
?? Rows.FirstOrDefault(i => !i.IsDisabled)
?? GetVirtualizeItem(CurrentValueAsString);
Expand All @@ -314,6 +315,10 @@ private SelectedItem? SelectedRow
return item;
}

private SelectedItem? GetItemWidthEnumValue() => ValueType.IsEnum
? Rows.Find(i => i.Value == Convert.ToInt32(Value).ToString())
: null;

private List<SelectedItem> GetRowsByItems()
{
var items = new List<SelectedItem>();
Expand All @@ -328,7 +333,7 @@ private List<SelectedItem> GetRowsByItems()
private List<SelectedItem> GetRowsBySearch()
{
var items = OnSearchTextChanged?.Invoke(SearchText) ?? FilterBySearchText(GetRowsByItems());
return items.ToList();
return [.. items];
}

private IEnumerable<SelectedItem> FilterBySearchText(IEnumerable<SelectedItem> source) => string.IsNullOrEmpty(SearchText)
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Extensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ public static bool TryConvertTo<TValue>(this string? source, [MaybeNullWhen(fals
}
else if (source == string.Empty)
{
ret = BindConverter.TryConvertTo<TValue>(source, CultureInfo.CurrentCulture, out val);
ret = BindConverter.TryConvertTo(source, CultureInfo.CurrentCulture, out val);
}
else
{
var isBoolean = type == typeof(bool);
var v = isBoolean ? (object)source.Equals("true", StringComparison.CurrentCultureIgnoreCase) : source;
ret = BindConverter.TryConvertTo<TValue>(v, CultureInfo.CurrentCulture, out val);
ret = BindConverter.TryConvertTo(v, CultureInfo.CurrentCulture, out val);
}
}
catch
Expand Down