Skip to content

The open alternative to Salesforce, designed for AI.

Expose complete Popover parts (#27590)

Raphaël Bosi0ba4089a4a86
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/dropdown.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/dropdown.mdx
index a6f0d1eb660..8fed2ff7475 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/dropdown.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/navigation/dropdown.mdx
@@ -95,15 +95,16 @@
### Dropdown.Content
<ParamField body="Content.align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;" default="start">
- Alignment of the popup along the anchor.
+ Alignment along the anchor. Defaults to start.
</ParamField>
-<ParamField body="Content.alignOffset" type="number | OffsetFunction">
- Offset in pixels along the alignment axis.
+<ParamField body="Content.alignOffset" type="number | OffsetFunction" default="0">
+ Offset along the alignment axis. Accepts a number or positioning function.
</ParamField>
<ParamField body="Content.anchor" type="Element | VirtualElement | RefObject&lt;Element | null&gt; | (() =&gt; Element | VirtualElement | null) | null">
- Element or position the popup is anchored to. Defaults to the trigger.
+ An element to position the popup against.
+ By default, the popup will be positioned against the trigger.
</ParamField>
<ParamField body="Content.className" type="string | ((state: PopoverPopupState) =&gt; string | undefined)">
@@ -111,14 +112,12 @@
returns a class based on the component's state.
</ParamField>
-<ParamField body="Content.collisionPadding" type="Padding">
- Space in pixels kept between the popup and the edges of its collision
- boundary, for all sides or per side. Defaults to 5.
+<ParamField body="Content.collisionPadding" type="Padding" default="5">
+ Additional space to maintain from the edge of the collision boundary.
</ParamField>
<ParamField body="Content.container" type="HTMLElement | ShadowRoot | RefObject&lt;HTMLElement | ShadowRoot | null&gt; | null">
- Element the popup is portaled into. Defaults to the theme's portal
- container.
+ Portal destination, using the scoped theme when omitted. Explicit null waits for a target, matching Popover.Portal.
</ParamField>
<ParamField body="Content.finalFocus" type="boolean | RefObject&lt;HTMLElement | null&gt; | ((closeType: InteractionType) =&gt; boolean | void | HTMLElement | null)">
@@ -143,8 +142,8 @@
Return an element to focus, `true` to use the default behavior, `null` to fall back to the default behavior, or `false`/`undefined` to do nothing.
</ParamField>
-<ParamField body="Content.keepMounted" type="boolean">
- Keeps the popup mounted in the DOM while the popover is closed.
+<ParamField body="Content.keepMounted" type="boolean" default="false">
+ Keeps the popup mounted while closed.
</ParamField>
<ParamField body="Content.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverPopupState&gt;">
@@ -154,12 +153,12 @@
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
-<ParamField body="Content.side" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
- Side of the anchor the popup is placed on.
+<ParamField body="Content.side" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;" default="bottom">
+ Preferred side of the anchor. Defaults to bottom, or inline-end in a submenu.
</ParamField>
<ParamField body="Content.sideOffset" type="number | OffsetFunction" default="0">
- Distance in pixels between the anchor and the popup.
+ Distance from the anchor. Defaults to 0. Accepts a number or positioning function.
</ParamField>
<ParamField body="Content.style" type="CSSProperties | ((state: PopoverPopupState) =&gt; CSSProperties | undefined)">
diff --git a/packages/twenty-docs/snippets/ui/generated/surfaces/popover.mdx b/packages/twenty-docs/snippets/ui/generated/surfaces/popover.mdx
index d4349ac3316..6c81285c120 100644
--- a/packages/twenty-docs/snippets/ui/generated/surfaces/popover.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/surfaces/popover.mdx
@@ -21,8 +21,7 @@
</ParamField>
<ParamField body="Root.children" type="ReactNode | PayloadChildRenderFunction&lt;Payload&gt;">
- The content of the popover.
- This can be a regular React node or a render function that receives the `payload` of the active trigger.
+ Parts or a render function receiving the active trigger payload. Root renders no DOM element.
</ParamField>
<ParamField body="Root.defaultOpen" type="boolean" default="false">
@@ -37,8 +36,7 @@
</ParamField>
<ParamField body="Root.handle" type="PopoverHandle&lt;Payload&gt;">
- A handle to associate the popover with a trigger.
- If specified, allows external triggers to control the popover's open state.
+ Connects detached triggers and imperative open/close actions.
</ParamField>
<ParamField body="Root.modal" type="boolean | &quot;trap-focus&quot;" default="false">
@@ -58,7 +56,7 @@
</ParamField>
<ParamField body="Root.onOpenChange" type="((open: boolean, eventDetails: PopoverRootChangeEventDetails) =&gt; void)">
- Event handler called when the popover is opened or closed.
+ Receives the requested open state and Base UI event details, including reason, event, trigger, cancel() and preventUnmountOnClose().
</ParamField>
<ParamField body="Root.onOpenChangeComplete" type="((open: boolean) =&gt; void)">
@@ -130,37 +128,154 @@
returns a style object based on the component's state.
</ParamField>
-### Popover.Popup
+### Popover.Portal
-<ParamField body="Popup.align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;" default="center">
- Alignment of the popup along the anchor.
+<ParamField body="Portal.className" type="string | ((state: PopoverPortalState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
</ParamField>
-<ParamField body="Popup.alignOffset" type="number | OffsetFunction">
- Offset in pixels along the alignment axis.
+<ParamField body="Portal.container" type="HTMLElement | ShadowRoot | RefObject&lt;HTMLElement | ShadowRoot | null&gt; | null">
+ When omitted, uses the scoped theme container, then the Base UI parent portal or document body. Explicit null delays rendering until a target is supplied. Explicit elements, ShadowRoots and refs are forwarded unchanged; their DOM scope supplies CSS tokens.
</ParamField>
-<ParamField body="Popup.anchor" type="Element | VirtualElement | RefObject&lt;Element | null&gt; | (() =&gt; Element | VirtualElement | null) | null">
- Element or position the popup is anchored to. Defaults to the trigger.
+<ParamField body="Portal.keepMounted" type="boolean" default="false">
+ Whether to keep the portal mounted in the DOM while the popup is hidden.
</ParamField>
-<ParamField body="Popup.arrow" type="boolean" default="false">
- Shows an arrow pointing at the anchor.
+<ParamField body="Portal.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the portal div. Native props, handlers and render target this element.
</ParamField>
-<ParamField body="Popup.className" type="string | ((state: PopoverPopupState) =&gt; string | undefined)">
+<ParamField body="Portal.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverPortalState&gt;">
+ Allows you to replace the component's HTML element
+ with a different tag, or compose it with another component.
+
+ Accepts a `ReactElement` or a function that returns the element to render.
+</ParamField>
+
+<ParamField body="Portal.style" type="CSSProperties | ((state: PopoverPortalState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Popover.Positioner
+
+<ParamField body="Positioner.align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;" default="center">
+ How to align the popup relative to the specified side.
+</ParamField>
+
+<ParamField body="Positioner.alignOffset" type="number | OffsetFunction" default="0">
+ Additional offset along the alignment axis in pixels.
+ Also accepts a function that returns the offset to read the dimensions of the anchor
+ and positioner elements, along with its side and alignment.
+
+ The function takes a `data` object parameter with the following properties:
+ - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`.
+ - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`.
+ - `data.side`: which side of the anchor element the positioner is aligned against.
+ - `data.align`: how the positioner is aligned relative to the specified side.
+</ParamField>
+
+<ParamField body="Positioner.anchor" type="Element | VirtualElement | RefObject&lt;Element | null&gt; | (() =&gt; Element | VirtualElement | null) | null">
+ An element to position the popup against.
+ By default, the popup will be positioned against the trigger.
+</ParamField>
+
+<ParamField body="Positioner.arrowPadding" type="number" default="5">
+ Minimum distance to maintain between the arrow and the edges of the popup.
+
+ Use it to prevent the arrow element from hanging out of the rounded corners of a popup.
+</ParamField>
+
+<ParamField body="Positioner.className" type="string | ((state: PopoverPositionerState) =&gt; string | undefined)">
CSS class applied to the element, or a function that
returns a class based on the component's state.
</ParamField>
-<ParamField body="Popup.collisionPadding" type="Padding">
- Space in pixels kept between the popup and the edges of its collision
- boundary, for all sides or per side. Defaults to 5.
+<ParamField body="Positioner.collisionAvoidance" type="CollisionAvoidance">
+ Determines how to handle collisions when positioning the popup.
+
+ `side` controls overflow on the preferred placement axis (`top`/`bottom` or `left`/`right`):
+ - `'flip'`: keep the requested side when it fits; otherwise try the opposite side
+ (`top` and `bottom`, or `left` and `right`).
+ - `'shift'`: never change side; keep the requested side and move the popup within
+ the clipping boundary so it stays visible.
+ - `'none'`: do not correct side-axis overflow.
+
+ `align` controls overflow on the alignment axis (`start`/`center`/`end`):
+ - `'flip'`: keep side, but swap `start` and `end` when the requested alignment overflows.
+ - `'shift'`: keep side and requested alignment, then nudge the popup along the
+ alignment axis to fit.
+ - `'none'`: do not correct alignment-axis overflow.
+
+ `fallbackAxisSide` controls fallback behavior on the perpendicular axis when the
+ preferred axis cannot fit:
+ - `'start'`: allow perpendicular fallback and try the logical start side first
+ (`top` before `bottom`, or `left` before `right` in LTR).
+ - `'end'`: allow perpendicular fallback and try the logical end side first
+ (`bottom` before `top`, or `right` before `left` in LTR).
+ - `'none'`: do not fallback to the perpendicular axis.
+
+ When `side` is `'shift'`, explicitly setting `align` only supports `'shift'` or `'none'`.
+ If `align` is omitted, it defaults to `'flip'`.
</ParamField>
-<ParamField body="Popup.container" type="HTMLElement | ShadowRoot | RefObject&lt;HTMLElement | ShadowRoot | null&gt; | null">
- Element the popup is portaled into. Defaults to the theme's portal
- container.
+<ParamField body="Positioner.collisionBoundary" type="Boundary" default="clipping-ancestors">
+ An element or a rectangle that delimits the area that the popup is confined to.
+</ParamField>
+
+<ParamField body="Positioner.collisionPadding" type="Padding" default="5">
+ Additional space to maintain from the edge of the collision boundary.
+</ParamField>
+
+<ParamField body="Positioner.disableAnchorTracking" type="boolean" default="false">
+ Whether to disable the popup from tracking any layout shift of its positioning anchor.
+</ParamField>
+
+<ParamField body="Positioner.positionMethod" type="&quot;absolute&quot; | &quot;fixed&quot;" default="absolute">
+ Determines which CSS `position` property to use.
+</ParamField>
+
+<ParamField body="Positioner.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the positioning div. Accepts the complete Base UI anchor, collision and positioning contract.
+</ParamField>
+
+<ParamField body="Positioner.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverPositionerState&gt;">
+ Allows you to replace the component's HTML element
+ with a different tag, or compose it with another component.
+
+ Accepts a `ReactElement` or a function that returns the element to render.
+</ParamField>
+
+<ParamField body="Positioner.side" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;" default="bottom">
+ Which side of the anchor element to align the popup against.
+ May automatically change to avoid collisions.
+</ParamField>
+
+<ParamField body="Positioner.sideOffset" type="number | OffsetFunction" default="8">
+ Distance from the anchor. Defaults to 8. Accepts a number or positioning function.
+</ParamField>
+
+<ParamField body="Positioner.sticky" type="boolean" default="false">
+ Whether to maintain the popup in the viewport after
+ the anchor element was scrolled out of view.
+</ParamField>
+
+<ParamField body="Positioner.style" type="CSSProperties | ((state: PopoverPositionerState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Popover.Popup
+
+<ParamField body="Popup.children" type="ReactNode">
+ Popup content. Compose Portal, Positioner and Arrow separately.
+</ParamField>
+
+<ParamField body="Popup.className" type="string | ((state: PopoverPopupState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
</ParamField>
<ParamField body="Popup.finalFocus" type="boolean | RefObject&lt;HTMLElement | null&gt; | ((closeType: InteractionType) =&gt; boolean | void | HTMLElement | null)">
@@ -185,8 +300,8 @@
Return an element to focus, `true` to use the default behavior, `null` to fall back to the default behavior, or `false`/`undefined` to do nothing.
</ParamField>
-<ParamField body="Popup.keepMounted" type="boolean">
- Keeps the popup mounted in the DOM while the popover is closed.
+<ParamField body="Popup.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the popup div. Focus props, native attributes, handlers and render target this element.
</ParamField>
<ParamField body="Popup.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverPopupState&gt;">
@@ -196,15 +311,53 @@
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
-<ParamField body="Popup.side" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;" default="bottom">
- Side of the anchor the popup is placed on.
+<ParamField body="Popup.style" type="CSSProperties | ((state: PopoverPopupState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Popover.Arrow
+
+<ParamField body="Arrow.className" type="string | ((state: PopoverArrowState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
</ParamField>
-<ParamField body="Popup.sideOffset" type="number | OffsetFunction" default="8">
- Distance in pixels between the anchor and the popup.
+<ParamField body="Arrow.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the arrow div. Compose inside Popup.
</ParamField>
-<ParamField body="Popup.style" type="CSSProperties | ((state: PopoverPopupState) =&gt; CSSProperties | undefined)">
+<ParamField body="Arrow.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverArrowState&gt;">
+ Allows you to replace the component's HTML element
+ with a different tag, or compose it with another component.
+
+ Accepts a `ReactElement` or a function that returns the element to render.
+</ParamField>
+
+<ParamField body="Arrow.style" type="CSSProperties | ((state: PopoverArrowState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Popover.Backdrop
+
+<ParamField body="Backdrop.className" type="string | ((state: PopoverBackdropState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
+</ParamField>
+
+<ParamField body="Backdrop.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the optional backdrop div. Compose inside Portal.
+</ParamField>
+
+<ParamField body="Backdrop.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverBackdropState&gt;">
+ Allows you to replace the component's HTML element
+ with a different tag, or compose it with another component.
+
+ Accepts a `ReactElement` or a function that returns the element to render.
+</ParamField>
+
+<ParamField body="Backdrop.style" type="CSSProperties | ((state: PopoverBackdropState) =&gt; CSSProperties | undefined)">
Style applied to the element, or a function that
returns a style object based on the component's state.
</ParamField>
@@ -271,3 +424,30 @@
Style applied to the element, or a function that
returns a style object based on the component's state.
</ParamField>
+
+### Popover.Viewport
+
+<ParamField body="Viewport.children" type="ReactNode">
+ The content to render inside the transition container.
+</ParamField>
+
+<ParamField body="Viewport.className" type="string | ((state: PopoverViewportState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
+</ParamField>
+
+<ParamField body="Viewport.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the content-transition div for changing trigger payloads.
+</ParamField>
+
+<ParamField body="Viewport.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, PopoverViewportState&gt;">
+ Allows you to replace the component's HTML element
+ with a different tag, or compose it with another component.
+
+ Accepts a `ReactElement` or a function that returns the element to render.
+</ParamField>
+
+<ParamField body="Viewport.style" type="CSSProperties | ((state: PopoverViewportState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
diff --git a/packages/twenty-docs/ui/primitives/overview.mdx b/packages/twenty-docs/ui/primitives/overview.mdx
index 50a8b5f49e6..eb89e0aa73c 100644
--- a/packages/twenty-docs/ui/primitives/overview.mdx
+++ b/packages/twenty-docs/ui/primitives/overview.mdx
@@ -68,13 +68,17 @@ const HelpButton = ({ ref, ...props }: HelpButtonProps) => (
export const ImportHelp = () => (
<Popover.Root>
<Popover.Trigger render={<HelpButton>Import help</HelpButton>} />
- <Popover.Popup>
- <Popover.Title>Import a CSV file</Popover.Title>
- <Popover.Description>
- Use a header row to identify your columns.
- </Popover.Description>
- <Popover.Close render={<Button>Got it</Button>} />
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <Popover.Title>Import a CSV file</Popover.Title>
+ <Popover.Description>
+ Use a header row to identify your columns.
+ </Popover.Description>
+ <Popover.Close render={<Button>Got it</Button>} />
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
);
```
diff --git a/packages/twenty-docs/ui/primitives/surfaces/popover.mdx b/packages/twenty-docs/ui/primitives/surfaces/popover.mdx
index 9eadf4ddf0a..31a3b36eccd 100644
--- a/packages/twenty-docs/ui/primitives/surfaces/popover.mdx
+++ b/packages/twenty-docs/ui/primitives/surfaces/popover.mdx
@@ -7,7 +7,7 @@ import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import PopoverReference from '/snippets/ui/generated/surfaces/popover.mdx';
-Use `Popover` for contextual information or lightweight controls. `Popup` includes positioning and a portal, so you can compose content directly inside it.
+Use `Popover` for contextual information or lightweight controls. Compose its portal, positioning wrapper and popup separately. Use [Dropdown](/ui/components/navigation/dropdown) for menus, pickers and panels with higher-level navigation.
<StoryEmbed
storyId="ui-surfaces-popover--documentation"
@@ -22,22 +22,32 @@ Keep the trigger and popup inside `Popover.Root`. The popup can contain text, fo
```text
Popover.Root
├── Popover.Trigger
-└── Popover.Popup
- ├── Popover.Title
- ├── Popover.Description
- └── Popover.Close
+└── Popover.Portal
+ ├── Popover.Backdrop (optional)
+ └── Popover.Positioner
+ └── Popover.Popup
+ ├── Popover.Arrow (optional)
+ └── Popover.Viewport (optional)
+ ├── Popover.Title
+ ├── Popover.Description
+ └── Popover.Close
```
-| Part | Requirement | Purpose |
-| ------------- | --------------------------------------- | --------------------------------------------------------------------- |
-| `Root` | Required | Coordinates open state and interactions. |
-| `Trigger` | Required for a trigger-anchored popover | Opens or closes the popup and supplies its anchor. |
-| `Popup` | Required | Renders positioned content with focus management. |
-| `Title` | Recommended | Supplies a visible popup name. An accessible name is always required. |
-| `Description` | Optional | Associates explanatory text with the popup. |
-| `Close` | Optional | Provides an explicit close action within the popup. |
-
-`Popup` includes the portal and positioner. Set `arrow` on `Popup` to add its built-in arrow. All parts share their root's context even though the popup renders in a portal; the tree describes component nesting, not the final DOM placement.
+| Part | Purpose and native target |
+| ------------- | --------------------------------------------------------------------------------- |
+| `Root` | Owns state, triggers and interactions. Renders no DOM element. |
+| `Trigger` | Opens the popup and supplies its default anchor. Targets a button. |
+| `Portal` | Chooses the destination. Native props, handlers, `render` and ref target its div. |
+| `Positioner` | Owns anchors, alignment, offsets and collision handling. Targets its div. |
+| `Popup` | Renders content and manages focus. Targets its div. |
+| `Arrow` | Optional styled arrow inside Popup. Targets its div. |
+| `Backdrop` | Optional upstream backdrop inside Portal. Targets its div. |
+| `Viewport` | Optional transition container for changing content. Targets its div. |
+| `Title` | Supplies a visible accessible name. Targets an h2. |
+| `Description` | Associates explanatory text. Targets a paragraph. |
+| `Close` | Requests closing. Targets a button. |
+
+All rendered parts support the installed Base UI native attributes, handlers, refs and element/function `render` composition. Custom components must forward the supplied props and ref. Every part has a public `Popover<Part>Props` and `Popover<Part>State` type. `PopoverRootProps` and `PopoverTriggerProps` preserve payload generics. `PopoverHandle`, `PopoverRootActions`, `PopoverRootChangeEventDetails` and `PopoverRootChangeEventReason` are also exported from `twenty-ui/primitives/surfaces`.
## Uncontrolled state
@@ -49,13 +59,18 @@ import { Popover } from 'twenty-ui/primitives/surfaces';
export const ImportHelp = () => (
<Popover.Root defaultOpen={false}>
<Popover.Trigger>Import help</Popover.Trigger>
- <Popover.Popup arrow>
- <Popover.Title>Import a CSV file</Popover.Title>
- <Popover.Description>
- Use a header row to identify your columns.
- </Popover.Description>
- <Popover.Close>Got it</Popover.Close>
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <Popover.Arrow />
+ <Popover.Title>Import a CSV file</Popover.Title>
+ <Popover.Description>
+ Use a header row to identify your columns.
+ </Popover.Description>
+ <Popover.Close>Got it</Popover.Close>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
);
```
@@ -76,13 +91,18 @@ export const ImportHelp = () => {
return (
<Popover.Root open={open} onOpenChange={setOpen}>
<Popover.Trigger>Import help</Popover.Trigger>
- <Popover.Popup arrow>
- <Popover.Title>Import a CSV file</Popover.Title>
- <Popover.Description>
- Use a header row to identify your columns.
- </Popover.Description>
- <Popover.Close>Got it</Popover.Close>
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <Popover.Arrow />
+ <Popover.Title>Import a CSV file</Popover.Title>
+ <Popover.Description>
+ Use a header row to identify your columns.
+ </Popover.Description>
+ <Popover.Close>Got it</Popover.Close>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
);
};
@@ -101,13 +121,18 @@ import { Popover } from 'twenty-ui/primitives/surfaces';
export const ImportHelp = () => (
<Popover.Root>
<Popover.Trigger render={<Button variant="outline">Import help</Button>} />
- <Popover.Popup arrow>
- <Popover.Title>Import a CSV file</Popover.Title>
- <Popover.Description>
- Use a header row to identify your columns.
- </Popover.Description>
- <Popover.Close render={<Button>Got it</Button>} />
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <Popover.Arrow />
+ <Popover.Title>Import a CSV file</Popover.Title>
+ <Popover.Description>
+ Use a header row to identify your columns.
+ </Popover.Description>
+ <Popover.Close render={<Button>Got it</Button>} />
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
);
```
@@ -116,9 +141,96 @@ export const ImportHelp = () => (
## Placement and focus
-`Popup` defaults to `side="bottom"`, `align="center"`, and `sideOffset={8}`. Set `arrow` to show an arrow. Set `container` to override the theme's portal container; see [theming](/ui/theming).
+`Positioner` defaults to `side="bottom"`, `align="center"` and `sideOffset={8}`. It accepts the full installed Base UI contract, including element/ref/function/virtual anchors, functional offsets, `positionMethod`, `collisionBoundary`, `collisionPadding`, `collisionAvoidance`, `arrowPadding`, `sticky` and `disableAnchorTracking`. DirectionProvider controls logical positioning and supplies the DOM direction. An explicit `dir` can override the native attribute; use the provider to change logical side placement.
+
+```tsx
+import { useRef } from 'react';
+import { Popover } from 'twenty-ui/primitives/surfaces';
+
+export const AnchoredHelp = () => {
+ const anchor = useRef<HTMLDivElement>(null);
+
+ return (
+ <div ref={anchor}>
+ <Popover.Root>
+ <Popover.Trigger>Help</Popover.Trigger>
+ <Popover.Portal>
+ <Popover.Positioner
+ anchor={anchor}
+ side="inline-end"
+ align="start"
+ sideOffset={({ anchor }) => anchor.width / 2}
+ collisionBoundary="clipping-ancestors"
+ collisionAvoidance={{ side: 'flip', align: 'shift' }}
+ collisionPadding={8}
+ positionMethod="fixed"
+ >
+ <Popover.Popup aria-label="Help">
+ <Popover.Arrow />
+ Contextual help
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ </div>
+ );
+};
+```
+
+Escape closes the popup and restores focus to its trigger. Outside interaction dismisses it by default. `Popup.initialFocus` and `Popup.finalFocus` accept the upstream focus targets and callbacks. `Root.modal` retains Base UI's nonmodal default, modal and trap-focus modes for standalone usage.
+
+## Portal destinations and theme
+
+Set `container` and `keepMounted` on `Portal`:
+
+| Container | Resolution |
+| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Omitted or `undefined` | Uses the nearest scoped ThemeProvider container. Without one, Base UI uses its parent portal or document body. |
+| `null` | Waits without rendering portal content until the container changes. It does not fall back to the theme or body. |
+| Element, ShadowRoot or ref | Passes the supplied target unchanged to Base UI. An unresolved ref retains Base UI's parent-portal/body fallback; use explicit null when waiting is required. |
+
+The default scoped destination preserves its CSS tokens and color scheme. An explicit destination inherits CSS from its actual DOM scope. Put it inside the intended theme scope, or supply the theme styles there. ShadowRoot targets need the library's CSS and theme styles in that shadow tree. React theme context and provided text direction remain available across portals. This API does not expand the renderer's permitted portal destinations.
+
+## Detached triggers and payloads
+
+`Popover.createHandle<TPayload>()` connects detached triggers to a root and exposes `open(triggerId)`, `close()` and `isOpen`. `Popover.Handle` is the installed upstream handle constructor. Root's render function receives the active payload. Call imperative actions from event handlers or effects.
+
+```tsx
+import { useState } from 'react';
+import { Popover } from 'twenty-ui/primitives/surfaces';
+
+export const OwnerHelp = () => {
+ const [handle] = useState(() => Popover.createHandle<{ name: string }>());
+
+ return (
+ <>
+ <Popover.Trigger handle={handle} id="owner" payload={{ name: 'Alice' }}>
+ Owner
+ </Popover.Trigger>
+ <Popover.Root handle={handle}>
+ {({ payload }) => (
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup aria-label="Account owner">
+ {payload?.name}
+ <Popover.Close>Close</Popover.Close>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ )}
+ </Popover.Root>
+ </>
+ );
+};
+```
+
+`onOpenChange` preserves `reason`, `event`, `trigger`, `cancel()` and `preventUnmountOnClose()`. Controlled roots retain `triggerId`; uncontrolled roots retain `defaultTriggerId`. `actionsRef` exposes the upstream close/unmount actions.
+
+## Migration
+
+Move `container` and `keepMounted` from Popup to Portal. Move placement, anchor and collision props to Positioner. Replace `Popup.arrow` with an explicit `Popover.Arrow` child. Popup's native props, handlers, focus props and ref continue to target the content element. Dropdown.Content keeps its existing convenient assembly.
-Escape closes the popup and focus returns to the trigger. Outside interaction dismisses it by default. Use the focus props on `Popup` when its content needs a specific initial or return focus target.
+Inside front components, use nonmodal composition within the existing scoped portal policy. Native browser popovers/dialogs and direct app-owned modality are prohibited; use the SDK host dialog API for dialogs. Renderer portal, geometry, scrolling and dismissal capability work remains separate from this primitive API.
## Props
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
index f312b41685e..ebc6b869522 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
@@ -9,6 +9,8 @@ so Dropdown-based popups never open there.
The field-controls fixture checks native input/textarea refs and change targets, typed textarea render composition, Field labels and controlled multiline value updates in React and Preact.
Textarea auto-resize growth and shrinking remain known renderer failures. Geometry reads use cached host snapshots, so resetting inline height and reading scrollHeight in the same turn cannot measure the updated layout. The growth failure also reproduces with main's unchanged Textarea. The fixture pins them with the existing known-failure helper; these assertions do not count as resize acceptance. Standalone Textarea browser checks pass.
+Popover composes Portal, Positioner, Popup, Arrow and Viewport. Its focused React/Preact cases check controlled trigger requests, native attributes, Button render composition, DOM refs and callback reasons. These checks do not establish popup visibility, geometry or dismissal support. The omitted-container popup still requires C04/C05/C07 renderer acceptance.
+
Typography composition checks constrained text, explicit links, semantic elements, refs and native focus handlers in both runtimes. Overflow tooltip popup acceptance still depends on renderer portal and geometry support.
Scenarios share their checks between runtimes where behavior matches. The story
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-popover.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-popover.front-component.tsx
index 8c232060776..d95c602a526 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-popover.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-popover.front-component.tsx
@@ -1,23 +1,63 @@
-import { useState } from 'react';
+import { useRef, useState } from 'react';
import { defineFrontComponent } from 'twenty-sdk/define';
-import { Popover } from 'twenty-ui/primitives/surfaces';
+import { Button } from 'twenty-ui/primitives/input';
+import {
+ Popover,
+ type PopoverRootChangeEventReason,
+} from 'twenty-ui/primitives/surfaces';
import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';
const PopoverExample = () => {
const [open, setOpen] = useState(false);
+ const [reason, setReason] = useState<PopoverRootChangeEventReason>('none');
+ const [triggerTarget, setTriggerTarget] = useState('');
+ const triggerRef = useRef<HTMLButtonElement>(null);
return (
<TwentyUiGalleryCard title="Popover">
- <Popover.Root open={open} onOpenChange={setOpen}>
- <Popover.Trigger>Account details</Popover.Trigger>
- <Popover.Popup>
- <Popover.Title>Account owner</Popover.Title>
- <Popover.Description>Alice manages this account</Popover.Description>
- <Popover.Close>Close details</Popover.Close>
- </Popover.Popup>
+ <Popover.Root
+ open={open}
+ onOpenChange={(nextOpen, details) => {
+ setOpen(nextOpen);
+ setReason(details.reason);
+ setTriggerTarget(
+ triggerRef.current?.getAttribute('data-native-trigger') ??
+ 'missing',
+ );
+ }}
+ >
+ <Popover.Trigger
+ ref={triggerRef}
+ data-native-trigger="account"
+ render={<Button variant="outline">Account details</Button>}
+ />
+ <Popover.Portal data-popover-portal="">
+ <Popover.Positioner
+ side="bottom"
+ align="start"
+ sideOffset={({ anchor }) => anchor.height / 4}
+ collisionAvoidance={{ side: 'flip', align: 'shift' }}
+ positionMethod="fixed"
+ data-popover-positioner=""
+ >
+ <Popover.Popup data-popover-popup="" render={<section />}>
+ <Popover.Arrow />
+ <Popover.Viewport>
+ <Popover.Title>Account owner</Popover.Title>
+ <Popover.Description>
+ Alice manages this account
+ </Popover.Description>
+ <Popover.Close render={<Button>Close details</Button>} />
+ </Popover.Viewport>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
- <p role="status">Details: {open ? 'open' : 'closed'}</p>
+ <p role="status">
+ Details: {open ? 'open' : 'closed'}; reason: {reason}; target:{' '}
+ {triggerTarget}
+ </p>
</TwentyUiGalleryCard>
);
};
@@ -25,6 +65,6 @@ const PopoverExample = () => {
export default defineFrontComponent({
universalIdentifier: '4d23e9af-7cb3-4e4a-bbca-8e960f840005',
name: 'twenty-ui-popover',
- description: 'Popover opening, portal content and dismissal in the sandbox',
+ description: 'Popover public parts and controlled trigger contract',
component: PopoverExample,
});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/popoverTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/popoverTest.ts
index 73ef7c808f4..2962bd85caa 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/popoverTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/popoverTest.ts
@@ -1,7 +1,28 @@
-import { createOverlayOpenTest } from '@/__stories__/twenty-ui-gallery/utils/createOverlayOpenTest';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
-export const popoverTest = createOverlayOpenTest({
- trigger: { role: 'button', name: 'Account details' },
- expectedOpenStatus: 'Details: open',
- popupText: 'Alice manages this account',
-});
+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const popoverTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ await expectFrontComponentMounted(canvas);
+ const trigger = canvas.getByRole('button', { name: 'Account details' });
+ expect(trigger).toHaveAttribute('data-native-trigger', 'account');
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.click(trigger);
+ await waitFor(() => expect(trigger).toHaveAttribute('aria-expanded', 'true'));
+ expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Details: open; reason: trigger-press; target: account',
+ );
+ await userEvent.click(trigger);
+ await waitFor(() =>
+ expect(trigger).toHaveAttribute('aria-expanded', 'false'),
+ );
+ expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Details: closed; reason: trigger-press; target: account',
+ );
+ expect(errorHandler).not.toHaveBeenCalled();
+};
diff --git a/packages/twenty-front/src/modules/front-components/media-session/components/FrontComponentMediaSessionIndicator.tsx b/packages/twenty-front/src/modules/front-components/media-session/components/FrontComponentMediaSessionIndicator.tsx
index 428ce2964a1..729d3a12aa1 100644
--- a/packages/twenty-front/src/modules/front-components/media-session/components/FrontComponentMediaSessionIndicator.tsx
+++ b/packages/twenty-front/src/modules/front-components/media-session/components/FrontComponentMediaSessionIndicator.tsx
@@ -84,21 +84,25 @@ export const FrontComponentMediaSessionIndicator = () => {
>
<StyledDot isCapturing={isCapturing} aria-hidden />
</Popover.Trigger>
- <Popover.Popup side="bottom" align="start" initialFocus={false}>
- <StyledContent>
- <Popover.Title>{title}</Popover.Title>
- <StyledApplications role="list" aria-label={title}>
- {Object.entries(sessionsByApplication).map(
- ([applicationId, sessions]) => (
- <FrontComponentMediaSessionTooltipRow
- key={applicationId}
- sessions={sessions}
- />
- ),
- )}
- </StyledApplications>
- </StyledContent>
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner side="bottom" align="start">
+ <Popover.Popup initialFocus={false}>
+ <StyledContent>
+ <Popover.Title>{title}</Popover.Title>
+ <StyledApplications role="list" aria-label={title}>
+ {Object.entries(sessionsByApplication).map(
+ ([applicationId, sessions]) => (
+ <FrontComponentMediaSessionTooltipRow
+ key={applicationId}
+ sessions={sessions}
+ />
+ ),
+ )}
+ </StyledApplications>
+ </StyledContent>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
);
};
diff --git a/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx b/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
index c0207506bc8..5163569fc45 100644
--- a/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
+++ b/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
@@ -248,12 +248,16 @@ export const OnboardingFreeCreditsPill = ({
<IconInfoCircle size={theme.icon.size.md} color="currentColor" />
</StyledInfoPart>
</Popover.Trigger>
- <Popover.Popup side="bottom" align="end" aria-label={t`Free credits`}>
- <OnboardingFreeCreditsPopoverContent
- earnedCredits={earnedCredits}
- earnedCreditsByStep={earnedCreditsByStep}
- />
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner side="bottom" align="end">
+ <Popover.Popup aria-label={t`Free credits`}>
+ <OnboardingFreeCreditsPopoverContent
+ earnedCredits={earnedCredits}
+ earnedCreditsByStep={earnedCreditsByStep}
+ />
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
</StyledPillAnchor>
<Tooltip.Root
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 318dbedd69a..9df27b8c454 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -69,6 +69,7 @@ import { SETTINGS_ROW_PROP_DESCRIPTIONS } from './settingsRowPropDescriptions';
import { STATUS_PROP_DESCRIPTIONS } from './statusPropDescriptions';
import { TAG_PROP_DESCRIPTIONS } from './tagPropDescriptions';
import { DIRECTION_PROVIDER_PROP_DESCRIPTIONS } from './directionProviderPropDescriptions';
+import { POPOVER_PART_PROP_DESCRIPTIONS } from './popoverPartPropDescriptions';
import { TOOLTIP_PART_PROP_DESCRIPTIONS } from './tooltipPartPropDescriptions';
import { TOOLTIP_PROP_DESCRIPTIONS } from './tooltipPropDescriptions';
import { VISUALLY_HIDDEN_PROP_DESCRIPTIONS } from './visuallyHiddenPropDescriptions';
@@ -477,6 +478,21 @@ export const DOCUMENTED_COMPONENTS = [
source: 'primitives/surfaces/Popover/Popover.tsx',
entryPoint: 'twenty-ui/primitives/surfaces',
slug: 'surfaces/popover',
+ parts: [
+ 'Root',
+ 'Trigger',
+ 'Portal',
+ 'Positioner',
+ 'Popup',
+ 'Arrow',
+ 'Backdrop',
+ 'Title',
+ 'Description',
+ 'Close',
+ 'Viewport',
+ ],
+ partPropDescriptions: POPOVER_PART_PROP_DESCRIPTIONS,
+ partPropDefaults: { Positioner: { sideOffset: '8' } },
},
{
name: 'Tooltip',
diff --git a/packages/twenty-ui/docs/dropdownPartPropDescriptions.ts b/packages/twenty-ui/docs/dropdownPartPropDescriptions.ts
index 9c269845d19..dff13f94f00 100644
--- a/packages/twenty-ui/docs/dropdownPartPropDescriptions.ts
+++ b/packages/twenty-ui/docs/dropdownPartPropDescriptions.ts
@@ -42,6 +42,15 @@ const DROPDOWN_ITEM_PROP_DESCRIPTIONS = {
export const DROPDOWN_PART_PROP_DESCRIPTIONS = {
Root: DROPDOWN_ROOT_PROP_DESCRIPTIONS,
Content: {
+ container:
+ 'Portal destination, using the scoped theme when omitted. Explicit null waits for a target, matching Popover.Portal.',
+ keepMounted: 'Keeps the popup mounted while closed.',
+ side: 'Preferred side of the anchor. Defaults to bottom, or inline-end in a submenu.',
+ align: 'Alignment along the anchor. Defaults to start.',
+ sideOffset:
+ 'Distance from the anchor. Defaults to 0. Accepts a number or positioning function.',
+ alignOffset:
+ 'Offset along the alignment axis. Accepts a number or positioning function.',
width: 'CSS width of the popup. Numbers are in pixels.',
} satisfies Partial<Record<keyof DropdownContentProps, string>>,
ActionItem: {
diff --git a/packages/twenty-ui/docs/popoverPartPropDescriptions.ts b/packages/twenty-ui/docs/popoverPartPropDescriptions.ts
new file mode 100644
index 00000000000..d6327e2a225
--- /dev/null
+++ b/packages/twenty-ui/docs/popoverPartPropDescriptions.ts
@@ -0,0 +1,28 @@
+export const POPOVER_PART_PROP_DESCRIPTIONS = {
+ Root: {
+ children:
+ 'Parts or a render function receiving the active trigger payload. Root renders no DOM element.',
+ handle: 'Connects detached triggers and imperative open/close actions.',
+ onOpenChange:
+ 'Receives the requested open state and Base UI event details, including reason, event, trigger, cancel() and preventUnmountOnClose().',
+ },
+ Portal: {
+ container:
+ 'When omitted, uses the scoped theme container, then the Base UI parent portal or document body. Explicit null delays rendering until a target is supplied. Explicit elements, ShadowRoots and refs are forwarded unchanged; their DOM scope supplies CSS tokens.',
+ ref: 'Ref to the portal div. Native props, handlers and render target this element.',
+ },
+ Positioner: {
+ sideOffset:
+ 'Distance from the anchor. Defaults to 8. Accepts a number or positioning function.',
+ ref: 'Ref to the positioning div. Accepts the complete Base UI anchor, collision and positioning contract.',
+ },
+ Popup: {
+ children: 'Popup content. Compose Portal, Positioner and Arrow separately.',
+ ref: 'Ref to the popup div. Focus props, native attributes, handlers and render target this element.',
+ },
+ Arrow: { ref: 'Ref to the arrow div. Compose inside Popup.' },
+ Backdrop: { ref: 'Ref to the optional backdrop div. Compose inside Portal.' },
+ Viewport: {
+ ref: 'Ref to the content-transition div for changing trigger payloads.',
+ },
+};
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 60e4447ea9c..cee5f65fdda 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -944,13 +944,33 @@
"MenuSubmenuTriggerProps": "primitives/surfaces/Menu/types/MenuSubmenuTriggerProps",
"MenuTriggerProps": "primitives/surfaces/Menu/types/MenuTriggerProps",
"PopoverAlign": "primitives/surfaces/Popover/types/PopoverAlign",
+ "PopoverArrowProps": "primitives/surfaces/Popover/types/PopoverArrowProps",
+ "PopoverArrowState": "primitives/surfaces/Popover/types/PopoverArrowState",
+ "PopoverBackdropProps": "primitives/surfaces/Popover/types/PopoverBackdropProps",
+ "PopoverBackdropState": "primitives/surfaces/Popover/types/PopoverBackdropState",
"PopoverCloseProps": "primitives/surfaces/Popover/types/PopoverCloseProps",
+ "PopoverCloseState": "primitives/surfaces/Popover/types/PopoverCloseState",
"PopoverDescriptionProps": "primitives/surfaces/Popover/types/PopoverDescriptionProps",
+ "PopoverDescriptionState": "primitives/surfaces/Popover/types/PopoverDescriptionState",
+ "PopoverHandle": "primitives/surfaces/Popover/types/PopoverHandle",
"PopoverPopupProps": "primitives/surfaces/Popover/types/PopoverPopupProps",
+ "PopoverPopupState": "primitives/surfaces/Popover/types/PopoverPopupState",
+ "PopoverPortalProps": "primitives/surfaces/Popover/types/PopoverPortalProps",
+ "PopoverPortalState": "primitives/surfaces/Popover/types/PopoverPortalState",
+ "PopoverPositionerProps": "primitives/surfaces/Popover/types/PopoverPositionerProps",
+ "PopoverPositionerState": "primitives/surfaces/Popover/types/PopoverPositionerState",
+ "PopoverRootActions": "primitives/surfaces/Popover/types/PopoverRootActions",
+ "PopoverRootChangeEventDetails": "primitives/surfaces/Popover/types/PopoverRootChangeEventDetails",
+ "PopoverRootChangeEventReason": "primitives/surfaces/Popover/types/PopoverRootChangeEventReason",
"PopoverRootProps": "primitives/surfaces/Popover/types/PopoverRootProps",
+ "PopoverRootState": "primitives/surfaces/Popover/types/PopoverRootState",
"PopoverSide": "primitives/surfaces/Popover/types/PopoverSide",
"PopoverTitleProps": "primitives/surfaces/Popover/types/PopoverTitleProps",
+ "PopoverTitleState": "primitives/surfaces/Popover/types/PopoverTitleState",
"PopoverTriggerProps": "primitives/surfaces/Popover/types/PopoverTriggerProps",
+ "PopoverTriggerState": "primitives/surfaces/Popover/types/PopoverTriggerState",
+ "PopoverViewportProps": "primitives/surfaces/Popover/types/PopoverViewportProps",
+ "PopoverViewportState": "primitives/surfaces/Popover/types/PopoverViewportState",
"TooltipAlign": "primitives/surfaces/Tooltip/types/TooltipAlign",
"TooltipArrowProps": "primitives/surfaces/Tooltip/types/TooltipArrowProps",
"TooltipArrowState": "primitives/surfaces/Tooltip/types/TooltipArrowState",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index d916c3b840b..89ec41df6e8 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -6965,7 +6965,7 @@
"type": "ReactNode | PayloadChildRenderFunction<Payload>",
"required": false,
"defaultValue": null,
- "description": "The content of the popover.\nThis can be a regular React node or a render function that receives the `payload` of the active trigger."
+ "description": "Parts or a render function receiving the active trigger payload. Root renders no DOM element."
},
{
"name": "defaultOpen",
@@ -6986,7 +6986,7 @@
"type": "PopoverHandle<Payload>",
"required": false,
"defaultValue": null,
- "description": "A handle to associate the popover with a trigger.\nIf specified, allows external triggers to control the popover's open state."
+ "description": "Connects detached triggers and imperative open/close actions."
},
{
"name": "modal",
@@ -7000,7 +7000,7 @@
"type": "((open: boolean, eventDetails: PopoverRootChangeEventDetails) => void)",
"required": false,
"defaultValue": null,
- "description": "Event handler called when the popover is opened or closed."
+ "description": "Receives the requested open state and Base UI event details, including reason, event, trigger, cancel() and preventUnmountOnClose()."
},
{
"name": "onOpenChangeComplete",
@@ -7101,56 +7101,185 @@
]
},
{
- "name": "Popup",
+ "name": "Portal",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: PopoverPortalState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "container",
+ "type": "HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null",
+ "required": false,
+ "defaultValue": null,
+ "description": "When omitted, uses the scoped theme container, then the Base UI parent portal or document body. Explicit null delays rendering until a target is supplied. Explicit elements, ShadowRoots and refs are forwarded unchanged; their DOM scope supplies CSS tokens."
+ },
+ {
+ "name": "keepMounted",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether to keep the portal mounted in the DOM while the popup is hidden."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the portal div. Native props, handlers and render target this element."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverPortalState>",
+ "required": false,
+ "defaultValue": null,
+ "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."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: PopoverPortalState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
+ },
+ {
+ "name": "Positioner",
"props": [
{
"name": "align",
"type": "\"center\" | \"end\" | \"start\"",
"required": false,
"defaultValue": "center",
- "description": "Alignment of the popup along the anchor."
+ "description": "How to align the popup relative to the specified side."
},
{
"name": "alignOffset",
"type": "number | OffsetFunction",
"required": false,
- "defaultValue": null,
- "description": "Offset in pixels along the alignment axis."
+ "defaultValue": "0",
+ "description": "Additional offset along the alignment axis in pixels.\nAlso accepts a function that returns the offset to read the dimensions of the anchor\nand positioner elements, along with its side and alignment.\n\nThe function takes a `data` object parameter with the following properties:\n- `data.anchor`: the dimensions of the anchor element with properties `width` and `height`.\n- `data.positioner`: the dimensions of the positioner element with properties `width` and `height`.\n- `data.side`: which side of the anchor element the positioner is aligned against.\n- `data.align`: how the positioner is aligned relative to the specified side."
},
{
"name": "anchor",
"type": "Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | null",
"required": false,
"defaultValue": null,
- "description": "Element or position the popup is anchored to. Defaults to the trigger."
+ "description": "An element to position the popup against.\nBy default, the popup will be positioned against the trigger."
},
{
- "name": "arrow",
- "type": "boolean",
+ "name": "arrowPadding",
+ "type": "number",
"required": false,
- "defaultValue": "false",
- "description": "Shows an arrow pointing at the anchor."
+ "defaultValue": "5",
+ "description": "Minimum distance to maintain between the arrow and the edges of the popup.\n\nUse it to prevent the arrow element from hanging out of the rounded corners of a popup."
},
{
"name": "className",
- "type": "string | ((state: PopoverPopupState) => string | undefined)",
+ "type": "string | ((state: PopoverPositionerState) => string | undefined)",
"required": false,
"defaultValue": null,
"description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
},
+ {
+ "name": "collisionAvoidance",
+ "type": "CollisionAvoidance",
+ "required": false,
+ "defaultValue": null,
+ "description": "Determines how to handle collisions when positioning the popup.\n\n`side` controls overflow on the preferred placement axis (`top`/`bottom` or `left`/`right`):\n- `'flip'`: keep the requested side when it fits; otherwise try the opposite side\n (`top` and `bottom`, or `left` and `right`).\n- `'shift'`: never change side; keep the requested side and move the popup within\n the clipping boundary so it stays visible.\n- `'none'`: do not correct side-axis overflow.\n\n`align` controls overflow on the alignment axis (`start`/`center`/`end`):\n- `'flip'`: keep side, but swap `start` and `end` when the requested alignment overflows.\n- `'shift'`: keep side and requested alignment, then nudge the popup along the\n alignment axis to fit.\n- `'none'`: do not correct alignment-axis overflow.\n\n`fallbackAxisSide` controls fallback behavior on the perpendicular axis when the\npreferred axis cannot fit:\n- `'start'`: allow perpendicular fallback and try the logical start side first\n (`top` before `bottom`, or `left` before `right` in LTR).\n- `'end'`: allow perpendicular fallback and try the logical end side first\n (`bottom` before `top`, or `right` before `left` in LTR).\n- `'none'`: do not fallback to the perpendicular axis.\n\nWhen `side` is `'shift'`, explicitly setting `align` only supports `'shift'` or `'none'`.\nIf `align` is omitted, it defaults to `'flip'`."
+ },
+ {
+ "name": "collisionBoundary",
+ "type": "Boundary",
+ "required": false,
+ "defaultValue": "clipping-ancestors",
+ "description": "An element or a rectangle that delimits the area that the popup is confined to."
+ },
{
"name": "collisionPadding",
"type": "Padding",
"required": false,
+ "defaultValue": "5",
+ "description": "Additional space to maintain from the edge of the collision boundary."
+ },
+ {
+ "name": "disableAnchorTracking",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether to disable the popup from tracking any layout shift of its positioning anchor."
+ },
+ {
+ "name": "positionMethod",
+ "type": "\"absolute\" | \"fixed\"",
+ "required": false,
+ "defaultValue": "absolute",
+ "description": "Determines which CSS `position` property to use."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
"defaultValue": null,
- "description": "Space in pixels kept between the popup and the edges of its collision\nboundary, for all sides or per side. Defaults to 5."
+ "description": "Ref to the positioning div. Accepts the complete Base UI anchor, collision and positioning contract."
},
{
- "name": "container",
- "type": "HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null",
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverPositionerState>",
"required": false,
"defaultValue": null,
- "description": "Element the popup is portaled into. Defaults to the theme's portal\ncontainer."
+ "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."
+ },
+ {
+ "name": "side",
+ "type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
+ "required": false,
+ "defaultValue": "bottom",
+ "description": "Which side of the anchor element to align the popup against.\nMay automatically change to avoid collisions."
+ },
+ {
+ "name": "sideOffset",
+ "type": "number | OffsetFunction",
+ "required": false,
+ "defaultValue": "8",
+ "description": "Distance from the anchor. Defaults to 8. Accepts a number or positioning function."
+ },
+ {
+ "name": "sticky",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether to maintain the popup in the viewport after\nthe anchor element was scrolled out of view."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: PopoverPositionerState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
+ },
+ {
+ "name": "Popup",
+ "props": [
+ {
+ "name": "children",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Popup content. Compose Portal, Positioner and Arrow separately."
+ },
+ {
+ "name": "className",
+ "type": "string | ((state: PopoverPopupState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
},
{
"name": "finalFocus",
@@ -7167,11 +7296,11 @@
"description": "Determines the element to focus when the popover is opened.\nBy default, focus moves to the first tabbable element inside the popup, except when the popover\nis opened by touch — then the popup itself is focused to avoid opening the virtual keyboard.\n\n- `false`: Do not move focus.\n- `true`: Move focus based on the default behavior (first tabbable element or popup).\n- `RefObject`: Move focus to the ref element.\n- `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`).\n Return an element to focus, `true` to use the default behavior, `null` to fall back to the default behavior, or `false`/`undefined` to do nothing."
},
{
- "name": "keepMounted",
- "type": "boolean",
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
"required": false,
"defaultValue": null,
- "description": "Keeps the popup mounted in the DOM while the popover is closed."
+ "description": "Ref to the popup div. Focus props, native attributes, handlers and render target this element."
},
{
"name": "render",
@@ -7181,22 +7310,74 @@
"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."
},
{
- "name": "side",
- "type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
+ "name": "style",
+ "type": "CSSProperties | ((state: PopoverPopupState) => CSSProperties | undefined)",
"required": false,
- "defaultValue": "bottom",
- "description": "Side of the anchor the popup is placed on."
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
+ },
+ {
+ "name": "Arrow",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: PopoverArrowState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
},
{
- "name": "sideOffset",
- "type": "number | OffsetFunction",
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
"required": false,
- "defaultValue": "8",
- "description": "Distance in pixels between the anchor and the popup."
+ "defaultValue": null,
+ "description": "Ref to the arrow div. Compose inside Popup."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverArrowState>",
+ "required": false,
+ "defaultValue": null,
+ "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."
},
{
"name": "style",
- "type": "CSSProperties | ((state: PopoverPopupState) => CSSProperties | undefined)",
+ "type": "CSSProperties | ((state: PopoverArrowState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
+ },
+ {
+ "name": "Backdrop",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: PopoverBackdropState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the optional backdrop div. Compose inside Portal."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverBackdropState>",
+ "required": false,
+ "defaultValue": null,
+ "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."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: PopoverBackdropState) => CSSProperties | undefined)",
"required": false,
"defaultValue": null,
"description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
@@ -7287,6 +7468,46 @@
"description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
}
]
+ },
+ {
+ "name": "Viewport",
+ "props": [
+ {
+ "name": "children",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "The content to render inside the transition container."
+ },
+ {
+ "name": "className",
+ "type": "string | ((state: PopoverViewportState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the content-transition div for changing trigger payloads."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverViewportState>",
+ "required": false,
+ "defaultValue": null,
+ "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."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: PopoverViewportState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
}
]
},
@@ -8977,21 +9198,21 @@
"type": "\"center\" | \"end\" | \"start\"",
"required": false,
"defaultValue": "start",
- "description": "Alignment of the popup along the anchor."
+ "description": "Alignment along the anchor. Defaults to start."
},
{
"name": "alignOffset",
"type": "number | OffsetFunction",
"required": false,
- "defaultValue": null,
- "description": "Offset in pixels along the alignment axis."
+ "defaultValue": "0",
+ "description": "Offset along the alignment axis. Accepts a number or positioning function."
},
{
"name": "anchor",
"type": "Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | null",
"required": false,
"defaultValue": null,
- "description": "Element or position the popup is anchored to. Defaults to the trigger."
+ "description": "An element to position the popup against.\nBy default, the popup will be positioned against the trigger."
},
{
"name": "className",
@@ -9004,15 +9225,15 @@
"name": "collisionPadding",
"type": "Padding",
"required": false,
- "defaultValue": null,
- "description": "Space in pixels kept between the popup and the edges of its collision\nboundary, for all sides or per side. Defaults to 5."
+ "defaultValue": "5",
+ "description": "Additional space to maintain from the edge of the collision boundary."
},
{
"name": "container",
"type": "HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null",
"required": false,
"defaultValue": null,
- "description": "Element the popup is portaled into. Defaults to the theme's portal\ncontainer."
+ "description": "Portal destination, using the scoped theme when omitted. Explicit null waits for a target, matching Popover.Portal."
},
{
"name": "finalFocus",
@@ -9032,8 +9253,8 @@
"name": "keepMounted",
"type": "boolean",
"required": false,
- "defaultValue": null,
- "description": "Keeps the popup mounted in the DOM while the popover is closed."
+ "defaultValue": "false",
+ "description": "Keeps the popup mounted while closed."
},
{
"name": "render",
@@ -9046,15 +9267,15 @@
"name": "side",
"type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
"required": false,
- "defaultValue": null,
- "description": "Side of the anchor the popup is placed on."
+ "defaultValue": "bottom",
+ "description": "Preferred side of the anchor. Defaults to bottom, or inline-end in a submenu."
},
{
"name": "sideOffset",
"type": "number | OffsetFunction",
"required": false,
"defaultValue": "0",
- "description": "Distance in pixels between the anchor and the popup."
+ "description": "Distance from the anchor. Defaults to 0. Accepts a number or positioning function."
},
{
"name": "style",
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.tsx
index 115af5a4d9d..fee37a10831 100644
--- a/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.tsx
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.tsx
@@ -135,18 +135,23 @@ export const OverflowingList = ({
+{hiddenItemCount}
</Popover.Trigger>
)}
- <Popover.Popup
- anchor={containerRef}
- align="start"
- sideOffset={-9}
- alignOffset={-7}
- aria-label={overflowLabel}
- className={styles.popup}
- data-overflowing-list-popup=""
- {...STOP_PROPAGATION_PROPS}
- >
- {children}
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner
+ anchor={containerRef}
+ align="start"
+ sideOffset={-9}
+ alignOffset={-7}
+ >
+ <Popover.Popup
+ aria-label={overflowLabel}
+ className={styles.popup}
+ data-overflowing-list-popup=""
+ {...STOP_PROPAGATION_PROPS}
+ >
+ {children}
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</div>
</Popover.Root>
);
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownContent.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownContent.tsx
index 4a3545880fc..5ae72d1d65d 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownContent.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownContent.tsx
@@ -22,6 +22,7 @@ export const DropdownContent = ({
sideOffset = 0,
alignOffset,
anchor,
+ collisionPadding,
container,
keepMounted,
width = 200,
@@ -63,71 +64,77 @@ export const DropdownContent = ({
return (
<>
- <Popover.Popup
- {...props}
- ref={mergedRef}
- side={side ?? (isSubmenu ? 'inline-end' : 'bottom')}
- align={align}
- sideOffset={sideOffset}
- alignOffset={alignOffset}
- anchor={anchor}
- container={container}
- keepMounted={keepMounted}
- role={type === 'menu' ? 'menu' : 'dialog'}
- aria-label={ariaLabel}
- aria-labelledby={ariaLabelledBy ?? defaultAriaLabelledBy}
- data-dropdown-content=""
- data-type={type}
- className={mergeClassNames(styles.content, className)}
- style={(state) => ({
- width,
- ...(isFunction(style) ? style(state) : style),
- })}
- initialFocus={
- initialFocus ??
- (() => {
- if (!focusOnOpen) {
- return false;
- }
+ <Popover.Portal container={container} keepMounted={keepMounted}>
+ <Popover.Positioner
+ side={side ?? (isSubmenu ? 'inline-end' : 'bottom')}
+ align={align}
+ sideOffset={sideOffset}
+ alignOffset={alignOffset}
+ anchor={anchor}
+ collisionPadding={collisionPadding}
+ >
+ <Popover.Popup
+ {...props}
+ ref={mergedRef}
+ role={type === 'menu' ? 'menu' : 'dialog'}
+ aria-label={ariaLabel}
+ aria-labelledby={ariaLabelledBy ?? defaultAriaLabelledBy}
+ data-dropdown-content=""
+ data-type={type}
+ className={mergeClassNames(styles.content, className)}
+ style={(state) => ({
+ width,
+ ...(isFunction(style) ? style(state) : style),
+ })}
+ initialFocus={
+ initialFocus ??
+ (() => {
+ if (!focusOnOpen) {
+ return false;
+ }
- if (!isDefined(contentRef.current)) {
- return true;
- }
+ if (!isDefined(contentRef.current)) {
+ return true;
+ }
- return getDropdownFocusTarget({
- content: contentRef.current,
- edge: initialFocusEdge,
- type,
- });
- })
- }
- onKeyDown={(event) => {
- onKeyDown?.(event);
- handleNavigation(event);
+ return getDropdownFocusTarget({
+ content: contentRef.current,
+ edge: initialFocusEdge,
+ type,
+ });
+ })
+ }
+ onKeyDown={(event) => {
+ onKeyDown?.(event);
+ handleNavigation(event);
- if (!isUnhandledModifierShortcut(event)) {
- event.stopPropagation();
- }
- }}
- onInput={(event) => {
- onInput?.(event);
- setSearchTargetId(getDropdownSearchTarget(event.currentTarget)?.id);
- }}
- onClick={(event) => {
- event.stopPropagation();
- onClick?.(event);
- }}
- onMouseDown={(event) => {
- event.stopPropagation();
- onMouseDown?.(event);
- }}
- onPointerDown={(event) => {
- event.stopPropagation();
- onPointerDown?.(event);
- }}
- >
- {children}
- </Popover.Popup>
+ if (!isUnhandledModifierShortcut(event)) {
+ event.stopPropagation();
+ }
+ }}
+ onInput={(event) => {
+ onInput?.(event);
+ setSearchTargetId(
+ getDropdownSearchTarget(event.currentTarget)?.id,
+ );
+ }}
+ onClick={(event) => {
+ event.stopPropagation();
+ onClick?.(event);
+ }}
+ onMouseDown={(event) => {
+ event.stopPropagation();
+ onMouseDown?.(event);
+ }}
+ onPointerDown={(event) => {
+ event.stopPropagation();
+ onPointerDown?.(event);
+ }}
+ >
+ {children}
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
<DropdownPageFocusEffect contentRef={contentRef} />
<DropdownSearchTargetEffect content={content} />
</>
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/types/DropdownContentProps.ts b/packages/twenty-ui/src/components/navigation/Dropdown/types/DropdownContentProps.ts
index b22cf7305af..010465828b5 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/types/DropdownContentProps.ts
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/types/DropdownContentProps.ts
@@ -1,7 +1,19 @@
import { type CSSProperties } from 'react';
import { type PopoverPopupProps } from '@ui/primitives/surfaces/Popover/types/PopoverPopupProps';
+import { type PopoverPortalProps } from '@ui/primitives/surfaces/Popover/types/PopoverPortalProps';
+import { type PopoverPositionerProps } from '@ui/primitives/surfaces/Popover/types/PopoverPositionerProps';
-export type DropdownContentProps = Omit<PopoverPopupProps, 'arrow'> & {
- width?: CSSProperties['width'];
-};
+export type DropdownContentProps = PopoverPopupProps &
+ Pick<PopoverPortalProps, 'container' | 'keepMounted'> &
+ Pick<
+ PopoverPositionerProps,
+ | 'side'
+ | 'align'
+ | 'sideOffset'
+ | 'alignOffset'
+ | 'anchor'
+ | 'collisionPadding'
+ > & {
+ width?: CSSProperties['width'];
+ };
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/Popover.tsx b/packages/twenty-ui/src/primitives/surfaces/Popover/Popover.tsx
index 0296ccb7ada..479d23ca60d 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Popover/Popover.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/Popover.tsx
@@ -1,14 +1,24 @@
import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
+import { PopoverArrow } from './internal/PopoverArrow';
import { PopoverDescription } from './internal/PopoverDescription';
import { PopoverPopup } from './internal/PopoverPopup';
+import { PopoverPortal } from './internal/PopoverPortal';
+import { PopoverPositioner } from './internal/PopoverPositioner';
import { PopoverTitle } from './internal/PopoverTitle';
export const Popover = {
Root: PopoverPrimitive.Root,
Trigger: PopoverPrimitive.Trigger,
+ Portal: PopoverPortal,
+ Positioner: PopoverPositioner,
Popup: PopoverPopup,
+ Arrow: PopoverArrow,
+ Backdrop: PopoverPrimitive.Backdrop,
Title: PopoverTitle,
Description: PopoverDescription,
Close: PopoverPrimitive.Close,
+ Viewport: PopoverPrimitive.Viewport,
+ Handle: PopoverPrimitive.Handle,
+ createHandle: PopoverPrimitive.createHandle,
};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/__stories__/Popover.stories.tsx b/packages/twenty-ui/src/primitives/surfaces/Popover/__stories__/Popover.stories.tsx
index 6f764c13a2a..39aca9d77cb 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Popover/__stories__/Popover.stories.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/__stories__/Popover.stories.tsx
@@ -13,15 +13,14 @@ import {
import { ThemeProvider } from '@ui/theme/ThemeProvider';
import { Popover } from '../Popover';
-import { type PopoverPopupProps } from '../types/PopoverPopupProps';
+import { type PopoverPortalProps } from '../types/PopoverPortalProps';
+import { type PopoverPositionerProps } from '../types/PopoverPositionerProps';
import { type PopoverRootProps } from '../types/PopoverRootProps';
import { type PopoverSide } from '../types/PopoverSide';
type PopoverStoryProps = PopoverRootProps &
- Pick<
- PopoverPopupProps,
- 'side' | 'align' | 'arrow' | 'keepMounted' | 'container'
- >;
+ Pick<PopoverPositionerProps, 'side' | 'align'> &
+ Pick<PopoverPortalProps, 'keepMounted' | 'container'> & { arrow?: boolean };
const PopoverStory = ({
side,
@@ -38,23 +37,24 @@ const PopoverStory = ({
style={{ alignSelf: 'flex-start', marginInline: 'auto' }}
render={<Button>Open</Button>}
/>
- <Popover.Popup
- side={side}
- align={align}
- arrow={arrow}
- keepMounted={keepMounted}
- container={container}
- >
- <Popover.Title>Details</Popover.Title>
- <Popover.Description>More information</Popover.Description>
- <Button type="button" aria-label="First action">
- First action
- </Button>
- <Popover.Close
- style={{ alignSelf: 'flex-start' }}
- render={<Button aria-label="Close" size="sm" startIcon={<IconX />} />}
- />
- </Popover.Popup>
+ <Popover.Portal container={container} keepMounted={keepMounted}>
+ <Popover.Positioner side={side} align={align}>
+ <Popover.Popup>
+ {arrow && <Popover.Arrow />}
+ <Popover.Title>Details</Popover.Title>
+ <Popover.Description>More information</Popover.Description>
+ <Button type="button" aria-label="First action">
+ First action
+ </Button>
+ <Popover.Close
+ style={{ alignSelf: 'flex-start' }}
+ render={
+ <Button aria-label="Close" size="sm" startIcon={<IconX />} />
+ }
+ />
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
<Button type="button" aria-label="Outside">
Outside
@@ -138,13 +138,17 @@ export const Documentation: Story = {
style={{ alignSelf: 'flex-start' }}
render={<Button>Show details</Button>}
/>
- <Popover.Popup>
- <Popover.Title>Contact details</Popover.Title>
- <Popover.Description>
- Add notes and contact information here.
- </Popover.Description>
- <Popover.Close aria-label="Close" render={<Button>Close</Button>} />
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <Popover.Title>Contact details</Popover.Title>
+ <Popover.Description>
+ Add notes and contact information here.
+ </Popover.Description>
+ <Popover.Close aria-label="Close" render={<Button>Close</Button>} />
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
),
};
@@ -327,9 +331,13 @@ export const WithoutTabbableContent: Story = {
render: (args) => (
<Popover.Root {...args}>
<Popover.Trigger aria-label="Open" render={<Button>Open</Button>} />
- <Popover.Popup>
- <Popover.Title>Details</Popover.Title>
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <Popover.Title>Details</Popover.Title>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
),
play: async ({ canvasElement }) => {
@@ -446,14 +454,20 @@ const PopoverCatalogCell = ({ side = 'bottom', arrow }: PopoverStoryProps) => {
>
<Popover.Root open modal={false}>
<Popover.Trigger
+ render={<Button />}
aria-label={`Open ${side} popover ${arrow ? 'with' : 'without'} arrow`}
>
Open
</Popover.Trigger>
- <Popover.Popup container={cellElement} side={side} arrow={arrow}>
- <Popover.Title>Details</Popover.Title>
- <Popover.Description>More information</Popover.Description>
- </Popover.Popup>
+ <Popover.Portal container={cellElement}>
+ <Popover.Positioner side={side}>
+ <Popover.Popup>
+ {arrow && <Popover.Arrow />}
+ <Popover.Title>Details</Popover.Title>
+ <Popover.Description>More information</Popover.Description>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
</div>
);
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/__stories__/PopoverParts.stories.tsx b/packages/twenty-ui/src/primitives/surfaces/Popover/__stories__/PopoverParts.stories.tsx
new file mode 100644
index 00000000000..12cce567f72
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/__stories__/PopoverParts.stories.tsx
@@ -0,0 +1,306 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useRef, useState } from 'react';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { Button } from '@ui/primitives/input/Button/Button';
+import { DirectionProvider } from '@ui/primitives/layout/DirectionProvider/DirectionProvider';
+import { Card } from '@ui/primitives/surfaces/Card/Card';
+import { ComponentDecorator } from '@ui/testing';
+import { ThemeProvider } from '@ui/theme/ThemeProvider';
+
+import { Popover } from '../Popover';
+
+const meta: Meta = {
+ title: 'UI/Surfaces/Popover/Parts',
+ decorators: [ComponentDecorator],
+};
+
+export default meta;
+type Story = StoryObj;
+
+const NativePartsExample = () => {
+ const portalRef = useRef<HTMLDivElement>(null);
+ const positionerRef = useRef<HTMLDivElement>(null);
+ const popupRef = useRef<HTMLDivElement>(null);
+ const arrowRef = useRef<HTMLDivElement>(null);
+ const viewportRef = useRef<HTMLDivElement>(null);
+ const [targets, setTargets] = useState('');
+
+ return (
+ <Popover.Root defaultOpen>
+ <Popover.Trigger render={<Button>Inspect parts</Button>} />
+ <Popover.Portal ref={portalRef} data-part="portal" render={<section />}>
+ <Popover.Positioner
+ ref={positionerRef}
+ data-part="positioner"
+ className={({ open }) => (open ? 'open-positioner' : '')}
+ style={({ side }) => ({ marginTop: side === 'bottom' ? 3 : 0 })}
+ render={(props, state) => (
+ <section {...props} data-open={state.open} />
+ )}
+ >
+ <Popover.Popup ref={popupRef} data-part="popup" render={<article />}>
+ <Popover.Arrow ref={arrowRef} data-part="arrow" render={<span />} />
+ <Popover.Viewport ref={viewportRef} render={<section />}>
+ <Popover.Title>Part targets</Popover.Title>
+ <Popover.Description>
+ Each ref targets its own element.
+ </Popover.Description>
+ <Button
+ onClick={() =>
+ setTargets(
+ [
+ portalRef.current?.localName,
+ positionerRef.current?.localName,
+ popupRef.current?.localName,
+ arrowRef.current?.localName,
+ viewportRef.current?.localName,
+ ].join(', '),
+ )
+ }
+ >
+ Read refs
+ </Button>
+ <Text render={<output />}>{targets}</Text>
+ <Popover.Close render={<Button>Close</Button>} />
+ </Popover.Viewport>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ );
+};
+
+export const NativeParts: Story = {
+ render: () => <NativePartsExample />,
+ play: async ({ canvasElement }) => {
+ const page = within(canvasElement.ownerDocument.body);
+ const popup = await page.findByRole('dialog', { name: 'Part targets' });
+ await waitFor(() => expect(popup).toBeVisible());
+ expect(popup.tagName).toBe('ARTICLE');
+ const positioner = popup.parentElement;
+ expect(positioner).toHaveAttribute('data-part', 'positioner');
+ expect(positioner).toHaveAttribute('data-open', 'true');
+ expect(positioner).toHaveClass('open-positioner');
+ expect(positioner).toHaveStyle({ marginTop: '3px' });
+ expect(positioner?.parentElement).toHaveAttribute('data-part', 'portal');
+ await userEvent.click(page.getByRole('button', { name: 'Read refs' }));
+ expect(page.getByRole('status')).toHaveTextContent(
+ 'section, section, article, span, section',
+ );
+ await userEvent.click(page.getByRole('button', { name: 'Close' }));
+ await waitFor(() =>
+ expect(page.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ },
+};
+
+const AdvancedAnchorExample = () => {
+ const [avoidCollisions, setAvoidCollisions] = useState(false);
+
+ return (
+ <>
+ <Button onClick={() => setAvoidCollisions(true)}>Avoid collisions</Button>
+ <Popover.Root open>
+ <Popover.Portal>
+ <Popover.Positioner
+ anchor={() => ({
+ getBoundingClientRect: () => new DOMRect(280, 240, 40, 24),
+ })}
+ positionMethod="fixed"
+ side="bottom"
+ align="start"
+ sideOffset={({ anchor }) => anchor.height / 2}
+ alignOffset={({ anchor }) => anchor.width / 4}
+ collisionBoundary={{ x: 120, y: 100, width: 240, height: 190 }}
+ collisionPadding={10}
+ collisionAvoidance={{
+ side: avoidCollisions ? 'flip' : 'none',
+ align: 'shift',
+ }}
+ arrowPadding={12}
+ sticky={false}
+ disableAnchorTracking
+ >
+ <Popover.Popup
+ aria-label="Advanced anchor"
+ style={{ width: 120, height: 60, boxSizing: 'border-box' }}
+ >
+ <Popover.Arrow />
+ <Text>Virtual anchor</Text>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ </>
+ );
+};
+
+export const AdvancedAnchor: Story = {
+ render: () => <AdvancedAnchorExample />,
+ play: async ({ canvasElement }) => {
+ const page = within(canvasElement.ownerDocument.body);
+ const popup = await page.findByRole('dialog', { name: 'Advanced anchor' });
+ const positioner = popup.parentElement;
+ await waitFor(() => {
+ expect(popup).toBeVisible();
+ expect(positioner).toHaveStyle({ position: 'fixed' });
+ expect(positioner?.getBoundingClientRect().top).toBeCloseTo(276, 0);
+ });
+ await userEvent.click(
+ within(canvasElement).getByRole('button', { name: 'Avoid collisions' }),
+ );
+ await waitFor(() => {
+ expect(popup).toHaveAttribute('data-side', 'top');
+ const rectangle = popup.getBoundingClientRect();
+ expect(rectangle.left).toBeGreaterThanOrEqual(130);
+ expect(rectangle.right).toBeLessThanOrEqual(350);
+ expect(rectangle.bottom).toBeCloseTo(228, 0);
+ });
+ },
+};
+
+const ScopedDestinationsExample = () => {
+ const [container, setContainer] = useState<HTMLDivElement | null>(null);
+ const [destination, setDestination] = useState<
+ 'omitted' | 'waiting' | 'explicit'
+ >('omitted');
+
+ return (
+ <DirectionProvider direction="rtl">
+ <ThemeProvider
+ colorScheme="dark"
+ applyToRoot={false}
+ overrides={{ '--t-font-color-primary': 'rgb(220, 230, 240)' }}
+ >
+ <Card.Root
+ style={{ background: 'var(--t-background-primary)', padding: 24 }}
+ >
+ <Button onClick={() => setDestination('waiting')}>
+ Wait for target
+ </Button>
+ <Button onClick={() => setDestination('explicit')}>
+ Use explicit target
+ </Button>
+ <div
+ ref={setContainer}
+ role="region"
+ aria-label="Explicit themed target"
+ />
+ <Popover.Root open>
+ <Popover.Trigger render={<Button>Scoped anchor</Button>} />
+ <Popover.Portal
+ container={
+ destination === 'omitted'
+ ? undefined
+ : destination === 'waiting'
+ ? null
+ : container
+ }
+ >
+ <Popover.Positioner
+ side="inline-start"
+ collisionAvoidance={{ side: 'none', align: 'none' }}
+ >
+ <Popover.Popup
+ aria-label="Scoped details"
+ style={{ background: 'var(--t-background-primary)' }}
+ >
+ <Text>Themed content</Text>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ </Card.Root>
+ </ThemeProvider>
+ </DirectionProvider>
+ );
+};
+
+export const ScopedDestinations: Story = {
+ render: () => <ScopedDestinationsExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ const popup = await page.findByRole('dialog', { name: 'Scoped details' });
+ await waitFor(() => expect(popup).toBeVisible());
+ expect(canvasElement).toContainElement(popup);
+ expect(popup).toHaveStyle({ color: 'rgb(220, 230, 240)' });
+ expect(popup.parentElement).toHaveAttribute('dir', 'rtl');
+ expect(popup).toHaveAttribute('data-side', 'inline-start');
+ const anchor = canvas.getByRole('button', { name: 'Scoped anchor' });
+ await waitFor(() =>
+ expect(popup.getBoundingClientRect().left).toBeCloseTo(
+ anchor.getBoundingClientRect().right + 8,
+ 0,
+ ),
+ );
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Wait for target' }),
+ );
+ await waitFor(() =>
+ expect(page.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Use explicit target' }),
+ );
+ const target = canvas.getByRole('region', {
+ name: 'Explicit themed target',
+ });
+ const relocatedPopup = await within(target).findByRole('dialog');
+ await waitFor(() => expect(relocatedPopup).toBeVisible());
+ expect(relocatedPopup).toHaveStyle({ color: 'rgb(220, 230, 240)' });
+ expect(relocatedPopup.parentElement).toHaveAttribute('dir', 'rtl');
+ },
+};
+
+const FocusTargetsExample = () => {
+ const firstActionRef = useRef<HTMLButtonElement>(null);
+ const returnRef = useRef<HTMLButtonElement>(null);
+
+ return (
+ <>
+ <Popover.Root>
+ <Popover.Trigger render={<Button>Open focus targets</Button>} />
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup
+ aria-label="Focus targets"
+ initialFocus={firstActionRef}
+ finalFocus={returnRef}
+ >
+ <Button>Other action</Button>
+ <Button ref={firstActionRef}>Initial action</Button>
+ <Popover.Close render={<Button>Close focus targets</Button>} />
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ <Button ref={returnRef}>Return here</Button>
+ </>
+ );
+};
+
+export const FocusTargets: Story = {
+ render: () => <FocusTargetsExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Open focus targets' }),
+ );
+ await waitFor(() =>
+ expect(
+ page.getByRole('button', { name: 'Initial action' }),
+ ).toHaveFocus(),
+ );
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(page.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ await waitFor(() =>
+ expect(canvas.getByRole('button', { name: 'Return here' })).toHaveFocus(),
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/__tests__/Popover.test.tsx b/packages/twenty-ui/src/primitives/surfaces/Popover/__tests__/Popover.test.tsx
index 1eb936e45b6..9ec8f467539 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Popover/__tests__/Popover.test.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/__tests__/Popover.test.tsx
@@ -1,4 +1,9 @@
-import { type ReactNode } from 'react';
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { createRef, type ReactNode } from 'react';
+import { describe, expect, it, vi } from 'vitest';
+
+import { ThemeProvider } from '@ui/theme/ThemeProvider';
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
@@ -9,12 +14,16 @@ const PopoverRootWrapper = ({ children }: { children: ReactNode }) => (
<Popover.Root>{children}</Popover.Root>
);
const OpenPopoverWrapper = ({ children }: { children: ReactNode }) => (
- <Popover.Root open>{children}</Popover.Root>
+ <Popover.Root open>
+ <Popover.Portal>
+ <Popover.Positioner>{children}</Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
);
const PopoverPopupWrapper = ({ children }: { children: ReactNode }) => (
- <Popover.Root open>
+ <OpenPopoverWrapper>
<Popover.Popup>{children}</Popover.Popup>
- </Popover.Root>
+ </OpenPopoverWrapper>
);
runComponentConformance({
@@ -52,3 +61,183 @@ runComponentConformance({
wrapper: PopoverPopupWrapper,
renderPropTagName: 'button',
});
+
+runComponentConformance({
+ name: 'Popover.Portal',
+ element: <Popover.Portal />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: ({ children }) => <Popover.Root open>{children}</Popover.Root>,
+});
+runComponentConformance({
+ name: 'Popover.Positioner',
+ element: <Popover.Positioner />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: ({ children }) => (
+ <Popover.Root open>
+ <Popover.Portal>{children}</Popover.Portal>
+ </Popover.Root>
+ ),
+ ownClassName: styles.positioner,
+});
+runComponentConformance({
+ name: 'Popover.Arrow',
+ element: <Popover.Arrow />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: PopoverPopupWrapper,
+ ownClassName: styles.arrow,
+});
+runComponentConformance({
+ name: 'Popover.Backdrop',
+ element: <Popover.Backdrop />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: ({ children }) => (
+ <Popover.Root open>
+ <Popover.Portal>{children}</Popover.Portal>
+ </Popover.Root>
+ ),
+});
+runComponentConformance({
+ name: 'Popover.Viewport',
+ element: <Popover.Viewport />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: PopoverPopupWrapper,
+});
+
+describe('Popover portal destinations', () => {
+ it('uses the scoped theme when omitted and waits when explicitly null', async () => {
+ const content = (container?: HTMLElement | null) => (
+ <ThemeProvider colorScheme="dark" applyToRoot={false}>
+ <Popover.Root open>
+ <Popover.Portal container={container}>
+ <Popover.Positioner>
+ <Popover.Popup aria-label="Details" />
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ </ThemeProvider>
+ );
+ const { container, rerender } = render(content());
+ const scope = container.querySelector('.dark');
+ expect(scope).toContainElement(await screen.findByRole('dialog'));
+
+ rerender(content(null));
+ await waitFor(() =>
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+
+ rerender(content());
+ expect(scope).toContainElement(await screen.findByRole('dialog'));
+ });
+
+ it('forwards element and ref targets and retargets without a body fallback', async () => {
+ const target = document.createElement('div');
+ const nextTarget = document.createElement('div');
+ document.body.append(target, nextTarget);
+ const targetRef = createRef<HTMLDivElement>();
+ targetRef.current = nextTarget;
+ const content = (container: HTMLElement | typeof targetRef | null) => (
+ <Popover.Root open>
+ <Popover.Portal container={container}>
+ <Popover.Positioner>
+ <Popover.Popup aria-label="Details" />
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ );
+ const { rerender, unmount } = render(content(target));
+ expect(target).toContainElement(await screen.findByRole('dialog'));
+ rerender(content(targetRef));
+ expect(nextTarget).toContainElement(await screen.findByRole('dialog'));
+ expect(target).toBeEmptyDOMElement();
+ rerender(content(null));
+ await waitFor(() => expect(nextTarget).toBeEmptyDOMElement());
+ unmount();
+ target.remove();
+ nextTarget.remove();
+ });
+
+ it('accepts a ShadowRoot without replacing its target', async () => {
+ const host = document.createElement('div');
+ document.body.append(host);
+ const shadowRoot = host.attachShadow({ mode: 'open' });
+ const { unmount } = render(
+ <Popover.Root open>
+ <Popover.Portal container={shadowRoot}>
+ <Popover.Positioner>
+ <Popover.Popup aria-label="Shadow details" />
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>,
+ );
+ await waitFor(() =>
+ expect(shadowRoot.querySelector('[role="dialog"]')).toHaveAttribute(
+ 'aria-label',
+ 'Shadow details',
+ ),
+ );
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
+ unmount();
+ expect(shadowRoot.childNodes).toHaveLength(0);
+ host.remove();
+ });
+});
+
+describe('Popover root contracts', () => {
+ it('preserves typed detached payloads, cancellation and imperative actions', async () => {
+ const user = userEvent.setup();
+ const handle = Popover.createHandle<{ name: string }>();
+ const onOpenChange = vi.fn();
+ render(
+ <>
+ <Popover.Trigger
+ handle={handle}
+ id="account"
+ payload={{ name: 'Alice' }}
+ >
+ Account
+ </Popover.Trigger>
+ <Popover.Root
+ handle={handle}
+ onOpenChange={(open, details) => {
+ onOpenChange(open, details);
+ if (details.reason === 'close-press') {
+ details.cancel();
+ }
+ }}
+ >
+ {({ payload }) => (
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup aria-label="Owner">
+ {payload?.name}
+ <Popover.Close>Close</Popover.Close>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ )}
+ </Popover.Root>
+ <button onClick={() => handle.close()}>Apply close</button>
+ </>,
+ );
+ await user.click(screen.getByRole('button', { name: 'Account' }));
+ expect(await screen.findByRole('dialog')).toHaveTextContent('Alice');
+ expect(onOpenChange).toHaveBeenLastCalledWith(
+ true,
+ expect.objectContaining({
+ reason: 'trigger-press',
+ trigger: screen.getByRole('button', { name: 'Account' }),
+ event: expect.any(Event),
+ }),
+ );
+ await user.click(screen.getByRole('button', { name: 'Close' }));
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
+ await user.click(screen.getByRole('button', { name: 'Apply close' }));
+ await waitFor(() =>
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ expect(onOpenChange).toHaveBeenCalledWith(
+ false,
+ expect.objectContaining({ reason: 'imperative-action' }),
+ );
+ });
+});
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverArrow.tsx b/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverArrow.tsx
new file mode 100644
index 00000000000..c50b373c9b8
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverArrow.tsx
@@ -0,0 +1,13 @@
+import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+
+import styles from '../Popover.module.scss';
+import { type PopoverArrowProps } from '../types/PopoverArrowProps';
+
+export const PopoverArrow = ({ className, ...props }: PopoverArrowProps) => (
+ <PopoverPrimitive.Arrow
+ {...props}
+ className={mergeClassNames(styles.arrow, className)}
+ />
+);
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPopup.tsx b/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPopup.tsx
index f421b389267..da0df113695 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPopup.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPopup.tsx
@@ -1,52 +1,13 @@
import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
-import { useProvidedTextDirection } from '@ui/primitives/layout/DirectionProvider/internal/useProvidedTextDirection';
-import { useThemeContainer } from '@ui/theme';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
import styles from '../Popover.module.scss';
import { type PopoverPopupProps } from '../types/PopoverPopupProps';
-export const PopoverPopup = ({
- side = 'bottom',
- align = 'center',
- sideOffset = 8,
- alignOffset,
- arrow = false,
- anchor,
- collisionPadding,
- container,
- keepMounted,
- className,
- children,
- ...props
-}: PopoverPopupProps) => {
- const themeContainer = useThemeContainer();
- const direction = useProvidedTextDirection();
-
- return (
- <PopoverPrimitive.Portal
- container={container ?? themeContainer ?? undefined}
- keepMounted={keepMounted}
- >
- <PopoverPrimitive.Positioner
- dir={direction}
- side={side}
- align={align}
- sideOffset={sideOffset}
- alignOffset={alignOffset}
- anchor={anchor}
- collisionPadding={collisionPadding}
- className={styles.positioner}
- >
- <PopoverPrimitive.Popup
- {...props}
- className={mergeClassNames(styles.popup, className)}
- >
- {arrow && <PopoverPrimitive.Arrow className={styles.arrow} />}
- {children}
- </PopoverPrimitive.Popup>
- </PopoverPrimitive.Positioner>
- </PopoverPrimitive.Portal>
- );
-};
+export const PopoverPopup = ({ className, ...props }: PopoverPopupProps) => (
+ <PopoverPrimitive.Popup
+ {...props}
+ className={mergeClassNames(styles.popup, className)}
+ />
+);
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPortal.tsx b/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPortal.tsx
new file mode 100644
index 00000000000..3a8c627f1fe
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPortal.tsx
@@ -0,0 +1,22 @@
+import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
+import { isUndefined } from '@sniptt/guards';
+
+import { useProvidedTextDirection } from '@ui/primitives/layout/DirectionProvider/internal/useProvidedTextDirection';
+import { useThemeContainer } from '@ui/theme';
+
+import { type PopoverPortalProps } from '../types/PopoverPortalProps';
+
+export const PopoverPortal = ({ container, ...props }: PopoverPortalProps) => {
+ const themeContainer = useThemeContainer();
+ const direction = useProvidedTextDirection();
+
+ return (
+ <PopoverPrimitive.Portal
+ dir={direction}
+ {...props}
+ container={
+ isUndefined(container) ? (themeContainer ?? undefined) : container
+ }
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPositioner.tsx b/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPositioner.tsx
new file mode 100644
index 00000000000..87a879f5ccc
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/internal/PopoverPositioner.tsx
@@ -0,0 +1,24 @@
+import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+import { useProvidedTextDirection } from '@ui/primitives/layout/DirectionProvider/internal/useProvidedTextDirection';
+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+
+import styles from '../Popover.module.scss';
+import { type PopoverPositionerProps } from '../types/PopoverPositionerProps';
+
+export const PopoverPositioner = ({
+ className,
+ sideOffset = 8,
+ ...props
+}: PopoverPositionerProps) => {
+ const direction = useProvidedTextDirection();
+
+ return (
+ <PopoverPrimitive.Positioner
+ dir={direction}
+ sideOffset={sideOffset}
+ {...props}
+ className={mergeClassNames(styles.positioner, className)}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverAlign.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverAlign.ts
index 6447f23a83f..c1df50792dc 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverAlign.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverAlign.ts
@@ -1 +1,3 @@
-export type PopoverAlign = 'start' | 'center' | 'end';
+import { type PopoverPositionerProps } from './PopoverPositionerProps';
+
+export type PopoverAlign = NonNullable<PopoverPositionerProps['align']>;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverArrowProps.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverArrowProps.ts
new file mode 100644
index 00000000000..06044821115
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverArrowProps.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverArrowProps = PopoverPrimitive.Arrow.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverArrowState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverArrowState.ts
new file mode 100644
index 00000000000..0c465f651c0
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverArrowState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverArrowState = PopoverPrimitive.Arrow.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverBackdropProps.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverBackdropProps.ts
new file mode 100644
index 00000000000..de14a047497
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverBackdropProps.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverBackdropProps = PopoverPrimitive.Backdrop.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverBackdropState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverBackdropState.ts
new file mode 100644
index 00000000000..16b31f6ab0b
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverBackdropState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverBackdropState = PopoverPrimitive.Backdrop.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverCloseState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverCloseState.ts
new file mode 100644
index 00000000000..8778304dad7
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverCloseState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverCloseState = PopoverPrimitive.Close.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverDescriptionState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverDescriptionState.ts
new file mode 100644
index 00000000000..edfda633dca
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverDescriptionState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverDescriptionState = PopoverPrimitive.Description.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverHandle.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverHandle.ts
new file mode 100644
index 00000000000..c6b9c15dac1
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverHandle.ts
@@ -0,0 +1,5 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverHandle<TPayload = unknown> = InstanceType<
+ typeof PopoverPrimitive.Handle<TPayload>
+>;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPopupProps.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPopupProps.ts
index 67d59058298..504d99efb8d 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPopupProps.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPopupProps.ts
@@ -1,31 +1,3 @@
import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
-import { type PopoverAlign } from './PopoverAlign';
-import { type PopoverSide } from './PopoverSide';
-
-export type PopoverPopupProps = PopoverPrimitive.Popup.Props & {
- /** Side of the anchor the popup is placed on. */
- side?: PopoverSide;
- /** Alignment of the popup along the anchor. */
- align?: PopoverAlign;
- /** Distance in pixels between the anchor and the popup. */
- sideOffset?: PopoverPrimitive.Positioner.Props['sideOffset'];
- /** Offset in pixels along the alignment axis. */
- alignOffset?: PopoverPrimitive.Positioner.Props['alignOffset'];
- /** Shows an arrow pointing at the anchor. */
- arrow?: boolean;
- /** Element or position the popup is anchored to. Defaults to the trigger. */
- anchor?: PopoverPrimitive.Positioner.Props['anchor'];
- /**
- * Space in pixels kept between the popup and the edges of its collision
- * boundary, for all sides or per side. Defaults to 5.
- */
- collisionPadding?: PopoverPrimitive.Positioner.Props['collisionPadding'];
- /**
- * Element the popup is portaled into. Defaults to the theme's portal
- * container.
- */
- container?: PopoverPrimitive.Portal.Props['container'];
- /** Keeps the popup mounted in the DOM while the popover is closed. */
- keepMounted?: boolean;
-};
+export type PopoverPopupProps = PopoverPrimitive.Popup.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPopupState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPopupState.ts
new file mode 100644
index 00000000000..041587461c1
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPopupState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverPopupState = PopoverPrimitive.Popup.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPortalProps.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPortalProps.ts
new file mode 100644
index 00000000000..e732f2878a7
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPortalProps.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverPortalProps = PopoverPrimitive.Portal.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPortalState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPortalState.ts
new file mode 100644
index 00000000000..20c9b4c2ee6
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPortalState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverPortalState = PopoverPrimitive.Portal.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPositionerProps.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPositionerProps.ts
new file mode 100644
index 00000000000..ef64b88908e
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPositionerProps.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverPositionerProps = PopoverPrimitive.Positioner.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPositionerState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPositionerState.ts
new file mode 100644
index 00000000000..000584df042
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverPositionerState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverPositionerState = PopoverPrimitive.Positioner.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootActions.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootActions.ts
new file mode 100644
index 00000000000..b6dd2da8a58
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootActions.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverRootActions = PopoverPrimitive.Root.Actions;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootChangeEventDetails.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootChangeEventDetails.ts
new file mode 100644
index 00000000000..58f0cccecd0
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootChangeEventDetails.ts
@@ -0,0 +1,4 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverRootChangeEventDetails =
+ PopoverPrimitive.Root.ChangeEventDetails;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootChangeEventReason.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootChangeEventReason.ts
new file mode 100644
index 00000000000..baef178817c
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootChangeEventReason.ts
@@ -0,0 +1,4 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverRootChangeEventReason =
+ PopoverPrimitive.Root.ChangeEventReason;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootState.ts
new file mode 100644
index 00000000000..e10b9c0dcc2
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverRootState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverRootState = PopoverPrimitive.Root.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverSide.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverSide.ts
index 379e9cc0b00..577710cd9bf 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverSide.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverSide.ts
@@ -1,7 +1,3 @@
-export type PopoverSide =
- | 'top'
- | 'bottom'
- | 'left'
- | 'right'
- | 'inline-start'
- | 'inline-end';
+import { type PopoverPositionerProps } from './PopoverPositionerProps';
+
+export type PopoverSide = NonNullable<PopoverPositionerProps['side']>;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverTitleState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverTitleState.ts
new file mode 100644
index 00000000000..e3ccdbe4547
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverTitleState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverTitleState = PopoverPrimitive.Title.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverTriggerState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverTriggerState.ts
new file mode 100644
index 00000000000..10a2598c5f8
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverTriggerState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverTriggerState = PopoverPrimitive.Trigger.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverViewportProps.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverViewportProps.ts
new file mode 100644
index 00000000000..19032955241
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverViewportProps.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverViewportProps = PopoverPrimitive.Viewport.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverViewportState.ts b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverViewportState.ts
new file mode 100644
index 00000000000..6cfc7d5700f
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Popover/types/PopoverViewportState.ts
@@ -0,0 +1,3 @@
+import { type Popover as PopoverPrimitive } from '@base-ui/react/popover';
+
+export type PopoverViewportState = PopoverPrimitive.Viewport.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/index.ts b/packages/twenty-ui/src/primitives/surfaces/index.ts
index f5c40b50b8c..afabf3530ec 100644
--- a/packages/twenty-ui/src/primitives/surfaces/index.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/index.ts
@@ -64,13 +64,33 @@ export type { MenuSubmenuTriggerProps } from './Menu/types/MenuSubmenuTriggerPro
export type { MenuTriggerProps } from './Menu/types/MenuTriggerProps';
export { Popover } from './Popover/Popover';
export type { PopoverAlign } from './Popover/types/PopoverAlign';
+export type { PopoverArrowProps } from './Popover/types/PopoverArrowProps';
+export type { PopoverArrowState } from './Popover/types/PopoverArrowState';
+export type { PopoverBackdropProps } from './Popover/types/PopoverBackdropProps';
+export type { PopoverBackdropState } from './Popover/types/PopoverBackdropState';
export type { PopoverCloseProps } from './Popover/types/PopoverCloseProps';
+export type { PopoverCloseState } from './Popover/types/PopoverCloseState';
export type { PopoverDescriptionProps } from './Popover/types/PopoverDescriptionProps';
+export type { PopoverDescriptionState } from './Popover/types/PopoverDescriptionState';
+export type { PopoverHandle } from './Popover/types/PopoverHandle';
export type { PopoverPopupProps } from './Popover/types/PopoverPopupProps';
+export type { PopoverPopupState } from './Popover/types/PopoverPopupState';
+export type { PopoverPortalProps } from './Popover/types/PopoverPortalProps';
+export type { PopoverPortalState } from './Popover/types/PopoverPortalState';
+export type { PopoverPositionerProps } from './Popover/types/PopoverPositionerProps';
+export type { PopoverPositionerState } from './Popover/types/PopoverPositionerState';
+export type { PopoverRootActions } from './Popover/types/PopoverRootActions';
+export type { PopoverRootChangeEventDetails } from './Popover/types/PopoverRootChangeEventDetails';
+export type { PopoverRootChangeEventReason } from './Popover/types/PopoverRootChangeEventReason';
export type { PopoverRootProps } from './Popover/types/PopoverRootProps';
+export type { PopoverRootState } from './Popover/types/PopoverRootState';
export type { PopoverSide } from './Popover/types/PopoverSide';
export type { PopoverTitleProps } from './Popover/types/PopoverTitleProps';
+export type { PopoverTitleState } from './Popover/types/PopoverTitleState';
export type { PopoverTriggerProps } from './Popover/types/PopoverTriggerProps';
+export type { PopoverTriggerState } from './Popover/types/PopoverTriggerState';
+export type { PopoverViewportProps } from './Popover/types/PopoverViewportProps';
+export type { PopoverViewportState } from './Popover/types/PopoverViewportState';
export { Tooltip } from './Tooltip/Tooltip';
export type { TooltipAlign } from './Tooltip/types/TooltipAlign';
export type { TooltipArrowProps } from './Tooltip/types/TooltipArrowProps';
diff --git a/packages/twenty-ui/src/theme/__stories__/ThemeProvider.stories.tsx b/packages/twenty-ui/src/theme/__stories__/ThemeProvider.stories.tsx
index d5ca38e9adf..e280eaf6a77 100644
--- a/packages/twenty-ui/src/theme/__stories__/ThemeProvider.stories.tsx
+++ b/packages/twenty-ui/src/theme/__stories__/ThemeProvider.stories.tsx
@@ -299,18 +299,30 @@ const NestedThemes = () => {
</Button>
<Popover.Root>
<Popover.Trigger render={<Button>Open scoped portal</Button>} />
- <Popover.Popup>
- <Popover.Title>Scoped portal</Popover.Title>
- <ThemeReadout />
- <Popover.Close render={<Button>Close scoped portal</Button>} />
- </Popover.Popup>
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <Popover.Title>Scoped portal</Popover.Title>
+ <ThemeReadout />
+ <Popover.Close
+ render={<Button>Close scoped portal</Button>}
+ />
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
<Popover.Root>
<Popover.Trigger render={<Button>Open explicit portal</Button>} />
- <Popover.Popup container={container}>
- <Popover.Title>Explicit portal</Popover.Title>
- <Popover.Close render={<Button>Close explicit portal</Button>} />
- </Popover.Popup>
+ <Popover.Portal container={container}>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <Popover.Title>Explicit portal</Popover.Title>
+ <Popover.Close
+ render={<Button>Close explicit portal</Button>}
+ />
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
</Popover.Root>
</div>
</ThemeProvider>