Skip to content

Commit

Permalink
Refactor TieredMenu and Menu escapes #5639
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Dec 25, 2023
1 parent 68942b6 commit c41b7d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/lib/menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const Menu = React.memo(
}

case 'Tab':
props.popup && visibleState && hide();
props.popup && visibleState && hide(event);
break;

default:
Expand All @@ -157,7 +157,7 @@ export const Menu = React.memo(
const onArrowUpKey = (event) => {
if (event.altKey && popup) {
DomHandler.focus(targetRef.current);
hide();
hide(event);
event.preventDefault();
} else {
const optionIndex = findPrevOptionIndex(focusedOptionIndex);
Expand Down
6 changes: 6 additions & 0 deletions components/lib/tieredmenu/TieredMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export const TieredMenu = React.memo(
break;

case 'Escape':
props.popup && DomHandler.focus(targetRef.current);
onEscapeKey(event);
break;

Expand Down Expand Up @@ -268,6 +269,10 @@ export const TieredMenu = React.memo(

const onArrowUpKey = (event) => {
if (event.altKey) {
if (props.popup) {
DomHandler.focus(targetRef.current);
}

if (focusedItemInfo.index !== -1) {
const processedItem = visibleItems[focusedItemInfo.index];
const grouped = isProccessedItemGroup(processedItem);
Expand Down Expand Up @@ -330,6 +335,7 @@ export const TieredMenu = React.memo(
const element = DomHandler.findSingle(getMenuElement(), `li[id="${`${focusedItemId}`}"]`);
const anchorElement = element && DomHandler.findSingle(element, '[data-pc-section="action"]');

props.popup && DomHandler.focus(targetRef.current);
anchorElement ? anchorElement.click() : element && element.click();
}

Expand Down

0 comments on commit c41b7d7

Please sign in to comment.