[PM-2432] Desktop: Modify switch account dropdown/dialog for accessibility (#5529)
* Tweak account switcher button - if it opens a dialog, it should advertise this with `aria-haspopup="dialog"`, not `aria-haspopup="menu"` - if it opens a dialog, the `aria-expanded` is pointless (as the user will never get back out into the underlying page to check if it's expanded or collapsed, since it's for a dialog not a disclosure widget or menu) * Make two variants for button to sort out `aria-label` on logged-in case * Remove `aria-controls` for button as it's a dialog that opens, not a disclosure, this is irrelevant * Fix `overlayPostition` typo * Simplify approach just use existing single button, but add visually hidden extra "Switch account" to accName * Tweak account switch buttons in dialog/dropdown * Take out the confusing "Logged in as..." a11y text * Use visible button text (with a few extra `sr-only` parts, for readability) as the button's accName * Add the "Switch account" context to each of the buttons to make clear what they do
This commit is contained in:
parent
43edc1a893
commit
22a138a46f
|
@ -6,9 +6,7 @@
|
||||||
cdkOverlayOrigin
|
cdkOverlayOrigin
|
||||||
#trigger="cdkOverlayOrigin"
|
#trigger="cdkOverlayOrigin"
|
||||||
[hidden]="!showSwitcher"
|
[hidden]="!showSwitcher"
|
||||||
aria-haspopup="menu"
|
aria-haspopup="dialog"
|
||||||
aria-controls="cdk-overlay-container"
|
|
||||||
[attr.aria-expanded]="isOpen"
|
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="activeAccount?.email != null; else noActiveAccount">
|
<ng-container *ngIf="activeAccount?.email != null; else noActiveAccount">
|
||||||
<app-avatar
|
<app-avatar
|
||||||
|
@ -22,7 +20,10 @@
|
||||||
*ngIf="activeAccount.email != null"
|
*ngIf="activeAccount.email != null"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></app-avatar>
|
></app-avatar>
|
||||||
<span>{{ activeAccount.email }}</span>
|
<span
|
||||||
|
>{{ activeAccount.email
|
||||||
|
}}<span class="sr-only"> ({{ "switchAccount" | i18n }})</span></span
|
||||||
|
>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-template #noActiveAccount>
|
<ng-template #noActiveAccount>
|
||||||
<span>{{ "switchAccount" | i18n }}</span>
|
<span>{{ "switchAccount" | i18n }}</span>
|
||||||
|
@ -54,13 +55,7 @@
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
>
|
>
|
||||||
<div class="accounts" *ngIf="numberOfAccounts > 0">
|
<div class="accounts" *ngIf="numberOfAccounts > 0">
|
||||||
<button
|
<button *ngFor="let a of accounts | keyvalue" class="account" (click)="switch(a.key)">
|
||||||
*ngFor="let a of accounts | keyvalue"
|
|
||||||
class="account"
|
|
||||||
(click)="switch(a.key)"
|
|
||||||
appA11yTitle="{{ 'loggedInAsOn' | i18n : a.value.profile.email : a.value.serverUrl }}"
|
|
||||||
attr.aria-label="{{ 'switchAccount' | i18n }}"
|
|
||||||
>
|
|
||||||
<app-avatar
|
<app-avatar
|
||||||
[text]="a.value.profile.name ?? a.value.profile.email"
|
[text]="a.value.profile.name ?? a.value.profile.email"
|
||||||
[id]="a.value.profile.userId"
|
[id]="a.value.profile.userId"
|
||||||
|
@ -73,14 +68,20 @@
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></app-avatar>
|
></app-avatar>
|
||||||
<div class="accountInfo">
|
<div class="accountInfo">
|
||||||
<span class="email" aria-hidden="true">{{ a.value.profile.email }}</span>
|
<span class="sr-only">{{ "switchAccount" | i18n }}: </span>
|
||||||
<span class="server" aria-hidden="true" *ngIf="a.value.serverUrl != 'bitwarden.com'">{{
|
<span class="email">{{ a.value.profile.email }}</span>
|
||||||
a.value.serverUrl
|
<span class="server" *ngIf="a.value.serverUrl != 'bitwarden.com'">
|
||||||
}}</span>
|
<span class="sr-only"> / </span>
|
||||||
<span class="status" aria-hidden="true">{{
|
{{ a.value.serverUrl }}
|
||||||
|
</span>
|
||||||
|
<span class="status">
|
||||||
|
<span class="sr-only"> (</span>
|
||||||
|
{{
|
||||||
(a.value.profile.authenticationStatus === authStatus.Unlocked ? "unlocked" : "locked")
|
(a.value.profile.authenticationStatus === authStatus.Unlocked ? "unlocked" : "locked")
|
||||||
| i18n
|
| i18n
|
||||||
}}</span>
|
}}
|
||||||
|
<span class="sr-only">)</span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<i
|
<i
|
||||||
class="bwi bwi-2x text-muted"
|
class="bwi bwi-2x text-muted"
|
||||||
|
|
Loading…
Reference in New Issue