[frontend/components] Add Escape and Enter keybinds to NoticeDialog
This commit is contained in:
parent
df5dcab581
commit
04425aab9d
1 changed files with 9 additions and 1 deletions
|
@ -6,7 +6,7 @@
|
||||||
@inject IJSRuntime Js;
|
@inject IJSRuntime Js;
|
||||||
@inject IStringLocalizer<Localization> Loc;
|
@inject IStringLocalizer<Localization> Loc;
|
||||||
|
|
||||||
<dialog class="dialog" @ref="Dialog">
|
<dialog @onkeydown="HandleKeyDown" class="dialog" @ref="Dialog">
|
||||||
<div class="notice">
|
<div class="notice">
|
||||||
<span class="notice-icon">
|
<span class="notice-icon">
|
||||||
@switch (Type)
|
@switch (Type)
|
||||||
|
@ -57,6 +57,14 @@
|
||||||
await _module.InvokeVoidAsync("openDialog", Dialog);
|
await _module.InvokeVoidAsync("openDialog", Dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task HandleKeyDown(KeyboardEventArgs e)
|
||||||
|
{
|
||||||
|
if (e is { Code: "Enter" or "Escape" })
|
||||||
|
{
|
||||||
|
await CloseDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
_module = await Js.InvokeAsync<IJSObjectReference>("import",
|
_module = await Js.InvokeAsync<IJSObjectReference>("import",
|
||||||
|
|
Loading…
Add table
Reference in a new issue