Skip to content

MenuButton performance issues #636

@aminland

Description

@aminland

🐛 Bug report

Current Behavior

It seems that simply having a MenuButton on the page (not expanded) results in a getBoundingClientRect call on every frame (see screenshot). On other pages (e.g. reach-alert), the profile on the right side is nice and empty.
image

Expected behavior

If the menu isn't open, there is no reason to be observing and measuring it. (It would be nice if it wasn't re-measured even if it was open)

Reproducible example

Reach's own docs

Suggested solution(s)

I'm not too with what's under the hood, but perhaps add a prop to the popover component that allows enabling / disabling measurement, and control this prop based on menu state?

Additional context

We ran into this issue while profiling our own application. Even when the window isn't in focus, the idle cpu usage for this chrome tab sits at 10% due to this issue.

Your environment

Software Name(s) Version
Reach Package menu-button 0.10.5
Browser Chrome 83

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions