Skip to content

Commit

Permalink
#5720 TreeSelect tab fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Jan 10, 2024
1 parent 1a05a21 commit f993a21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/lib/treeselect/TreeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,13 @@ export const TreeSelect = React.memo(
break;

case 'Tab':
onTabKey(event);
if (overlayVisibleState) {
event.preventDefault();

if (event.shiftKey) setFocusToFocusableFirstNode();
else onTabKey(event);
}

break;

default:
Expand Down Expand Up @@ -856,6 +862,7 @@ export const TreeSelect = React.memo(
scrollHeight={props.scrollHeight}
onClick={onOverlayClick}
header={header}
hide={hide}
footer={footer}
firstHiddenFocusableElementOnOverlay={<span {...firstHiddenFocusableElementOnOverlayProps}></span>}
lastHiddenFocusableElementOnOverlay={<span {...lastHiddenFocusableElementOnOverlayProps}></span>}
Expand Down
8 changes: 8 additions & 0 deletions components/lib/treeselect/TreeSelectPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ export const TreeSelectPanel = React.forwardRef((props, ref) => {
});
};

const onKeyDown = (event) => {
if (event.key === 'Escape') {
event.preventDefault();
props.hide();
}
};

const createElement = () => {
const wrapperStyle = { maxHeight: props.scrollHeight || 'auto' };

const panelProps = mergeProps(
{
className: cx('panel', { panelProps: props, context }),
style: props.panelStyle,
onKeyDown: onKeyDown,
onClick: props.onClick
},
getPTOptions('panel')
Expand Down

0 comments on commit f993a21

Please sign in to comment.