feat: support clearing the searching text
All checks were successful
Caddy Manager CI build / docker (push) Successful in 1m15s

This commit is contained in:
2025-07-05 15:40:37 +07:00
parent f3eae5e649
commit 520ccd8a49
2 changed files with 16 additions and 1 deletions

View File

@@ -21,7 +21,8 @@
<MudSpacer /> <MudSpacer />
<MudTextField T="string" Placeholder="Search..." Adornment="Adornment.End" DebounceInterval="500" <MudTextField T="string" Placeholder="Search..." Adornment="Adornment.End" DebounceInterval="500"
OnDebounceIntervalElapsed="HandleIntervalElapsed" @bind-Value="_debouncedText" OnDebounceIntervalElapsed="HandleIntervalElapsed" @bind-Value="_debouncedText"
AdornmentIcon="@Icons.Material.Filled.Search"/> AdornmentIcon="@(string.IsNullOrWhiteSpace(_debouncedText) ? Icons.Material.Filled.Search : Icons.Material.Filled.Close)"
OnAdornmentClick="HandleSearchBarAdornmentClick" />
</MudContainer> </MudContainer>
<MudList T="string" Style="padding-top: 16px;" SelectionMode="SelectionMode.MultiSelection" <MudList T="string" Style="padding-top: 16px;" SelectionMode="SelectionMode.MultiSelection"
@bind-SelectedValues="_selectedCaddyConfigurations"> @bind-SelectedValues="_selectedCaddyConfigurations">

View File

@@ -144,4 +144,18 @@ public partial class CaddyReverseProxiesPage : ComponentBase
// Simply refresh the page with the new debounced text // Simply refresh the page with the new debounced text
Refresh(); Refresh();
} }
/// <summary>
/// Handle the click event for the search bar adornment. If the debounced text is empty, then simply refresh
/// to have the search be effective, otherwise, clear the debounced text to reset the search.
/// </summary>
private void HandleSearchBarAdornmentClick()
{
if (!string.IsNullOrWhiteSpace(_debouncedText))
{
_debouncedText = string.Empty;
}
Refresh();
}
} }