From 0dc360e1125d477e852619edbce6ed343c42e63c Mon Sep 17 00:00:00 2001 From: Akshay Antony Date: Wed, 28 Feb 2024 19:55:16 +0530 Subject: [PATCH] fix: primefaces #6046, Password: (accessiblility) cannot access toggle button using keyboard --- components/lib/password/Password.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/lib/password/Password.js b/components/lib/password/Password.js index 5ee43644e5..69b79c2c3f 100644 --- a/components/lib/password/Password.js +++ b/components/lib/password/Password.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api'; +import PrimeReact, { PrimeReactContext, localeOption, ariaLabel } from '../api/Api'; import { useHandleStyle } from '../componentbase/ComponentBase'; import { CSSTransition } from '../csstransition/CSSTransition'; import { ESC_KEY_HANDLING_PRIORITIES, useDisplayOrder, useGlobalOnEscapeKey, useMergeProps, useMountEffect, useOverlayListener, useUnmountEffect } from '../hooks/Hooks'; @@ -272,7 +272,7 @@ export const Password = React.memo( ZIndexUtils.clear(overlayRef.current); }); - const onToggleMaskKeyDown= (e) => { + const onToggleMaskKeyDown = (e) => { return e.key === 'Enter' ? toggleMask() : ''; }; @@ -286,7 +286,8 @@ export const Password = React.memo( tabIndex: props.tabIndex || '0', className: cx('hideIcon'), onClick: toggleMask, - onKeyDown: onToggleMaskKeyDown + onKeyDown: onToggleMaskKeyDown, + 'aria-label': ariaLabel('toggleMaskLabel') || 'Toggle Password Mask' }, ptm('hideIcon') ); @@ -298,7 +299,8 @@ export const Password = React.memo( tabIndex: props.tabIndex || '0', className: cx('showIcon'), onClick: toggleMask, - onKeyDown: onToggleMaskKeyDown + onKeyDown: onToggleMaskKeyDown, + 'aria-label': ariaLabel('toggleMaskLabel') || 'Toggle Password Mask' }, ptm('showIcon') );