Focus quick parse input on entry
This commit is contained in:
@@ -191,14 +191,12 @@
|
|||||||
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>(
|
jsModule = await JSRuntime.InvokeAsync<IJSObjectReference>(
|
||||||
"import",
|
"import",
|
||||||
"./Components/Shared/CriticalCellEditorDialog.razor.js");
|
"./Components/Shared/CriticalCellEditorDialog.razor.js");
|
||||||
@@ -206,6 +204,13 @@
|
|||||||
await jsModule.InvokeVoidAsync("lockBackgroundScroll");
|
await jsModule.InvokeVoidAsync("lockBackgroundScroll");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldFocusQuickParseEditor && quickParseEditor is not null)
|
||||||
|
{
|
||||||
|
shouldFocusQuickParseEditor = false;
|
||||||
|
await quickParseEditor.FocusAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async ValueTask DisposeAsync()
|
public async ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
if (jsModule is null)
|
if (jsModule is null)
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user