Repository navigation
Conversation
On React 17, the generated trigger id is undefined on the first render and is set in an effect. The Menu and Popover triggers used this id as the key of the Fragment that wraps the element, so React mounted a new DOM node. The hover listeners stayed on the old node, and hover did not open the popup. Use constant keys. The keys are local to the trigger, so they cannot collide between triggers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
commit: |
Bundle size
PerformanceNo regressions in 36 benchmarks · precise to ±11.1% (±16.8% at worst) · ran 3m 54s · details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This was referenced Dec 1, 2026
Render the focus guards conditionally around the trigger element, so React keeps the element at the same position without a key. Add tests that mock `React.useId` away and check that hover opens Menu and Popover on mount and after hydration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On React 17,
useIdreturnsundefinedon the first render. It sets the id in an effect and forces a rerender.Menu.TriggerandPopover.Triggerused this id as the key of the Fragment that wraps the trigger element (added in #3255). The key changes fromundefinedtobase-ui-N, so React mounts a new trigger DOM node. The hover listeners stay on the old, detached node, and hover does not open the popup. A staticidprop on the trigger hides the bug.The same remount also occurs on all React versions when the
idprop of the trigger changes.Fix
FloatingFocusManager. The element keeps its position, so React keeps its DOM node without a key, also when the focus guards mount.Tests
popupConformanceTests(all popup roots): the trigger keeps the same DOM node from the first commit through open and close, and when theidprop changes.MenuTrigger.react17.test.tsxandPopoverTrigger.react17.test.tsxmockReact.useIdaway, likeMenuFilterRoot.react17.test.tsx. So the default CI runs the React 17 id fallback. Hover opens the popup on mount and after hydration.props.triggeronCombobox.Input, like the other configs.idchange test fail for Menu and Popover on React 19. If the closed trigger returns the element alone, the open and close test also fails on React 19.Test results
React 19 (default):
pnpm test:jsdom src/menu/ src/popover/ Root.test: 80 files pass (4021 tests).pnpm test:chromium src/menu/ src/popover/ Root.test: 84 files pass (4877 tests).React 17 (Chromium only, CI does not run React 17):
pnpm test:chromium src/menu/ src/popover/: 76 failures before the fix, 26 after. Most of the fixed tests are hover tests, for example "opens when the trigger is hovered and closes when it is no longer hovered".act()warnings,React.startTransitionin test code, synchronous commits, and flakyMenuFilterSubmenuRootkeyboard tests (they are also flaky without the fix).To run the tests on React 17 locally:
pnpm code-infra set-version-overrides --pkg react@17(the same command aspnpm use-react-18).packages/react/test/createRenderer.tslocally. On React 17,act()does not return the callback result, sorender()returnsundefined. Assign the result inside theact()callback.react/jsx-runtimefrom@mui/internal-test-utilson React 17.Related: mui/material-ui#48823 (the Menu2 tests on React 17 use a static
idas a workaround).Generated with Claude Code