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

View File

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