-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MenuLists in portals cause page to scroll with React 18 #956
Comments
I have experienced this too |
I have the same issue. |
I have this issue with or without using the One way to fix this issue before the team releases the patch is to use a function to render the <Menu>
{({ isExpanded }) => (
<>
<MenuButton>Actions</MenuButton>
{isExpanded ? (
<MenuList portal>
<MenuItem onSelect={() => alert("Download")}>Download</MenuItem>
<MenuItem onSelect={() => alert("Copy")}>Create a Copy</MenuItem>
<MenuItem onSelect={() => alert("Delete")}>Delete</MenuItem>
<MenuLink as="a" href="https://reacttraining.com/workshops/">
Attend a Workshop
</MenuLink>
</MenuList>
) : null}
</>
)}
</Menu> |
@spirosikmd your fix worked, the patch helped, but still caused some scroll issues the first time it was opened. Thank you very much |
The only potential issue I see is that in development, I see a warning from the |
I'm trying the suggestion above in a custom select component that uses |
🐛 Bug report
Current Behavior
When rendering menu buttons that open menu lists on slightly long pages, opening a menu after scrolling down a bit often causes the page to scroll farther down. This only happens when rendering the menu lists inside portals, and when using React 18.
This screen recording shows the behavior happening in the reproducible example.
Expected behavior
The menu should open without any change in the page's scroll position.
Reproducible example
Example in Code Sandbox
Your environment
The text was updated successfully, but these errors were encountered: