Menu incorrectly triggers page scroll on hover
See original GitHub issueDescription
When I hover over a <Menu>
which is partially off-screen, the page is scrolled. I don’t expect the page to ever scroll when hovering on a <MenuItem>
.
Link to Reproduction
https://codesandbox.io/s/dawn-bash-516v70?file=/src/index.js
Steps to reproduce
-
Click to open the menu
-
Resize your browser so the menu goes off the bottom of the screen, but the top is visible:
-
Hover over any menu item
-
Notice the page scrolls (this is unexpected behaviour).
-
Scroll the page so the menu goes off the top of the screen, but the bottom is visible:
-
Hover over any menu item
-
Notice the page scrolls (this is unexpected behaviour).
-
Scroll the page so both the top and bottom go off the screen:
-
Hover over any menu item
-
Notice there is no scrolling (this is the correct behaviour).
-
Resize your browser so the full menu fits on the screen (but so there’s still some vertical scroll):
-
Hover over any menu item
-
Notice there is no scrolling (this is the correct behaviour).
Chakra UI Version
1.8.5
Browser
Brave 1.35.101 (Chromium: 98.0.4758.87)
Operating System
- Linux
Additional Information
I couldn’t reproduce the bug in Firefox v97.
Some debugging reveals the culprit as preventScroll: false
here:
https://github.com/takethefake/chakra-ui/blob/main/packages/menu/src/use-menu.ts#L629-L631
Looks like this was introduced in https://github.com/chakra-ui/chakra-ui/pull/4514/files#diff-6c4aefbd3ea81ddacf70475aa13274ae14fbcc6609044c74a25c45f12bd9ff4eR616 to make the keyboard scrolling support better.
I wonder if there’s a better way to fix keyboard support? Or, perhaps alternatively; is there a way we can handle the hovering without having to re-focus every time?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:12 (2 by maintainers)
Top GitHub Comments
Still an issue. Pinging to keep the bot away.
this may help, using a scrollable menuList