From d6ce2f49238722639608b3916c2fadd040f20e78 Mon Sep 17 00:00:00 2001 From: ANTONA09 Date: Tue, 26 Mar 2024 20:01:43 +0100 Subject: [PATCH] fix: primefaces #6234, TreeSelect: (accessiblility) cannot access and clear the selected input using using keyboard --- components/lib/treeselect/TreeSelect.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/lib/treeselect/TreeSelect.js b/components/lib/treeselect/TreeSelect.js index 6cf20b4d8f..3fd54d7e59 100644 --- a/components/lib/treeselect/TreeSelect.js +++ b/components/lib/treeselect/TreeSelect.js @@ -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(); @@ -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') );