Skip to content

Commit

Permalink
[PM-8214] adding tabIndex for screen reader (#12602)
Browse files Browse the repository at this point in the history
* update new device components to use liveannouncer so users are notified of the pages header, and add tabindex to remind me later btn
  • Loading branch information
Jingo88 authored Dec 31, 2024
1 parent e1778f4 commit 75f75dc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LiveAnnouncer } from "@angular/cdk/a11y";
import { CommonModule } from "@angular/common";
import { Component, OnInit } from "@angular/core";
import { AfterViewInit, Component, OnInit } from "@angular/core";
import { FormBuilder, FormControl, ReactiveFormsModule } from "@angular/forms";
import { Router } from "@angular/router";
import { firstValueFrom, Observable } from "rxjs";
Expand All @@ -9,6 +10,7 @@ import { Account, AccountService } from "@bitwarden/common/auth/abstractions/acc
import { ClientType } from "@bitwarden/common/enums";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { UserId } from "@bitwarden/common/types/guid";
import {
Expand Down Expand Up @@ -41,7 +43,7 @@ import {
ReactiveFormsModule,
],
})
export class NewDeviceVerificationNoticePageOneComponent implements OnInit {
export class NewDeviceVerificationNoticePageOneComponent implements OnInit, AfterViewInit {
protected formGroup = this.formBuilder.group({
hasEmailAccess: new FormControl(0),
});
Expand All @@ -57,6 +59,8 @@ export class NewDeviceVerificationNoticePageOneComponent implements OnInit {
private newDeviceVerificationNoticeService: NewDeviceVerificationNoticeService,
private platformUtilsService: PlatformUtilsService,
private configService: ConfigService,
private liveAnnouncer: LiveAnnouncer,
private i18nService: I18nService,
) {
this.isDesktop = this.platformUtilsService.getClientType() === ClientType.Desktop;
}
Expand All @@ -70,6 +74,10 @@ export class NewDeviceVerificationNoticePageOneComponent implements OnInit {
this.currentUserId = currentAcct.id;
}

ngAfterViewInit() {
void this.liveAnnouncer.announce(this.i18nService.t("importantNotice"), "polite");
}

submit = async () => {
const doesNotHaveEmailAccess = this.formGroup.controls.hasEmailAccess.value === 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@
</a>

<div class="tw-flex tw-justify-center tw-mt-6" *ngIf="!permanentFlagEnabled">
<a bitLink linkType="primary" (click)="remindMeLaterSelect()" data-testid="remind-me-later">
<a
bitLink
linkType="primary"
(click)="remindMeLaterSelect()"
data-testid="remind-me-later"
href="#"
appStopClick
>
{{ "remindMeLater" | i18n }}
</a>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LiveAnnouncer } from "@angular/cdk/a11y";
import { CommonModule } from "@angular/common";
import { Component, OnInit } from "@angular/core";
import { AfterViewInit, Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { firstValueFrom, Observable } from "rxjs";

Expand All @@ -12,6 +13,7 @@ import {
Environment,
EnvironmentService,
} from "@bitwarden/common/platform/abstractions/environment.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { UserId } from "@bitwarden/common/types/guid";
import { ButtonModule, LinkModule, TypographyModule } from "@bitwarden/components";
Expand All @@ -24,7 +26,7 @@ import { NewDeviceVerificationNoticeService } from "../../services/new-device-ve
templateUrl: "./new-device-verification-notice-page-two.component.html",
imports: [CommonModule, JslibModule, TypographyModule, ButtonModule, LinkModule],
})
export class NewDeviceVerificationNoticePageTwoComponent implements OnInit {
export class NewDeviceVerificationNoticePageTwoComponent implements OnInit, AfterViewInit {
protected isWeb: boolean;
protected isDesktop: boolean;
protected permanentFlagEnabled = false;
Expand All @@ -39,6 +41,8 @@ export class NewDeviceVerificationNoticePageTwoComponent implements OnInit {
private platformUtilsService: PlatformUtilsService,
private environmentService: EnvironmentService,
private configService: ConfigService,
private liveAnnouncer: LiveAnnouncer,
private i18nService: I18nService,
) {
this.isWeb = this.platformUtilsService.getClientType() === ClientType.Web;
this.isDesktop = this.platformUtilsService.getClientType() === ClientType.Desktop;
Expand All @@ -56,6 +60,10 @@ export class NewDeviceVerificationNoticePageTwoComponent implements OnInit {
this.currentUserId = currentAcct.id;
}

ngAfterViewInit() {
void this.liveAnnouncer.announce(this.i18nService.t("setupTwoStepLogin"), "polite");
}

async navigateToTwoStepLogin(event: Event) {
event.preventDefault();

Expand Down

0 comments on commit 75f75dc

Please sign in to comment.