Filter dropdown content (#19)
All checks were successful
Game Ideas build for PR / build_test (pull_request) Successful in 54s

This commit is contained in:
2025-05-18 16:19:05 +02:00
parent fd3d0c347d
commit c7a77d1d9e
4 changed files with 25 additions and 7 deletions

View File

@@ -49,17 +49,15 @@ public partial class AdvancedGameFilter
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel); 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; ExpandedFilter = true;
await ExpandedFilterChanged.InvokeAsync(ExpandedFilter);
BackdropFilter?.Show(); BackdropFilter?.Show();
} }
private async Task HandleBackdropFilterClickedAsync() private void HandleBackdropFilterClickedAsync()
{ {
ExpandedFilter = false; ExpandedFilter = false;
await ExpandedFilterChanged.InvokeAsync(ExpandedFilter);
} }
private void HandleLocationChanged(LocationChangingContext locationContext) private void HandleLocationChanged(LocationChangingContext locationContext)

View File

@@ -34,7 +34,7 @@
min-width: 18px; min-width: 18px;
height: 18px; height: 18px;
width: 18px; width: 18px;
z-index: var(--index-overlay); z-index: 800;
} }
.clear-icon:hover { .clear-icon:hover {

View File

@@ -10,7 +10,7 @@
<div class="@SelectHelper.GetClassFromTheme(Theme)"> <div class="@SelectHelper.GetClassFromTheme(Theme)">
<SearchInput @ref=SearchInput Icon="SearchInputIcon.Dropdown" Placeholder="@Placeholder" <SearchInput @ref=SearchInput Icon="SearchInputIcon.Dropdown" Placeholder="@Placeholder"
TextChanged="HandleClearClicked" ClearClicked="HandleClearClicked" IsDisable=false TextChanged="HandleTextChanged" ClearClicked="HandleClearClicked" IsDisable=false
FocusIn="HandleFocusIn" SearchClicked="HandleFocusIn" /> FocusIn="HandleFocusIn" SearchClicked="HandleFocusIn" />
</div> </div>

View File

@@ -1,3 +1,4 @@
using GameIdeas.BlazorApp.Pages.Games;
using GameIdeas.BlazorApp.Shared.Components.Search; using GameIdeas.BlazorApp.Shared.Components.Search;
using GameIdeas.BlazorApp.Shared.Components.Select; using GameIdeas.BlazorApp.Shared.Components.Select;
using GameIdeas.BlazorApp.Shared.Components.Select.Models; using GameIdeas.BlazorApp.Shared.Components.Select.Models;
@@ -61,4 +62,23 @@ public partial class SelectSearch<TItem>
{ {
Select?.Open(); 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)];
}
}
} }