Made the search sticky

This commit is contained in:
Thorsten Sommer 2026-06-04 19:21:38 +02:00
parent 4bf895062e
commit 0ecac914f2
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 15 additions and 7 deletions

View File

@ -11,9 +11,9 @@
} }
else else
{ {
@if (this.isSearchVisible) @if (this.SearchVisible)
{ {
<MudStack Class="mx-3 mt-2 mb-1" Spacing="1"> <MudStack Class="mx-3 mt-2 mb-1" Spacing="1" Style="position: sticky; top: 0; z-index: 2; background-color: var(--mud-palette-background);">
<MudStack Row="@true" AlignItems="AlignItems.Center" Wrap="Wrap.NoWrap" Spacing="1"> <MudStack Row="@true" AlignItems="AlignItems.Center" Wrap="Wrap.NoWrap" Spacing="1">
<MudTextField T="string" <MudTextField T="string"
Text="@this.searchText" Text="@this.searchText"

View File

@ -32,6 +32,12 @@ public partial class Workspaces : MSGComponentBase
[Parameter] [Parameter]
public bool ExpandRootNodes { get; set; } = true; public bool ExpandRootNodes { get; set; } = true;
[Parameter]
public bool SearchVisible { get; set; }
[Parameter]
public EventCallback<bool> SearchVisibleChanged { get; set; }
private const Placement WORKSPACE_ITEM_TOOLTIP_PLACEMENT = Placement.Bottom; private const Placement WORKSPACE_ITEM_TOOLTIP_PLACEMENT = Placement.Bottom;
private readonly SemaphoreSlim treeLoadingSemaphore = new(1, 1); private readonly SemaphoreSlim treeLoadingSemaphore = new(1, 1);
private readonly List<TreeItemData<ITreeItem>> treeItems = []; private readonly List<TreeItemData<ITreeItem>> treeItems = [];
@ -41,7 +47,6 @@ public partial class Workspaces : MSGComponentBase
private CancellationTokenSource? searchCancellationTokenSource; private CancellationTokenSource? searchCancellationTokenSource;
private bool isInitialLoading = true; private bool isInitialLoading = true;
private bool isDisposed; private bool isDisposed;
private bool isSearchVisible;
private bool includeThreadContents; private bool includeThreadContents;
private bool isSearchRunning; private bool isSearchRunning;
private string searchText = string.Empty; private string searchText = string.Empty;
@ -92,7 +97,7 @@ public partial class Workspaces : MSGComponentBase
await this.StartPrefetchAsync(); await this.StartPrefetchAsync();
} }
private bool HasSearchQuery => this.isSearchVisible && !string.IsNullOrWhiteSpace(this.searchText); private bool HasSearchQuery => this.SearchVisible && !string.IsNullOrWhiteSpace(this.searchText);
private void BuildTreeItems(WorkspaceTreeCacheSnapshot snapshot) private void BuildTreeItems(WorkspaceTreeCacheSnapshot snapshot)
{ {
@ -410,8 +415,11 @@ public partial class Workspaces : MSGComponentBase
public async Task ToggleSearchAsync() public async Task ToggleSearchAsync()
{ {
this.isSearchVisible = !this.isSearchVisible; var searchVisible = !this.SearchVisible;
if (this.isSearchVisible) this.SearchVisible = searchVisible;
await this.SearchVisibleChanged.InvokeAsync(searchVisible);
if (this.SearchVisible)
{ {
await this.SafeStateHasChanged(); await this.SafeStateHasChanged();
return; return;