Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #7377, MultiSelect: Cannot access the close Icon and clear the input using keyboard in Filled mode #7378

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion components/lib/multiselect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,11 +981,31 @@ export const MultiSelect = React.memo(
ZIndexUtils.clear(overlayRef.current);
});

const onClearIconKeyDown = (event) => {
event.preventDefault();
event.stopPropagation();

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

updateModel(event, [], []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you want to add event.preventDefault() and event.stopPropagation() so this does not bubble up to other components

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done @melloware

break;
}
};

const createClearIcon = () => {
const clearIconProps = mergeProps(
{
className: cx('clearIcon'),
onClick: (e) => updateModel(e, [], [])
onClick: (e) => updateModel(e, [], []),
tabIndex: props.tabIndex || '0',
'aria-label': localeOption('clear'),
onKeyDown: (e) => onClearIconKeyDown(e)
},
ptm('clearIcon')
);
Expand Down
Loading