Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Keypress event to catch Enter key on Login page #1198 #1216

Merged
merged 4 commits into from
Apr 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}