Skip to content

Commit

Permalink
Merge pull request #1216 from leigh-pointer/dev.fork
Browse files Browse the repository at this point in the history
Added Keypress event to catch Enter key on Login page #1198
  • Loading branch information
sbwalker authored Apr 2, 2021
2 parents 6d44384 + 60a1f4e commit 9995066
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Oqtane.Client/Modules/Admin/Login/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
}
<AuthorizeView>
<NotAuthorized>
<div class="container Oqtane-Modules-Admin-Login">
<div class="container Oqtane-Modules-Admin-Login" @onkeypress="@(e => KeyPressed(e))">
<div class="form-group">
<label for="Username" class="control-label">@Localizer["Username:"] </label>
<input type="text" name="Username" class="form-control username" placeholder="Username" @bind="@_username" id="Username" />
<input type="text" @ref="username" name="Username" class="form-control username" placeholder="Username" @bind="@_username" id="Username" />
</div>
<div class="form-group">
<label for="Password" class="control-label">@Localizer["Password:"] </label>
Expand All @@ -41,6 +41,7 @@
private string _username = string.Empty;
private string _password = string.Empty;
private bool _remember = false;
private ElementReference username;

public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;

Expand Down Expand Up @@ -80,6 +81,14 @@
}
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await username.FocusAsync();
}
}

private async Task Login()
{
if (PageState.Runtime == Oqtane.Shared.Runtime.Server)
Expand Down Expand Up @@ -157,4 +166,12 @@

StateHasChanged();
}

private async Task KeyPressed(KeyboardEventArgs e)
{
if (e.Code == "Enter" || e.Code == "NumpadEnter")
{
await Login();
}
}
}

0 comments on commit 9995066

Please sign in to comment.