From c45548370958fa70868d4d3dbb5853bde1600cd7 Mon Sep 17 00:00:00 2001 From: mckaragoz <78308169+mckaragoz@users.noreply.github.com> Date: Wed, 23 Apr 2025 03:07:08 +0300 Subject: [PATCH] MudSelect Fix Crash While Search --- .../ListExtended/MudListExtended.razor.cs | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs index bde0fb18..c75400f9 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs @@ -926,10 +926,10 @@ protected internal async Task SearchBoxHandleKeyDownAsync(KeyboardEventArgs obj) await _searchField.SelectAsync(); } break; - case "ArrowUp": - case "ArrowDown": - await HandleKeyDownAsync(obj); - break; + //case "ArrowUp": + //case "ArrowDown": + // await HandleKeyDownAsync(obj); + // break; case "Enter": case "NumpadEnter": await HandleKeyDownAsync(obj); @@ -1451,7 +1451,7 @@ public async Task ActiveFirstItem(string? startChar = null) { items[0].SetActive(true); _lastActivatedItem = items[0]; - if (items[0].ParentListItem != null && !items[0].ParentListItem.Expanded) + if (items[0].ParentListItem != null && items[0].ParentListItem?.Expanded == false) { items[0].ParentListItem.Expanded = true; } @@ -1463,16 +1463,18 @@ public async Task ActiveFirstItem(string? startChar = null) var possibleItems = items.Where(x => (x.Text ?? Converter.Set(x.Value) ?? "").StartsWith(startChar, StringComparison.CurrentCultureIgnoreCase)).ToList(); if (possibleItems == null || !possibleItems.Any()) { - if (_lastActivatedItem == null) - { - return; - } - _lastActivatedItem.SetActive(true); - if (_lastActivatedItem.ParentListItem != null && !_lastActivatedItem.ParentListItem.Expanded) - { - _lastActivatedItem.ParentListItem.Expanded = true; - } - await ScrollToMiddleAsync(_lastActivatedItem); + DeactiveAllItems(items); + _lastActivatedItem = null; + //if (_lastActivatedItem == null) + //{ + // return; + //} + //_lastActivatedItem.SetActive(true); + //if (_lastActivatedItem.ParentListItem != null && !_lastActivatedItem.ParentListItem.Expanded) + //{ + // _lastActivatedItem.ParentListItem.Expanded = true; + //} + //await ScrollToMiddleAsync(_lastActivatedItem); return; }