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: #7437, TabView: Unable to select closable icon of tabs through keyboard #7438

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Changes from 1 commit
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
17 changes: 16 additions & 1 deletion components/lib/tabview/TabView.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,19 @@ export const TabView = React.forwardRef((inProps, ref) => {
getElement: () => elementRef.current
}));

const onCloseIconKeyDown = (event, index) => {
event.preventDefault();
event.stopPropagation();

switch (event.code) {
case 'Space':
case 'NumpadEnter':
case 'Enter':
onTabHeaderClose(event, index);
break;
}
};

const createTabHeader = (tab, index) => {
const selected = isSelected(index);
const { headerStyle, headerClassName, style: _style, className: _className, disabled, leftIcon, rightIcon, header, headerTemplate, closable, closeIcon } = TabPanelBase.getCProps(tab);
Expand All @@ -348,7 +361,9 @@ export const TabView = React.forwardRef((inProps, ref) => {
const closeIconProps = mergeProps(
{
className: cx('tab.closeIcon'),
onClick: (e) => onTabHeaderClose(e, index)
onClick: (e) => onTabHeaderClose(e, index),
tabIndex: 0,
onKeyDown: (e) => onCloseIconKeyDown(e, index)
akshayaqburst marked this conversation as resolved.
Show resolved Hide resolved
},
getTabPT(tab, 'closeIcon', index)
);
Expand Down
Loading