Skip to content

Commit

Permalink
fix: focus-trapped-within-menuitem (#17550)
Browse files Browse the repository at this point in the history
  • Loading branch information
preetibansalui committed Sep 25, 2024
1 parent 124d86c commit afc2c6a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react/src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ const Menu = forwardRef<HTMLUListElement, MenuProps>(function Menu(
}

function focusItem(e?: React.KeyboardEvent<HTMLUListElement>) {
e?.preventDefault();
const currentItem = focusableItems.findIndex((item) =>
item.ref?.current?.contains(document.activeElement)
);
Expand Down Expand Up @@ -266,6 +265,7 @@ const Menu = forwardRef<HTMLUListElement, MenuProps>(function Menu(
if (indexToFocus !== currentItem) {
const nodeToFocus = focusableItems[indexToFocus];
nodeToFocus.ref?.current?.focus();
e?.preventDefault();
}
}

Expand Down

0 comments on commit afc2c6a

Please sign in to comment.