diff --git a/components/lib/password/Password.js b/components/lib/password/Password.js index 5c6d3d4e1b..854a26f20f 100644 --- a/components/lib/password/Password.js +++ b/components/lib/password/Password.js @@ -275,13 +275,32 @@ export const Password = React.memo( const createIcon = () => { let icon; - const hideIconProps = mergeProps(ptm('hideIcon')); - const showIconProps = mergeProps(ptm('showIcon')); + const hideIconProps = mergeProps( + { + key: 'hideIcon', + role: 'button', + tabIndex: props.tabIndex, + className: cx('hideIcon'), + onClick: toggleMask + }, + ptm('hideIcon') + ); + + const showIconProps = mergeProps( + { + key: 'showIcon', + role: 'button', + tabIndex: props.tabIndex, + className: cx('showIcon'), + onClick: toggleMask + }, + ptm('showIcon') + ); if (unmaskedState) { - icon = props.hideIcon || ; + icon = props.hideIcon || ; } else { - icon = props.showIcon || ; + icon = props.showIcon || ; } const eyeIcon = IconUtils.getJSXIcon(icon, unmaskedState ? { ...hideIconProps } : { ...showIconProps }, { props }); diff --git a/components/lib/password/PasswordBase.js b/components/lib/password/PasswordBase.js index 4386ad76e9..e6772a15ee 100644 --- a/components/lib/password/PasswordBase.js +++ b/components/lib/password/PasswordBase.js @@ -22,6 +22,8 @@ const classes = { meter: 'p-password-meter', meterLabel: ({ strength }) => classNames('p-password-strength', strength), info: ({ strength }) => classNames('p-password-info', strength), + showIcon: 'p-password-show-icon', + hideIcon: 'p-password-hide-icon', transition: 'p-connected-overlay' }; @@ -60,6 +62,12 @@ const styles = ` .p-password-input::-ms-clear { display: none; } + + .p-password .p-password-show-icon, + .p-password .p-password-hide-icon { + line-height: 1.5; + cursor: pointer; + } } `;