Filter dropdown content (#19)
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 54s
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 54s
This commit is contained in:
@@ -49,17 +49,15 @@ public partial class AdvancedGameFilter
|
||||
|
||||
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
|
||||
}
|
||||
private async Task HandleExpandFilterAsync(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
|
||||
private void HandleExpandFilterAsync(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
|
||||
{
|
||||
ExpandedFilter = true;
|
||||
await ExpandedFilterChanged.InvokeAsync(ExpandedFilter);
|
||||
BackdropFilter?.Show();
|
||||
}
|
||||
|
||||
private async Task HandleBackdropFilterClickedAsync()
|
||||
private void HandleBackdropFilterClickedAsync()
|
||||
{
|
||||
ExpandedFilter = false;
|
||||
await ExpandedFilterChanged.InvokeAsync(ExpandedFilter);
|
||||
}
|
||||
|
||||
private void HandleLocationChanged(LocationChangingContext locationContext)
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
z-index: var(--index-overlay);
|
||||
z-index: 800;
|
||||
}
|
||||
|
||||
.clear-icon:hover {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<div class="@SelectHelper.GetClassFromTheme(Theme)">
|
||||
<SearchInput @ref=SearchInput Icon="SearchInputIcon.Dropdown" Placeholder="@Placeholder"
|
||||
TextChanged="HandleClearClicked" ClearClicked="HandleClearClicked" IsDisable=false
|
||||
TextChanged="HandleTextChanged" ClearClicked="HandleClearClicked" IsDisable=false
|
||||
FocusIn="HandleFocusIn" SearchClicked="HandleFocusIn" />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using GameIdeas.BlazorApp.Pages.Games;
|
||||
using GameIdeas.BlazorApp.Shared.Components.Search;
|
||||
using GameIdeas.BlazorApp.Shared.Components.Select;
|
||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||
@@ -61,4 +62,23 @@ public partial class SelectSearch<TItem>
|
||||
{
|
||||
Select?.Open();
|
||||
}
|
||||
private void HandleTextChanged(string args)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(args))
|
||||
{
|
||||
var keywords = args
|
||||
.Split([' '], StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(k => k.Trim())
|
||||
.ToArray() ?? [];
|
||||
|
||||
SelectParams.Items = [.. Items
|
||||
.Where(game => keywords.All(
|
||||
kw => SelectParams.GetItemLabel(game).Contains(kw, StringComparison.OrdinalIgnoreCase)
|
||||
))
|
||||
.OrderBy(game => keywords.Min(kw =>
|
||||
SelectParams.GetItemLabel(game).IndexOf(kw, StringComparison.OrdinalIgnoreCase)
|
||||
))
|
||||
.ThenBy(game => SelectParams.GetItemLabel(game).Length)];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user