MOBILE-3749 a11y: Implement cancel key on pages

main
Pau Ferrer Ocaña 2021-05-10 14:26:15 +02:00
parent c3d0e39c3e
commit 4e643a363e
2 changed files with 24 additions and 1 deletions

View File

@ -7,7 +7,7 @@
<ion-title>{{ 'core.login.reconnect' | translate }}</ion-title> <ion-title>{{ 'core.login.reconnect' | translate }}</ion-title>
</ion-toolbar> </ion-toolbar>
</ion-header> </ion-header>
<ion-content class="ion-padding"> <ion-content class="ion-padding" (keydown)="keyDown($event)" (keyup)="keyUp($event)">
<div class="ion-text-wrap ion-text-center ion-margin-bottom" [ngClass]="{'item-avatar-center': showSiteAvatar}"> <div class="ion-text-wrap ion-text-center ion-margin-bottom" [ngClass]="{'item-avatar-center': showSiteAvatar}">
<!-- Show user avatar. --> <!-- Show user avatar. -->
<img *ngIf="showSiteAvatar" [src]="userAvatar" class="large-avatar" core-external-content [siteId]="siteId" <img *ngIf="showSiteAvatar" [src]="userAvatar" class="large-avatar" core-external-content [siteId]="siteId"

View File

@ -271,4 +271,27 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
} }
} }
/**
* A11y key functionality that prevents keyDown events.
*
* @param e Event.
*/
keyDown(e: KeyboardEvent): void {
if (e.key == 'Escape') {
e.preventDefault();
e.stopPropagation();
}
}
/**
* Cancel reconnect.
*
* @param e Event.
*/
keyUp(e: KeyboardEvent): void {
if (e.key == 'Escape') {
this.cancel(e);
}
}
} }