Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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.5.6-beta04</Version>
<Version>9.5.6-beta05</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
28 changes: 21 additions & 7 deletions src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@
base.OnInitialized();

SkipRegisterEnterEscJSInvoke = true;

Items ??= [];

if (!string.IsNullOrEmpty(Value))
{
_filterItems = GetFilterItemsByValue(Value);
if (DisplayCount != null)
{
_filterItems = [.. _filterItems.Take(DisplayCount.Value)];
}

Check warning on line 105 in src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs

View check run for this annotation

Codecov / codecov/patch

src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs#L103-L105

Added lines #L103 - L105 were not covered by tests
}
}

/// <summary>
Expand All @@ -106,8 +117,6 @@
PlaceHolder ??= Localizer[nameof(PlaceHolder)];
Icon ??= IconTheme.GetIconByKey(ComponentIcons.AutoCompleteIcon);
LoadingIcon ??= IconTheme.GetIconByKey(ComponentIcons.LoadingIcon);

Items ??= [];
}

private bool _render = true;
Expand Down Expand Up @@ -151,11 +160,7 @@
}
else
{
var comparison = IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
var items = IsLikeMatch
? Items.Where(s => s.Contains(val, comparison))
: Items.Where(s => s.StartsWith(val, comparison));
_filterItems = [.. items];
_filterItems = GetFilterItemsByValue(val);
}

if (DisplayCount != null)
Expand All @@ -166,6 +171,15 @@
await TriggerChange(val);
}

private List<string> GetFilterItemsByValue(string val)
{
var comparison = IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
var items = IsLikeMatch
? Items.Where(s => s.Contains(val, comparison))
: Items.Where(s => s.StartsWith(val, comparison));
return [.. items];
}

/// <summary>
/// TriggerChange method
/// </summary>
Expand Down