anchorOrigin and transformOrigin can create delay on what menuItem is (visually) selected.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
When adding an anchorOrigin OR transformOrigin prop to a Menu so that it pops over the button it can create a visual glitch. If your mouse is on a certain area it can select the wrong menuItem briefly before changing. It is sometimes only a small area where the mouse has to be for it to take effect but I've managed to exaggerate the effect (somehow) in the code-sand-box linked below, so that it often fails to select the correct menuItem straight away.
I've checked the console log on my own project and if I click while the wrong menuItem is selected it does actually select the correct item, so it's purely visual.
https://codesandbox.io/s/positionedmenu-demo-material-ui-forked-j8d0vt?file=/demo.tsx:1070-1180

Expected behavior 🤔
Correct menuItem is visually selected straight away.
Steps to reproduce 🕹
Steps:
- Use a
- Add an anchorOrigin or transformOrigin
- Use these to position the popup over the menu
- Click the button, try the mouse in different locations to reach the sweet spot (usually when your mouse is overlapping two of the menuItems).
Context 🔦
I'm trying to create a custom menu type where the menu pops over the button with a default item located directly over the button and others in the list above or below.
Your environment 🌎
Brave Browser
Latest OsX on Mac
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction in demo.tsx, especially the Menu configured with anchorOrigin or transformOrigin, and reproduce the visual selection delay while moving the mouse across overlapping MenuItems. Trace how the positioned popup determines the visually selected item. Done means the correct MenuItem is highlighted immediately in the reproduction, including when the menu overlaps the button.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100