Skip to content

Commit

Permalink
fix(components): context menu keyboard navigation (#5767)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra authored May 14, 2021
1 parent 4704c7b commit ef793e7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/components/src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ const ContextMenu = ({ visible, setVisibility, position, ...props }) => {
const [computedMenuWidth, setComputedMenuWidth] = React.useState<number>(0);
const [menuIsReadyToShow, setMenuIsReadyToShow] = React.useState(false);

// enables keyboard navigation
React.useEffect(() => {
setTimeout(() => {
if (!visible && !menuRef.current) return;
menuRef.current.focus();
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible, menuRef.current]);

React.useEffect(() => {
// for the initial render, the menu is not ready to be shown
// because the element height cannot be computed
Expand Down

0 comments on commit ef793e7

Please sign in to comment.