MOBILE-4065 a11y: Change approach to add aria-label to eye button

main
Pau Ferrer Ocaña 2022-11-11 13:22:22 +01:00
parent f7796700a7
commit 8b87195593
2 changed files with 1 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<ng-content></ng-content> <ng-content></ng-content>
<ion-button fill="clear" [attr.aria-label]="label | translate" core-suppress-events (onClick)="toggle($event)" <ion-button fill="clear" [attr.aria-label]="(shown ? 'core.hide' : 'core.show') | translate" core-suppress-events (onClick)="toggle($event)"
(mousedown)="doNotBlur($event)" (keydown)="doNotBlur($event)" (keyup)="toggle($event)"> (mousedown)="doNotBlur($event)" (keydown)="doNotBlur($event)" (keyup)="toggle($event)">
<ion-icon [name]="shown ? 'fas-eye-slash' : 'fas-eye'" slot="icon-only" aria-hidden="true"></ion-icon> <ion-icon [name]="shown ? 'fas-eye-slash' : 'fas-eye'" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button> </ion-button>

View File

@ -45,7 +45,6 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
@ContentChild(IonInput) ionInput?: IonInput; @ContentChild(IonInput) ionInput?: IonInput;
shown = false; // Whether the password is shown. shown = false; // Whether the password is shown.
label = ''; // Label for the button to show/hide.
protected input?: HTMLInputElement; // Input affected. protected input?: HTMLInputElement; // Input affected.
protected element: HTMLElement; // Current element. protected element: HTMLElement; // Current element.
@ -97,7 +96,6 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
* @param input The input element. * @param input The input element.
*/ */
protected setData(input: HTMLInputElement): void { protected setData(input: HTMLInputElement): void {
this.label = this.shown ? 'core.hide' : 'core.show';
input.type = this.shown ? 'text' : 'password'; input.type = this.shown ? 'text' : 'password';
} }