Skip to content

Commit

Permalink
Kamu UI 436 minor ux mouse less experience in login with password form (
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-borzenko authored Sep 24, 2024
1 parent 428b4ae commit 349ad50
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- Added `Share query` button to the Data tab

### Fixed
- Added autofocus to the login field on the login page

## [0.26.4] - 2024-09-13
### Added
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { AccountComponent } from "./account/account.component";
import { DatasetsTabComponent } from "./account/additional-components/datasets-tab/datasets-tab.component";
import { AccessTokensTabComponent } from "./auth/settings/tabs/access-tokens-tab/access-tokens-tab.component";
import { MatSlideToggleModule } from "@angular/material/slide-toggle";
import { AutofocusDirective } from "./common/directives/autofocus.directive";

const Services = [
{
Expand Down Expand Up @@ -204,6 +205,7 @@ const MatModules = [
AdminDashboardComponent,
AccessTokensTabComponent,
AccountFlowsTabComponent,
AutofocusDirective,
],
imports: [
AppRoutingModule,
Expand Down
7 changes: 3 additions & 4 deletions src/app/auth/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ <h1 class="text-center text-muted mt-4">Login to Kamu</h1>
class="form-control d-inline"
id="login"
data-test-id="input-login"
required
(keyup)="resetPasswordLoginError()"
(keyup)="onChangeInputField($event)"
appAutofocus
[class.error-border-color]="passwordLoginError$ | async"
/>
<div *ngIf="loginControl?.invalid && (loginControl?.touched || loginControl?.dirty)">
Expand All @@ -65,8 +65,7 @@ <h1 class="text-center text-muted mt-4">Login to Kamu</h1>
class="form-control d-inline"
id="password"
data-test-id="input-password"
required
(keyup)="resetPasswordLoginError()"
(keyup)="onChangeInputField($event)"
[class.error-border-color]="passwordLoginError$ | async"
/>
<div *ngIf="passwordControl?.invalid && (passwordControl?.touched || passwordControl?.dirty)">
Expand Down
6 changes: 6 additions & 0 deletions src/app/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ export class LoginComponent extends BaseComponent implements OnInit {
public resetPasswordLoginError(): void {
this.loginService.resetPasswordLoginError();
}

public onChangeInputField(event: KeyboardEvent): void {
if (event.key !== "Enter") {
this.resetPasswordLoginError();
}
}
}
14 changes: 14 additions & 0 deletions src/app/common/directives/autofocus.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { AfterViewInit, Directive, ElementRef, inject } from "@angular/core";

@Directive({
selector: "[appAutofocus]",
})
export class AutofocusDirective implements AfterViewInit {
private elementRef = inject(ElementRef);

ngAfterViewInit(): void {
setTimeout(() => {
(this.elementRef.nativeElement as HTMLElement).focus();
});
}
}

0 comments on commit 349ad50

Please sign in to comment.