-
-
Notifications
You must be signed in to change notification settings - Fork 266
[popover] Support detached triggers and multiple triggers per popover #2336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michaldudak
merged 171 commits into
mui:master
from
michaldudak:popover-detached-triggers
Oct 6, 2025
Merged
Changes from all commits
Commits
Show all changes
171 commits
Select commit
Hold shift + click to select a range
971b6f9
Shared referenceProps
michaldudak fc2138c
Update Floating UI to work with multiple triggers
michaldudak 3a56526
Create a working demo
michaldudak 6d6d22a
Do not animate initial appearance
michaldudak d9152e6
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 4088d34
Suppress TS error
michaldudak f65cc32
Cleanup
michaldudak bfee582
Open on hover setting
michaldudak d9d1905
Remove unnecessary data prop
michaldudak 7a4f3bf
Animate popups' dimensions
michaldudak 6740f73
Fix autoresize
michaldudak 3b03622
Update Popover implementation to use the Store
michaldudak 6543ba0
Fix hover triggers
michaldudak b0de7c8
Remove unnecessary props
michaldudak d8ee5ac
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak e6c5e96
Fix height transitions when anchored on top
michaldudak 4a45232
Remove separate DetachedTriggerComponent
michaldudak 6531171
Fix some of the issues
michaldudak b46d7fe
Update the experiment
michaldudak a1a8eee
Cleanup
michaldudak a8a6656
Payload type safety
michaldudak 4b3fd46
Fix `stickIfOpen`
michaldudak ee73f22
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak c10b27f
API docs
michaldudak 80f56d3
Fix build errors
michaldudak c7eb92a
Fix modality, set initial state
michaldudak 3bc5d73
Update tests
michaldudak 4d0a555
Controlled mode WIP
michaldudak 03f81f8
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 1a55d07
lint, api docs
michaldudak 4498f3b
dedupe
michaldudak bd331f4
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak fd17f93
Fix controlled mode
michaldudak f10279d
Make a Trigger mandatory
michaldudak b58ea65
Change onOpenChange signature
michaldudak 0205efc
docs:api
michaldudak 323ca10
comment
michaldudak ef7084d
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 7d99d16
dedupe
michaldudak fff7da9
Fix controlled popups not appearing
michaldudak 2d84030
Update demos
michaldudak 5bbcc7e
Set open state only for active triggers
michaldudak cc26415
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak a3e3a26
Correct a11y attributes for inactive triggers
michaldudak d09bd98
Recreate lockfile
michaldudak dc4822b
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak b41b0e8
Remove gaps between triggers
michaldudak 1e9dc60
Support transitions while hovering
michaldudak c8e98bf
Somewhat working content transitions
michaldudak 63d00b0
Fix
michaldudak 87fcc2f
Fix opening the wrong popover on hover with delay
michaldudak 50ceda6
TransitionContainer -> Viewport
michaldudak c6de7d2
API docs
michaldudak 682766b
Restore closeOnFocusOut
michaldudak 482a2b3
Hint what component should stay stable
michaldudak 4261b0b
Recreate the old content using innerHTML instead of JSX tree
michaldudak 8e467f0
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak e7f5357
Docs and demos
michaldudak 6a9bc64
Fix a mistake in the example
michaldudak 94f35e8
Fix docs
michaldudak 4cd22af
JSDocs, cleanup, fixes
michaldudak b5672eb
Add tests
michaldudak f5a8901
Fix tests
michaldudak f91b5bf
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak ef0bf76
Do not run tests on JSDOM
michaldudak 7610fde
Do not show shared state in experiments
michaldudak 4637d11
Do not include demo files without default export in regression tests
michaldudak 027c64d
Cleanup
michaldudak 176e2fc
Do not modify old trigger maps
michaldudak 6d8627a
Detect aborted animations
michaldudak f347f42
Remove unnecessary positionerRef
michaldudak 48c0615
Revert
michaldudak 8234bec
Fix layout shifting during content transitions
michaldudak 3440cb1
Prettier
michaldudak d482c8a
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 2fa33ac
Do not use `innerHTML`/`dangerouslySetInnerHTML`
michaldudak 56e59c5
Fix ref cleanup
michaldudak 25062e3
Keep the `open` prop a boolean and add the `triggerId` prop
michaldudak dba3a53
Add close to imperative actions
michaldudak feb1f03
Fix TS and API docs
michaldudak 89bc14a
Dedupe
michaldudak 26f4079
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 25b7191
Recreate the lockfile
michaldudak d468eab
Fix disappearing arrow
michaldudak ff5b413
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 69197a5
API docs
michaldudak 64c6f82
Merge eventDetails and options parameters
michaldudak 37c2423
Fix hover with delay=0
michaldudak 6791a00
Fix controlled input warning
michaldudak f58b76e
Viewport tests
michaldudak bc9a03f
Tailwind demos
michaldudak 449eebf
Fix `inert` value on R18
michaldudak 246dd66
Refactor usePreviousRenderValue
michaldudak 47c4c82
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 576421c
Add missing paren
michaldudak 21748a0
Update demos and docs
michaldudak e858dbe
Pass trigger to onOpenChange
michaldudak 551ff08
Update `useFloating` to recognize triggers
michaldudak 0bbe272
Make transitions consistent
michaldudak 5b07b1a
dedupe
michaldudak 51acf6b
Improve the fully featured demo
michaldudak 821fae6
prettier
michaldudak 2473531
Use state in `usePreviousRenderValue`
michaldudak 48366c9
Tests and cleanup
michaldudak f7a8579
Transition improvements
michaldudak 46264ca
Almost there
michaldudak fff09c6
fix WIP
michaldudak f642d11
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak f9a8f8b
Fix size calculations
michaldudak a95e936
Remove debug code
michaldudak 6cfc0af
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak d3c18b2
Fix sizing issue and update Tailwind demo
michaldudak 404b6c0
Inline demo icons
michaldudak c5a4b89
Update the docs
michaldudak b148fb8
Fix animation restarting when toggling the open state repeatedly
michaldudak 23cdb6c
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak ae9e720
Fix layout glitch
michaldudak 64948de
Docs
michaldudak a4c1607
Revert useStoreControlled
michaldudak 7f0b948
contains
michaldudak b49358f
Add trigger to BaseUIEventDetails
michaldudak 9048abd
Remove `innerHTML`
michaldudak bdec6fe
Fix NavigationMenu regression
michaldudak b4da865
Fix layout shift when closing the popover during content transitions
michaldudak b69104a
Fix tests
michaldudak 2013b72
dedupe
michaldudak 483c10e
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak b3172e9
Fix focus management
michaldudak 6eb6cdb
Fixes
michaldudak c6e9a58
Fix focus restoration on esc
michaldudak cbe8e11
Do not close the popup on shift+tab
michaldudak d1f4520
Cleanup
michaldudak 60522c0
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 41178e4
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak ee0a1be
Focus issues
michaldudak c089f6a
More focus fixes
michaldudak 6f04c99
Fixing R18 tests
michaldudak 2affba5
Fix the `key` spread issue
michaldudak 16354d2
Formatting
michaldudak c414231
Testing leftover
michaldudak 54e0297
Use `resolveRef` elsewhere
michaldudak ac67488
Fix
michaldudak 5385539
Set data-instant on focusout
michaldudak b8f2769
Fix iOS size calculation
michaldudak 846b34b
Capitalize titles
michaldudak fe45dea
Typo
michaldudak b1b2983
Controlled mode docs and demo
michaldudak f7a7d26
Use CSS transitions in the demo
michaldudak cc6ffe8
API docs
michaldudak a5f4cb6
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 379ac3a
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 556dc6a
Use new methods from the ReactStore
michaldudak 946eb93
Use `store.useControlledProp`
michaldudak a547bec
Add Calendar experiment
michaldudak 0901f32
Ignore available width/height when measuring popup size
michaldudak a851cb0
Remove starting-style when measuring content
michaldudak 6d16361
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 9609029
Lint, dedupe
michaldudak c5e58c4
API docs
michaldudak d59a259
Fix exploding layout in controlled demo
michaldudak aa2d8f5
Revert ignoring starting style
michaldudak 610eb03
Fix transition issue in the deployed docs
michaldudak 800730b
Fixing React 18
michaldudak a8c54a7
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak edf8d4e
Dedupe
michaldudak 9f594cf
Remove redundant ref
michaldudak 0027f01
Move refs to store's context
michaldudak bf7a6b6
Merge remote-tracking branch 'upstream/master' into popover-detached-…
michaldudak 7529cc3
Experiment updates
michaldudak 15109b5
Cleanup
michaldudak feb8909
Prettier
michaldudak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| { | ||
| "name": "PopoverViewport", | ||
| "description": "A viewport for displaying content transitions.\nThis component is only required if one popup can be opened by multiple triggers, its content change based on the trigger\nand switching between them is animated.\nRenders a `<div>` element.", | ||
| "props": { | ||
| "children": { | ||
| "type": "ReactNode", | ||
| "description": "The content to render inside the transition container.", | ||
| "detailedType": "React.ReactNode" | ||
| }, | ||
| "className": { | ||
| "type": "string | ((state: Popover.Viewport.State) => string)", | ||
| "description": "CSS class applied to the element, or a function that\nreturns a class based on the component’s state.", | ||
| "detailedType": "| string\n| ((state: Popover.Viewport.State) => string)" | ||
| }, | ||
| "render": { | ||
| "type": "ReactElement | ((props: HTMLProps, state: Popover.Viewport.State) => ReactElement)", | ||
| "description": "Allows you to replace the component’s HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render.", | ||
| "detailedType": "| ReactElement\n| ((\n props: HTMLProps,\n state: Popover.Viewport.State,\n ) => ReactElement)" | ||
| } | ||
| }, | ||
| "dataAttributes": { | ||
| "data-activation-direction": { | ||
| "description": "Indicates the direction from which the popup was activated.\nThis can be used to create directional animations based on how the popup was triggered.\nContains space-separated values for both horizontal and vertical axes.", | ||
| "type": "`${'left' | 'right'} {'top' | 'bottom'}`" | ||
| }, | ||
| "data-current": { | ||
| "description": "Applied to the direct child of the viewport when no transitions are present or the new content when it's entering." | ||
| }, | ||
| "data-previous": { | ||
| "description": "Applied to the direct child of the viewport that contains the exiting content when transitions are present." | ||
| }, | ||
| "data-transitioning": { | ||
| "description": "Indicates that the viewport is currently transitioning between old and new content." | ||
| } | ||
| }, | ||
| "cssVariables": { | ||
| "--popup-height": { | ||
| "description": "The height of the parent popup.\nThis variable is placed on the 'previous' container and stores the height of the popup when the previous content was rendered.\nIt can be used to freeze the dimensions of the popup when animating between different content." | ||
| }, | ||
| "--popup-width": { | ||
| "description": "The width of the parent popup.\nThis variable is placed on the 'previous' container and stores the width of the popup when the previous content was rendered.\nIt can be used to freeze the dimensions of the popup when animating between different content." | ||
| } | ||
| } | ||
| } |
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
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
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
15 changes: 15 additions & 0 deletions
15
docs/src/app/(private)/experiments/popover/calendar-shared.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { Popover } from '@base-ui-components/react/popover'; | ||
|
|
||
| export const eventPopover = Popover.createHandle<EventData>(); | ||
|
|
||
| export interface EventData { | ||
| title: string; | ||
| dayOfWeek: number; | ||
| dateString: string; | ||
| description?: string; | ||
| location?: string; | ||
| imageUrl?: string; | ||
| startTime: number; | ||
| endTime: number; | ||
| id: number; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this special method a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously unmounting was prevented whenever
actionsRefwas present. As I added a new imperative action, this logic didn't make sense anymore, so I had to make preventing unmounting explicit.