From ea7e89127e94efcc05982c79e69409744a7b0361 Mon Sep 17 00:00:00 2001 From: kurilova Date: Thu, 19 Sep 2024 13:08:44 +0000 Subject: [PATCH] Adds aria label; code refactoring --- .../profile-item/profile-item.component.html | 1 + .../profile-item/profile-item.component.ts | 11 ++++++--- .../risk-assessment.component.ts | 23 ++++++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/modules/ui/src/app/pages/risk-assessment/profile-item/profile-item.component.html b/modules/ui/src/app/pages/risk-assessment/profile-item/profile-item.component.html index 31049cd93..0e9f3fa5e 100644 --- a/modules/ui/src/app/pages/risk-assessment/profile-item/profile-item.component.html +++ b/modules/ui/src/app/pages/risk-assessment/profile-item/profile-item.component.html @@ -28,6 +28,7 @@ ? EXPIRED_TOOLTIP : profile.status }}" + [attr.aria-label]="getProfileItemLabel(profile)" (click)="profileClicked.emit(profile)" (keydown.enter)="enterProfileItem(profile)"> { if (saveProfile) { - this.saveProfile(profile); - this.store.setFocusOnSelectedProfile(); + this.saveProfile(profile, this.store.setFocusOnSelectedProfile); } }); } @@ -158,12 +156,14 @@ export class RiskAssessmentComponent implements OnInit, OnDestroy { } } - private saveProfile(profile: Profile) { + private saveProfile(profile: Profile, focusElement: () => void) { this.store.saveProfile({ profile, onSave: (profile: Profile) => { if (profile.status === ProfileStatus.VALID) { - this.openSuccessDialog(profile); + this.openSuccessDialog(profile, focusElement); + } else { + focusElement(); } }, }); @@ -200,8 +200,8 @@ export class RiskAssessmentComponent implements OnInit, OnDestroy { return dialogRef?.afterClosed(); } - private openSuccessDialog(profile: Profile): void { - this.dialog.open(SuccessDialogComponent, { + private openSuccessDialog(profile: Profile, focusElement: () => void): void { + const dialogRef = this.dialog.open(SuccessDialogComponent, { ariaLabel: 'Risk Assessment Profile Completed', data: { profile, @@ -211,5 +211,12 @@ export class RiskAssessmentComponent implements OnInit, OnDestroy { disableClose: true, panelClass: 'simple-dialog', }); + + dialogRef + ?.afterClosed() + .pipe(takeUntil(this.destroy$)) + .subscribe(() => { + focusElement(); + }); } }