Repository navigation
[popups] Unify popup open changes, store and Root - #5960
Merged
michaldudak merged 15 commits intoOct 16, 2026
Merged
Conversation
commit: |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
michaldudak
force-pushed
the
popups-refactor/2-store-and-root
branch
from
October 9, 2026 18:33
a6fd88d to
c3e6c7a
Compare
Bundle size
PerformanceTotal duration: 383.40 ms -0.66 ms(-0.2%) | Renders: 75 (▼-1) | Paint: 682.68 ms +2.64 ms(+0.4%)
14 tests within noise — details Check out the code infra dashboard for more information about this PR. |
michaldudak
force-pushed
the
popups-refactor/2-store-and-root
branch
from
October 12, 2026 10:43
c3e6c7a to
0a861c8
Compare
michaldudak
force-pushed
the
popups-refactor/2-store-and-root
branch
from
October 12, 2026 18:02
0a861c8 to
1f4941a
Compare
michaldudak
force-pushed
the
popups-refactor/2-store-and-root
branch
from
October 13, 2026 07:53
1f4941a to
e3522ab
Compare
michaldudak
force-pushed
the
popups-refactor/2-store-and-root
branch
from
October 13, 2026 08:48
e3522ab to
af80724
Compare
michaldudak
marked this pull request as ready for review
October 13, 2026 10:46
michaldudak
requested review from
aarongarciah,
atomiks,
colmtuite,
flaviendelangle,
jjenzz and
romgrk
as code owners
October 13, 2026 10:46
atomiks
approved these changes
Oct 13, 2026
`MenuStore.setOpen` emitted a `'setOpen'` string event that `MenuRoot` listened for in a layout effect and handled with component state. The store now runs the open change itself, as the other popup stores do, so the event and its listener are gone. The touch-close cooldown and the last open event move to the store context. The Root still decides two things the listener did, and exposes both to the store through the context: a request made while the Root isn't mounted is dropped, as an event with no listener was, and a repeated request is compared against the state the Root last committed. The order of the steps is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Tooltip, PreviewCard, Popover, Dialog and Menu each ran their own copy of the open-change sequence. `BasePopupStore` now owns `setOpen` and the order of its steps: 1. `isOpenChangeIgnored` 2. `getCloseTrigger` 3. attaching `preventUnmountOnClose()` to the event details 4. `onOpenChange` 5. the cancel check 6. notifying the interactions 7. `isOpenChangeDropped` 8. `prepareOpenChange` 9. one commit, flushed synchronously for hover unless the store opts out 10. `completeOpenChange` Each store overrides only the steps where it differs, so every popup keeps its behavior, including where the copies had drifted apart: - Menu still ignores a delayed touch click only after reporting the close to `onOpenChange` and the interactions. - Popover still commits `instantType` in a second update. - Dialog's `preventUnmountOnClose()` still writes state as soon as it is called, even when the close is then cancelled. The last open-change reason is now shared popup state, and `applyPopupOpenChange` is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…erface `FloatingRootContext` was an alias of the `FloatingRootStore` class. It is now an interface holding only what the interaction hooks, the focus manager, the delay group and positioning use: reads of the open state, trigger, anchor, floating element and id, `setOpen`, the client-point anchor, and the shared `dataRef`, `events`, `nested` and trigger map. `FloatingRootStore` implements it. Code that owns a real `FloatingRootStore` (Select, Combobox, NavigationMenu, the popup store state and the anchor positioning write-back) now names the class instead. Nothing changes at runtime. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Popup stores (Tooltip, PreviewCard, Popover, Dialog and Menu, plus the
components built on them) no longer create a `FloatingRootStore` or copy their
open state, trigger and elements into it from the Root's layout effect. They
implement `FloatingRootContext` themselves, and parts hand the store straight
to the interaction hooks, the focus manager and positioning.
- The hooks' reads come from popup state and keep the values the old copy
settled on:
- The DOM reference is the last trigger the popup was anchored to, kept after
the popup unmounts.
- The anchor is the client-point reference or else the active trigger. A
client-point reference survives a close; one that followed the trigger
follows the next trigger.
- The floating element is the positioner (the popup for Dialog and Drawer),
including a `keepMounted` positioner while closed. It is withheld only
while an opening popup is still hidden, which the copy's one-commit lag
used to cover.
- Anchor positioning still clears the DOM reference and the client-point
reference while a `keepMounted` positioner is unmounted.
- `dataRef`, `events` and `nested` live in the popup store's context.
- `dispatchOpenChange` is one function both store kinds call, so `syncOnly`
and `useSyncedFloatingRootContext` are gone.
Hooks now see a change in the same render instead of one Root layout effect
later.
Select, Combobox, NavigationMenu and Toast keep their `FloatingRootStore`.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nceInteraction
Popover, Menu, the submenu trigger, PreviewCard and Tooltip all passed
`isClosing: () => store.select('transitionStatus') === 'ending'`. Now that the
hook reads the popup store itself, its own fallback reads exactly that, so the
option and its test are gone. NavigationMenu, which never passed it, keeps
reading a `FloatingRootStore` that never reports a closing transition.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Store creation, handle attachment, trigger ownership and open-state transitions move from popupStoreUtils.ts to popupRoot.tsx unchanged, so the next commits can build the popup Root module there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…opupStore Popover, PreviewCard and Menu passed a callback to useOpenStateTransitions to clear their own fields once the popup unmounted. They now override prepareUnmount instead, and resetOnUnmount commits those fields with the ones every popup resets in one update. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Popover, Tooltip, PreviewCard, Dialog and Menu each created their store, synced the controlled props and callbacks, kept the active trigger current, ran the open-state transitions and wired actionsRef with the same ordered calls. usePopupRoot now does all of that from the props the Roots share. What differs between Roots is passed as options: closeOnActiveTriggerUnmount (Tooltip, PreviewCard), disabled (Tooltip) and animateInitialOpen (Menu). Menu also passes its own floatingId through usePopupRootWithFloatingId. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Popover, Tooltip, PreviewCard, Dialog and Menu each rendered the handle attachment, their interactions and the payload children in a fixed order. renderPopupRootChildren renders them, so the ordering rule lives in the popup Root module, and the module only exports what Roots call. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
useAnchorPositioning no longer checks for FloatingRootStore to decide which fields to clear while a keepMounted positioner is unmounted. A PositioningRootContext interface adds clearPositioning() to the interaction store for positioning only: FloatingRootStore clears all four element fields, and popup stores clear the anchor element and anchor override in one update. Popup families that use their own store no longer bundle FloatingRootStore.
usePopupRootStore sets the store's nested flag on every render before anything reads it, so the argument threaded through createStore, the store constructors, createInitialContext and createFloatingRootContextValues is gone. Menu's open changes are gated on getCommittedOpenState alone: the Root sets it in a layout effect and clears it on unmount, so rootMounted is gone too. Also corrects the usePopupRootStore and PreviewCardHandleStore JSDoc.
… request gates Covers both syncAnchorState branches, both resetOnUnmount branches with a store's own unmount field, the floatingElement and referenceElement selectors, and Menu's repeated, already-closed, unmounted and trigger-less requests and its allowMouseEnter reset.
…n-change steps may return Preview Card is checked for focus and dismiss, and Tooltip for dismiss. A type spec pins which fields prepareOpenChange and prepareUnmount may return.
- `createPopupStoreContext()` builds the context every popup store starts with, including its trigger map, so stores no longer create and pass a `PopupTriggerMap` themselves. - `resetOnUnmount` builds the shared reset once, and Menu's close trigger reads the committed open state without a redundant optional call. - `StoreInspector` serializes Maps and Sets in one branch. - Tests cover what `dispatchOpenChange` sends and how it keeps the open event, a Menu `handle.open()` made in the commit the Root mounts, the synchronous hover commit and re-hovering during the exit transition for Tooltip and Menu, and focus when a `keepMounted` submenu reopens on hover. - The `useImplicitActiveTrigger` and `createPopupOpenState` tests move next to their modules, sharing trigger helpers through `test/popupStoreTestUtils`.
michaldudak
force-pushed
the
popups-refactor/2-store-and-root
branch
from
October 16, 2026 06:58
0035eea to
0c9f945
Compare
flaviendelangle
added a commit
to flaviendelangle/base-ui
that referenced
this pull request
Nov 2, 2026
Moves the drag engine's interactive-element selector import to the relocated `utils/popups/constants`, applies master's stricter lint rules to the branch's files, and marks the fake browser's paste focus test as an expected failure: since mui#5960, a Menu closed through its controlled `open` prop no longer notifies its Menubar, which then reopens it on focus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
flaviendelangle
added a commit
to michaldudak/base-ui
that referenced
this pull request
Nov 19, 2026
Master (mui#5960, mui#6111) moved `useOpenStateTransitions` into popupRoot.tsx and replaced its `onUnmount` callback with the store's `resetOnUnmount`. Ported the deferred close check there: when an open request is pending at unmount, `resetOnUnmount` and `onOpenChangeComplete(false)` now wait until the request turns out to be ignored, and are skipped if it reopens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part 2 of 4 of the popup architecture refactor.
Before: Tooltip, Preview Card, Popover, Dialog and Menu each ran their own copy of the open-change sequence, and the copies had drifted apart. Menu even routed its open change through a string event that
MenuRoothandled with component state. Each popup also kept a second store, aFloatingRootStore, that the Root's layout effect filled with copies of the open state, trigger and elements so the interaction hooks could read them. And each Root repeated the same ordered calls to create the store, sync controlled props, keep the active trigger current, run the open-state transitions and render its children.After:
BasePopupStoreownssetOpenand the order of its steps, and each store overrides only the steps where it differs. The popup stores implement the interface the interaction hooks need (FloatingRootContext) themselves, so there is no second store and no copy. Every popup Root runs throughusePopupRootand renders its children throughrenderPopupRootChildren, so the Root's rules live in one module (popupRoot.tsx). Select, Combobox, NavigationMenu and Toast keep theirFloatingRootStore.How
MenuRootintoMenuStore; the'setOpen'event and its listener are gone.BasePopupStore.setOpen: ignore check, close trigger,preventUnmountOnClose(),onOpenChange, cancel check, notifying the interactions, drop check, prepare, one commit (flushed synchronously for hover unless the store opts out), complete.instantTypein a second update, and Dialog'spreventUnmountOnClose()still writes state as soon as it is called.applyPopupOpenChangeis gone.FloatingRootContextbecomes an interface holding only what the interaction hooks, the focus manager, the delay group and positioning use.FloatingRootStoreimplements it.dataRef,eventsandnestedmove into the popup store's context, andsyncOnlyanduseSyncedFloatingRootContextare gone.useHoverReferenceInteractionreads the closing transition from the store, so theisClosingoption is gone.clearPositioning()on aPositioningRootContextinterface. Both store kinds implement it, so positioning doesn't importFloatingRootStore, and Popover, Menu, Tooltip and Preview Card no longer bundle it.popupStoreUtils.tstopopupRoot.tsx.prepareUnmount, committed with the shared fields in one update.usePopupRootruns every Root. The differences are options:closeOnActiveTriggerUnmount(Tooltip, Preview Card),disabled(Tooltip) andanimateInitialOpen(Menu).renderPopupRootChildrenrenders the handle attachment, interactions and payload children in one fixed order.nestedargument, sinceusePopupRootStoresets the flag on every render. Menu gates open changes ongetCommittedOpenStatealone, which the Root sets while it is mounted.Behavior
No intended user-visible change. The differences between components are kept on purpose.
Known observable notes:
FloatingRootStoreran.🤖 Generated with Claude Code