mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-24 20:52:11 +00:00
Fixed focus on new workspace name field
This commit is contained in:
parent
b64cfdc0be
commit
690183cd2a
@ -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:
|
||||||
|
|||||||
@ -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"
|
||||||
|
|||||||
@ -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]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user