Skip to content

Commit

Permalink
fix: primefaces #6234, TreeSelect: (accessiblility) cannot access and…
Browse files Browse the repository at this point in the history
… clear the selected input using using keyboard
  • Loading branch information
ANTONA09 authored and ANTONA09 committed Mar 26, 2024
1 parent 709d5c4 commit d6ce2f4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/lib/treeselect/TreeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ export const TreeSelect = React.memo(
}
};

const onClearIconKeyDown = (event) => {
if (event.key === 'Enter' || event.code === 'Space') {
clear(event);
event.preventDefault();
}
};

const onNodeSelect = (node) => {
props.onNodeSelect && props.onNodeSelect(node);
isSingleSelectionMode && hide();
Expand Down Expand Up @@ -621,7 +628,10 @@ export const TreeSelect = React.memo(
const clearIconProps = mergeProps(
{
className: cx('clearIcon'),
onPointerUp: clear
onPointerUp: clear,
tabIndex: props.tabIndex || '0',
onKeyDown: onClearIconKeyDown,
'aria-label': 'Clear Selection'
},
ptm('clearIcon')
);
Expand Down

0 comments on commit d6ce2f4

Please sign in to comment.