Focus quick parse input on entry

This commit is contained in:
2026-03-21 11:03:31 +01:00
parent 62710f269d
commit fbbeebf056
2 changed files with 25 additions and 7 deletions

View File

@@ -191,19 +191,24 @@
private IJSObjectReference? jsModule; private IJSObjectReference? jsModule;
private bool isBackdropPointerDown; private bool isBackdropPointerDown;
private CriticalCellQuickParseEditor? quickParseEditor; private CriticalCellQuickParseEditor? quickParseEditor;
private bool shouldFocusQuickParseEditor;
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (!firstRender) if (firstRender)
{ {
return; jsModule = await JSRuntime.InvokeAsync<IJSObjectReference>(
"import",
"./Components/Shared/CriticalCellEditorDialog.razor.js");
await jsModule.InvokeVoidAsync("lockBackgroundScroll");
} }
jsModule = await JSRuntime.InvokeAsync<IJSObjectReference>( if (shouldFocusQuickParseEditor && quickParseEditor is not null)
"import", {
"./Components/Shared/CriticalCellEditorDialog.razor.js"); shouldFocusQuickParseEditor = false;
await quickParseEditor.FocusAsync();
await jsModule.InvokeVoidAsync("lockBackgroundScroll"); }
} }
public async ValueTask DisposeAsync() public async ValueTask DisposeAsync()
@@ -299,4 +304,12 @@
IsQuickParseMode && !string.IsNullOrWhiteSpace(QuickParseErrorMessage) IsQuickParseMode && !string.IsNullOrWhiteSpace(QuickParseErrorMessage)
? QuickParseErrorMessage ? QuickParseErrorMessage
: ErrorMessage; : ErrorMessage;
protected override void OnParametersSet()
{
if (IsQuickParseMode && quickParseEditor is null)
{
shouldFocusQuickParseEditor = true;
}
}
} }

View File

@@ -1,6 +1,7 @@
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
<textarea <textarea
@ref="textArea"
class="@TextAreaCssClass" class="@TextAreaCssClass"
value="@Model.QuickParseInput" value="@Model.QuickParseInput"
@oninput="HandleQuickParseInputChanged" @oninput="HandleQuickParseInputChanged"
@@ -21,6 +22,10 @@
public Task ReparseAsync() => OnReparse.InvokeAsync(); public Task ReparseAsync() => OnReparse.InvokeAsync();
public ValueTask FocusAsync() => textArea.FocusAsync();
private ElementReference textArea;
private void HandleQuickParseInputChanged(ChangeEventArgs args) private void HandleQuickParseInputChanged(ChangeEventArgs args)
{ {
Model.QuickParseInput = args.Value?.ToString() ?? string.Empty; Model.QuickParseInput = args.Value?.ToString() ?? string.Empty;