Skip to content

MenuLists in portals cause page to scroll with React 18 #956

@Emilios1995

Description

@Emilios1995

🐛 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

Software Name(s) Version
Reach Package menu-button 0.17.0
React react 18.2.0
Browser Chrome 104.0.5112.79
Browser Firefox 103.0.1
Assistive tech - -
Node - -
npm/yarn - -
Operating System MacOS 12.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions