Skip to content

Commit fad62f9

Browse files
committed
refactor: 精简代码
1 parent f4deacc commit fad62f9

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

src/BootstrapBlazor/Components/Select/Select.razor.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,6 @@ private async ValueTask<ItemsProviderResult<SelectedItem>> LoadItems(ItemsProvid
387387
int GetCountByTotal() => TotalCount == 0 ? request.Count : Math.Min(request.Count, TotalCount - request.StartIndex);
388388
}
389389

390-
private async Task SearchTextChanged(string val)
391-
{
392-
_itemsCache = null;
393-
SearchText = val;
394-
await RefreshVirtualizeElement();
395-
}
396-
397390
private async Task RefreshVirtualizeElement()
398391
{
399392
if (IsVirtualize && OnQueryAsync != null)
@@ -463,7 +456,9 @@ public async Task ConfirmSelectedItem(int index)
463456
[JSInvokable]
464457
public async Task TriggerOnSearch(string searchText)
465458
{
466-
await SearchTextChanged(searchText);
459+
_itemsCache = null;
460+
SearchText = searchText;
461+
await RefreshVirtualizeElement();
467462
StateHasChanged();
468463
}
469464

src/BootstrapBlazor/Components/SelectGeneric/SelectGeneric.razor.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,6 @@ private async ValueTask<ItemsProviderResult<SelectedItem<TValue>>> LoadItems(Ite
375375
int GetCountByTotal() => TotalCount == 0 ? request.Count : Math.Min(request.Count, TotalCount - request.StartIndex);
376376
}
377377

378-
private async Task SearchTextChanged(string val)
379-
{
380-
SearchText = val;
381-
_itemsCache = null;
382-
await RefreshVirtualizeElement();
383-
}
384-
385378
private async Task RefreshVirtualizeElement()
386379
{
387380
if (IsVirtualize && OnQueryAsync != null)
@@ -420,7 +413,9 @@ public async Task ConfirmSelectedItem(int index)
420413
[JSInvokable]
421414
public async Task TriggerOnSearch(string searchText)
422415
{
423-
await SearchTextChanged(searchText);
416+
_itemsCache = null;
417+
SearchText = searchText;
418+
await RefreshVirtualizeElement();
424419
StateHasChanged();
425420
}
426421

0 commit comments

Comments
 (0)