Focus quick parse input on entry
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user