Repository navigation
[menu] Open submenus on hover after a plain delay - #4990
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,341.53 ms +105.98 ms(+8.6%) | Renders: 50 (+0) | Paint: 2,028.07 ms +170.10 ms(+9.2%)
10 tests within noise — details Check out the code infra dashboard for more information about this PR. |
72694d1 to
76f4750
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes inconsistent submenu hover-open behavior in the React Menu implementation by ensuring submenus always open after a plain delay (instead of sometimes requiring the pointer to come to rest) when the menu was opened via keyboard/programmatic means and allowMouseEnter initially starts as false.
Changes:
- Update
MenuSubmenuTriggerto always use a plain{ open, close }delay for hover, and gate the open viashouldOpenusingparentMenuStore.select('allowMouseEnter')(only whendelay > 0). - Add a regression test that verifies a submenu opens after the configured delay even while the pointer continues moving (i.e. without entering the “rest-only” path).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react/src/menu/submenu-trigger/MenuSubmenuTrigger.tsx | Ensures submenu hover-open uses a plain delay consistently and gates open via shouldOpen instead of switching to a rest-only path when allowMouseEnter is initially false. |
| packages/react/src/menu/root/MenuRoot.test.tsx | Adds coverage for opening a submenu after a plain delay without requiring the pointer to stop moving. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Review (Claude Fable 5): #4990 — [menu] Open submenus on hover after a plain delayVerdict: LGTM. The fix is sound, minimal (+34/−2), and I verified the test coverage empirically: the new test passes on the PR head and fails when the source fix is reverted, and the full menu suite passes in both jsdom (805 tests) and Chromium (286 tests). What it doesPreviously, while Correctness
Code quality
Test coverage
No security or performance concerns — if anything, performance improves slightly via the removed re-render subscription. |
Submenus that open on hover used to wait for the cursor to stop moving before opening, but only when the submenu trigger was the first item you reached after opening the menu with the keyboard or programmatically. In every other case they opened after a plain delay. They now always use a plain delay.
Root cause
While
allowMouseEnterwas stillfalse, the submenu's hover delay was set to0, which made the open fall back to a rest-only path (restMs) that waits for the pointer to come to rest instead of using the delay.Changes
allowMouseEnterthrough the hover hook'sshouldOpencheck, which is re-evaluated when the delay elapses.0, since that opens synchronously and has no later re-check to fall back on.