Skip to content

Commit

Permalink
fix: primefaces#7349, MultiSelect: Unable to select remove icon of ch…
Browse files Browse the repository at this point in the history
…ips through keyboard
  • Loading branch information
ANTONA09 committed Nov 2, 2024
1 parent ba98e88 commit cb12647
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion components/lib/multiselect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,23 @@ export const MultiSelect = React.memo(
return ObjectUtils.getJSXElement(props.selectedItemTemplate);
}

const onremoveTokenIconKeyDown = (event, val) => {
event.preventDefault();
event.stopPropagation();

switch (event.code) {
case 'Space':
case 'NumpadEnter':
case 'Enter':
if (props.inline) {
break;
}

removeChip(event, val);
break;
}
};

if (props.display === 'chip' && !empty) {
const value = props.value.slice(0, props.maxSelectedLabels || props.value.length);

Expand All @@ -873,7 +890,10 @@ export const MultiSelect = React.memo(
const iconProps = mergeProps(
{
className: cx('removeTokenIcon'),
onClick: (e) => removeChip(e, val)
onClick: (e) => removeChip(e, val),
tabIndex: props.tabIndex || '0',
'aria-label': localeOption('removeTokenIcon'),
onKeyDown: (e) => onremoveTokenIconKeyDown(e, val)
},
ptm('removeTokenIcon', context)
);
Expand Down

0 comments on commit cb12647

Please sign in to comment.