Fixed focus on new workspace name field

This commit is contained in:
Thorsten Sommer 2026-06-06 09:59:51 +02:00
parent b64cfdc0be
commit 690183cd2a
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 17 additions and 1 deletions

View File

@ -56,7 +56,7 @@ public partial class Workspaces : MSGComponentBase
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
await base.OnInitializedAsync(); await base.OnInitializedAsync();
this.ApplyFilters([], [ Event.AI_JOB_CHANGED, Event.AI_JOB_FINISHED, Event.CHAT_GENERATION_CHANGED ]); this.ApplyFilters([], [ Event.AI_JOB_CHANGED, Event.AI_JOB_FINISHED, Event.CHAT_GENERATION_CHANGED, Event.WORKSPACE_CREATED ]);
_ = this.LoadTreeItemsAsync(startPrefetch: true); _ = this.LoadTreeItemsAsync(startPrefetch: true);
} }
@ -887,6 +887,10 @@ public partial class Workspaces : MSGComponentBase
await this.ForceRefreshFromDiskAsync(); await this.ForceRefreshFromDiskAsync();
break; break;
case Event.WORKSPACE_CREATED:
await this.LoadTreeItemsAsync(startPrefetch: false);
break;
case Event.AI_JOB_CHANGED: case Event.AI_JOB_CHANGED:
case Event.AI_JOB_FINISHED: case Event.AI_JOB_FINISHED:
case Event.CHAT_GENERATION_CHANGED: case Event.CHAT_GENERATION_CHANGED:

View File

@ -19,11 +19,13 @@
{ {
<MudForm @ref="this.createWorkspaceForm"> <MudForm @ref="this.createWorkspaceForm">
<MudTextField T="string" <MudTextField T="string"
@ref="@this.newWorkspaceNameField"
@bind-Text="@this.newWorkspaceName" @bind-Text="@this.newWorkspaceName"
Variant="Variant.Outlined" Variant="Variant.Outlined"
AutoGrow="@false" AutoGrow="@false"
Lines="1" Lines="1"
Label="@T("Workspace name")" Label="@T("Workspace name")"
AutoFocus="@true"
Immediate="@true" Immediate="@true"
Disabled="@this.isCreatingWorkspace" Disabled="@this.isCreatingWorkspace"
OnKeyDown="@this.HandleNewWorkspaceNameKeyDown" OnKeyDown="@this.HandleNewWorkspaceNameKeyDown"

View File

@ -27,11 +27,13 @@ public partial class WorkspaceSelectionDialog : MSGComponentBase
private readonly List<WorkspaceSelectionItem> workspaces = []; private readonly List<WorkspaceSelectionItem> workspaces = [];
private readonly string escapeHandlerId = $"workspace-selection-dialog-{Guid.NewGuid():N}"; private readonly string escapeHandlerId = $"workspace-selection-dialog-{Guid.NewGuid():N}";
private MudForm? createWorkspaceForm; private MudForm? createWorkspaceForm;
private MudTextField<string>? newWorkspaceNameField;
private DotNetObjectReference<WorkspaceSelectionDialog>? dotNetReference; private DotNetObjectReference<WorkspaceSelectionDialog>? dotNetReference;
private Guid selectedWorkspace; private Guid selectedWorkspace;
private string newWorkspaceName = string.Empty; private string newWorkspaceName = string.Empty;
private bool isCreatingWorkspace; private bool isCreatingWorkspace;
private bool showCreateWorkspaceForm; private bool showCreateWorkspaceForm;
private bool shouldFocusNewWorkspaceName;
private string? createWorkspaceError; private string? createWorkspaceError;
private string? createWorkspaceErrorName; private string? createWorkspaceErrorName;
@ -57,6 +59,12 @@ public partial class WorkspaceSelectionDialog : MSGComponentBase
await this.JsRuntime.InvokeVoidAsync("registerEscapeHandler", this.escapeHandlerId, this.dotNetReference); await this.JsRuntime.InvokeVoidAsync("registerEscapeHandler", this.escapeHandlerId, this.dotNetReference);
} }
if (this.shouldFocusNewWorkspaceName && this.newWorkspaceNameField is not null)
{
this.shouldFocusNewWorkspaceName = false;
await this.newWorkspaceNameField.FocusAsync();
}
await base.OnAfterRenderAsync(firstRender); await base.OnAfterRenderAsync(firstRender);
} }
@ -102,6 +110,7 @@ public partial class WorkspaceSelectionDialog : MSGComponentBase
this.createWorkspaceErrorName = null; this.createWorkspaceErrorName = null;
this.newWorkspaceName = string.Empty; this.newWorkspaceName = string.Empty;
this.showCreateWorkspaceForm = true; this.showCreateWorkspaceForm = true;
this.shouldFocusNewWorkspaceName = true;
} }
private async Task CreateWorkspaceAsync() private async Task CreateWorkspaceAsync()
@ -153,6 +162,7 @@ public partial class WorkspaceSelectionDialog : MSGComponentBase
this.newWorkspaceName = string.Empty; this.newWorkspaceName = string.Empty;
this.createWorkspaceForm?.ResetValidation(); this.createWorkspaceForm?.ResetValidation();
this.showCreateWorkspaceForm = false; this.showCreateWorkspaceForm = false;
this.shouldFocusNewWorkspaceName = false;
} }
[JSInvokable] [JSInvokable]