Skip to content

Commit

Permalink
Don’t scroll menus in response to hover
Browse files Browse the repository at this point in the history
By default, when a menu item is focused, browsers will scroll it into view.
Sometimes even into the centre of the view. This is good when using a keyboard,
because the focused item is automatically visible, but when it was focused in
response to mouse movement, it has the effect of moving the item out from
underneath the pointer.

Fixes #1566
  • Loading branch information
cpmsmith authored and benoitgrelard committed Mar 6, 2024
1 parent 2790136 commit 0173093
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .yarn/versions/54d1ffa8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
releases:
"@radix-ui/react-context-menu": patch
"@radix-ui/react-dropdown-menu": patch
"@radix-ui/react-menu": patch
"@radix-ui/react-menubar": patch

declined:
- primitives
2 changes: 1 addition & 1 deletion packages/react/menu/src/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ const MenuItemImpl = React.forwardRef<MenuItemImplElement, MenuItemImplProps>(
contentContext.onItemEnter(event);
if (!event.defaultPrevented) {
const item = event.currentTarget;
item.focus();
item.focus({ preventScroll: true });
}
}
})
Expand Down

0 comments on commit 0173093

Please sign in to comment.