Skip to content

The open alternative to Salesforce, designed for AI.

Complete Autocomplete parts (#27806)

Raphaël Bosifd5d75034adf
diff --git a/packages/twenty-docs/snippets/ui/generated/input/autocomplete.mdx b/packages/twenty-docs/snippets/ui/generated/input/autocomplete.mdx
index bdf9b58d028..d7c87e0c58e 100644
--- a/packages/twenty-docs/snippets/ui/generated/input/autocomplete.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/input/autocomplete.mdx
@@ -41,11 +41,11 @@
Whether the component should ignore user interaction.
</ParamField>
-<ParamField body="Root.filter" type="((item: TItem, query: string, itemToString?: ((item: TItem) =&gt; string) | undefined) =&gt; boolean) | null">
+<ParamField body="Root.filter" type="AutocompleteRootProps&lt;TItem&gt;[&quot;filter&quot;]">
Filter function used to match items against the input query.
</ParamField>
-<ParamField body="Root.filteredItems" type="readonly TItem[] | readonly Group&lt;TItem&gt;[]">
+<ParamField body="Root.filteredItems" type="readonly TItem[] | readonly { items: readonly TItem[] }[]">
Filtered items to display in the list.
When provided, the list uses these items instead of filtering the `items` prop internally.
When `items` is also provided, this array must preserve its flat or grouped structure.
@@ -83,11 +83,11 @@
A ref to the hidden input element.
</ParamField>
-<ParamField body="Root.items" type="readonly TItem[]">
- Items to display in the list. Nullish entries are not supported.
+<ParamField body="Root.items" type="readonly TItem[] | readonly { items: readonly TItem[] }[]">
+ Flat items or groups with an items array. Preserves the upstream item type; nullish entries are not supported.
</ParamField>
-<ParamField body="Root.itemToStringValue" type="((itemValue: TItem) =&gt; string)">
+<ParamField body="Root.itemToStringValue" type="(itemValue: TItem) =&gt; string">
When the item values are objects (`<Autocomplete.Item value={object}>`), this function converts the object value to a string representation for both display in the input and form submission.
If the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop.
</ParamField>
@@ -131,7 +131,7 @@
Identifies the field when a form is submitted.
</ParamField>
-<ParamField body="Root.onItemHighlighted" type="((highlightedValue: TItem | undefined, eventDetails: HighlightEventDetails) =&gt; void)">
+<ParamField body="Root.onItemHighlighted" type="(highlightedValue: TItem | undefined, eventDetails: AutocompleteRootHighlightEventDetails) =&gt; void">
Callback fired when an item is highlighted or unhighlighted.
Receives the highlighted item value (or `undefined` if no item is highlighted) and event details with a `reason` property describing why the highlight changed.
The `reason` can be:
@@ -182,6 +182,41 @@
Whether the items are being externally virtualized.
</ParamField>
+### Autocomplete.Value
+
+<ParamField body="Value.children" type="ReactNode | ((value: string) =&gt; ReactNode)">
+ Content or render function receiving the current input text.
+</ParamField>
+
+### Autocomplete.Trigger
+
+<ParamField body="Trigger.className" type="string | ((state: AutocompleteTriggerState) =&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="Trigger.disabled" type="boolean" default="false">
+ Whether the component should ignore user interaction.
+</ParamField>
+
+<ParamField body="Trigger.nativeButton" type="boolean" default="true">
+ Whether the component renders a native `<button>` element when replacing it
+ via the `render` prop.
+ Set to `false` if the rendered element is not a button (for example, `<div>`).
+</ParamField>
+
+<ParamField body="Trigger.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, AutocompleteTriggerState&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="Trigger.style" type="CSSProperties | ((state: AutocompleteTriggerState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
### Autocomplete.InputGroup
<ParamField body="InputGroup.className" type="string | ((state: AutocompleteInputGroupState) =&gt; string | undefined)">
@@ -228,13 +263,111 @@
returns a style object based on the component's state.
</ParamField>
-### Autocomplete.Popup
+### Autocomplete.Icon
-<ParamField body="Popup.align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;" default="start">
- How to align the popup relative to the specified side.
+<ParamField body="Icon.className" type="string | ((state: ComboboxIconState) =&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" default="0">
+<ParamField body="Icon.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxIconState&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="Icon.style" type="CSSProperties | ((state: ComboboxIconState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Autocomplete.Clear
+
+<ParamField body="Clear.className" type="string | ((state: ComboboxClearState) =&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="Clear.disabled" type="boolean" default="false">
+ Whether the component should ignore user interaction.
+</ParamField>
+
+<ParamField body="Clear.keepMounted" type="boolean" default="false">
+ Whether the component should remain mounted in the DOM when not visible.
+</ParamField>
+
+<ParamField body="Clear.nativeButton" type="boolean" default="true">
+ Whether the component renders a native `<button>` element when replacing it
+ via the `render` prop.
+ Set to `false` if the rendered element is not a button (for example, `<div>`).
+</ParamField>
+
+<ParamField body="Clear.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxClearState&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="Clear.style" type="CSSProperties | ((state: ComboboxClearState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Autocomplete.Portal
+
+<ParamField body="Portal.className" type="string | ((state: ComboboxPortalState) =&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="Portal.container" type="HTMLElement | ShadowRoot | RefObject&lt;HTMLElement | ShadowRoot | null&gt; | null">
+ Portal destination. Omitted uses the scoped theme container; explicit null waits without rendering. Element, ShadowRoot and ref targets pass through to Base UI.
+</ParamField>
+
+<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="Portal.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxPortalState&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: ComboboxPortalState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Autocomplete.Backdrop
+
+<ParamField body="Backdrop.className" type="string | ((state: ComboboxBackdropState) =&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.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxBackdropState&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: ComboboxBackdropState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Autocomplete.Positioner
+
+<ParamField body="Positioner.align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;" default="start">
+ Alignment relative to the anchor. Defaults to start.
+</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.
@@ -246,22 +379,101 @@
- `data.align`: how the positioner is aligned relative to the specified side.
</ParamField>
-<ParamField body="Popup.anchor" type="Element | VirtualElement | RefObject&lt;Element | null&gt; | (() =&gt; Element | VirtualElement | null) | null">
+<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="Popup.className" type="string | ((state: ComboboxPopupState) =&gt; string | undefined)">
+<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: ComboboxPositionerState) =&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" default="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="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="Popup.container" type="HTMLElement | ShadowRoot | RefObject&lt;HTMLElement | ShadowRoot | null&gt; | null">
- Element the popup is portaled into. Defaults to the theme portal container.
+<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, separate from Popup and Portal.
+</ParamField>
+
+<ParamField body="Positioner.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxPositionerState&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; supports functional offsets.
+</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: ComboboxPositionerState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Autocomplete.Popup
+
+<ParamField body="Popup.className" type="string | ((state: ComboboxPopupState) =&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)">
@@ -291,23 +503,6 @@
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">
- Which side of the anchor element to align the popup against.
- May automatically change to avoid collisions.
-</ParamField>
-
-<ParamField body="Popup.sideOffset" type="number | OffsetFunction" default="8">
- Distance between the anchor and the popup in pixels.
- Also accepts a function that returns the distance 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="Popup.style" type="CSSProperties | ((state: ComboboxPopupState) =&gt; CSSProperties | undefined)">
Style applied to the element, or a function that
returns a style object based on the component's state.
@@ -317,6 +512,25 @@
Width of the popup. Overrides its default minimum anchor width.
</ParamField>
+### Autocomplete.Arrow
+
+<ParamField body="Arrow.className" type="string | ((state: ComboboxArrowState) =&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="Arrow.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxArrowState&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: ComboboxArrowState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
### Autocomplete.List
<ParamField body="List.className" type="string | ((state: ComboboxListState) =&gt; string | undefined)">
@@ -336,6 +550,68 @@
returns a style object based on the component's state.
</ParamField>
+### Autocomplete.Status
+
+<ParamField body="Status.className" type="string | ((state: ComboboxStatusState) =&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="Status.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxStatusState&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="Status.style" type="CSSProperties | ((state: ComboboxStatusState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Autocomplete.Group
+
+<ParamField body="Group.className" type="string | ((state: ComboboxGroupState) =&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="Group.items" type="readonly any[]">
+ Items to be rendered within this group.
+ When provided, child `Collection` components will use these items.
+</ParamField>
+
+<ParamField body="Group.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxGroupState&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="Group.style" type="CSSProperties | ((state: ComboboxGroupState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Autocomplete.GroupLabel
+
+<ParamField body="GroupLabel.className" type="string | ((state: ComboboxGroupLabelState) =&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="GroupLabel.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxGroupLabelState&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="GroupLabel.style" type="CSSProperties | ((state: ComboboxGroupLabelState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
### Autocomplete.Item
<ParamField body="Item.className" type="string | ((state: AutocompleteItemState) =&gt; string | undefined)">
@@ -395,6 +671,31 @@
A unique value that identifies this item.
</ParamField>
+### Autocomplete.Row
+
+<ParamField body="Row.className" type="string | ((state: ComboboxRowState) =&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="Row.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ComboboxRowState&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="Row.style" type="CSSProperties | ((state: ComboboxRowState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Autocomplete.Collection
+
+<ParamField body="Collection.children" type="(item: any, index: number) =&gt; ReactNode" required>
+ Render function receiving each filtered item and its index.
+</ParamField>
+
### Autocomplete.Empty
<ParamField body="Empty.className" type="string | ((state: ComboboxEmptyState) =&gt; string | undefined)">
@@ -413,3 +714,26 @@
Style applied to the element, or a function that
returns a style object based on the component's state.
</ParamField>
+
+### Autocomplete.Separator
+
+<ParamField body="Separator.className" type="string | ((state: AutocompleteSeparatorState) =&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="Separator.orientation" type="&quot;horizontal&quot; | &quot;vertical&quot;" default="horizontal">
+ The orientation of the separator.
+</ParamField>
+
+<ParamField body="Separator.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, AutocompleteSeparatorState&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="Separator.style" type="CSSProperties | ((state: AutocompleteSeparatorState) =&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/input/autocomplete.mdx b/packages/twenty-docs/ui/primitives/input/autocomplete.mdx
index 230c5a65f22..36cb19b56b0 100644
--- a/packages/twenty-docs/ui/primitives/input/autocomplete.mdx
+++ b/packages/twenty-docs/ui/primitives/input/autocomplete.mdx
@@ -7,7 +7,7 @@ import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import AutocompleteReference from '/snippets/ui/generated/input/autocomplete.mdx';
-Use `Autocomplete` for suggestions attached to a text input. The input keeps its caret and keyboard focus while arrow keys highlight suggestions. Use [Select](/ui/primitives/input/select) when the user must choose a value from a fixed list.
+Use `Autocomplete` for suggestions attached to a text input. The input keeps its caret and keyboard focus while arrow keys highlight suggestions. Use [Select](/ui/primitives/input/select) when the user must choose a value from a fixed list. [Dropdown](/ui/components/navigation/dropdown) remains the higher-level component for menus and pickers.
<StoryEmbed
storyId="ui-input-autocomplete--documentation"
@@ -17,27 +17,61 @@ Use `Autocomplete` for suggestions attached to a text input. The input keeps its
## Anatomy
-Keep the input and popup inside a mounted `Autocomplete.Root`. `InputGroup` optionally groups the input with adjacent content and anchors the popup to that group.
+Keep related parts inside a mounted `Autocomplete.Root`. Compose the portal destination, positioning wrapper, and content separately. `InputGroup` optionally groups the input with adjacent controls and anchors the popup to that group.
```text
Autocomplete.Root
-├── Autocomplete.InputGroup
-│ └── Autocomplete.Input
-└── Autocomplete.Popup
- ├── Autocomplete.Empty
- └── Autocomplete.List
- └── Autocomplete.Item
+├── Autocomplete.InputGroup (optional)
+│ ├── Autocomplete.Input
+│ ├── Autocomplete.Clear (optional)
+│ └── Autocomplete.Trigger (optional)
+│ └── Autocomplete.Icon (optional)
+├── Autocomplete.Portal
+│ ├── Autocomplete.Backdrop (optional)
+│ └── Autocomplete.Positioner
+│ └── Autocomplete.Popup
+│ ├── Autocomplete.Arrow (optional)
+│ ├── Autocomplete.Empty
+│ └── Autocomplete.List
+│ ├── Autocomplete.Item
+│ ├── Autocomplete.Group (optional)
+│ │ ├── Autocomplete.GroupLabel
+│ │ └── Autocomplete.Collection
+│ │ └── Autocomplete.Item
+│ ├── Autocomplete.Row (optional, with Root.grid)
+│ │ └── Autocomplete.Item
+│ └── Autocomplete.Separator (optional)
+├── Autocomplete.Status (optional)
+└── Autocomplete.Value (optional)
```
-| Part | Purpose |
-| ------------ | --------------------------------------------------------------- |
-| `Root` | Owns the input value, filtering, highlights, and open state. |
-| `InputGroup` | Groups the input with adjacent controls or chips. |
-| `Input` | Renders the combobox input and retains keyboard focus. |
-| `Popup` | Portals and positions the suggestions. |
-| `List` | Renders the listbox and its filtered items. |
-| `Item` | Renders a suggestion and handles pointer or keyboard selection. |
-| `Empty` | Announces when no matching items are available. |
+| Part | Purpose and native target |
+| ------------ | ------------------------------------------------------------------------------- |
+| `Root` | Owns input value, filtering, highlights, and open state. Renders no element. |
+| `Value` | Reads the input text through children or a render function. Renders no element. |
+| `InputGroup` | Groups the input and adjacent controls. Targets a div. |
+| `Input` | Renders the combobox input and retains keyboard focus. Targets an input. |
+| `Trigger` | Opens or closes suggestions. Targets a button. |
+| `Icon` | Contains a trigger indicator. Targets a span. |
+| `Clear` | Clears the input value. Targets a button. |
+| `Portal` | Chooses the destination and mounting policy. Targets its portal div. |
+| `Backdrop` | Supplies an optional overlay beneath the popup. Targets a div. |
+| `Positioner` | Owns anchor, alignment, offsets, and collision handling. Targets its div. |
+| `Popup` | Renders the suggestion content and optional focus behavior. Targets its div. |
+| `Arrow` | Supplies an optional positioned arrow inside Popup. Targets a div. |
+| `List` | Renders filtered items. Targets a div with the listbox or grid role. |
+| `Item` | Renders a suggestion and handles pointer or keyboard selection. Targets a div. |
+| `Group` | Groups related items. Targets a div. |
+| `GroupLabel` | Labels its parent group. Targets a div. |
+| `Row` | Groups a row of items when `Root.grid` is enabled. Targets a div. |
+| `Collection` | Renders filtered items through a function child. Renders no element. |
+| `Separator` | Separates items or groups visually. Targets a div. |
+| `Empty` | Announces when no matching items are available. Targets a div. |
+| `Status` | Announces changes such as asynchronous loading status. Targets a div. |
+
+Rendered parts retain native attributes, handlers, refs, state-based `className` and `style`, and element/function `render` composition from the installed Base UI API. Native props and refs target the part's own element. Custom components must forward supplied props and refs. Public part props and state types are exported from `twenty-ui/primitives/input`, together with Root actions and change/highlight event detail types.
+
+`Autocomplete.useFilter()` supplies locale-aware `contains`, `startsWith`, and `endsWith` matching. `Autocomplete.useFilteredItems<TItem>()` reads the internally filtered collection under Root. Treat that result as read-only.
## Local suggestions
@@ -51,96 +85,175 @@ const CITIES = ['Paris', 'London', 'Lisbon'];
export const CityInput = () => (
<Autocomplete.Root items={CITIES} autoHighlight="always">
<Autocomplete.Input aria-label="City" placeholder="Search cities" />
- <Autocomplete.Popup>
- <Autocomplete.Empty>No matching cities</Autocomplete.Empty>
- <Autocomplete.List>
- {(city: string) => (
- <Autocomplete.Item key={city} value={city}>
- {city}
- </Autocomplete.Item>
- )}
- </Autocomplete.List>
- </Autocomplete.Popup>
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.Empty>No matching cities</Autocomplete.Empty>
+ <Autocomplete.List>
+ {(city: string) => (
+ <Autocomplete.Item key={city} value={city}>
+ {city}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
</Autocomplete.Root>
);
```
-`value` and `onValueChange` control the input text. Use `defaultValue` for an uncontrolled initial value. `Item.onClick` handles both pointer selection and Enter from the input. For object items, provide `itemToStringValue` to determine their input text.
+`value` and `onValueChange` control the input text. Use `defaultValue` for an uncontrolled initial value. Open state is independent: use `open` and `onOpenChange`, or `defaultOpen`. `Item.onClick` handles both pointer selection and Enter from the input.
+
+`mode="list"` filters without changing input text on highlight. `mode="both"` also supplies inline completion. `mode="inline"` keeps all items and supplies inline completion; `mode="none"` keeps all items without inline completion. `readOnly` prevents inline completion from changing the input.
-## Server suggestions
+## Object and grouped items
-Pass `filter={null}` when a server already filters the results. Keep `Root` mounted and control `open` independently so results can arrive while the input remains focused. A loading state can stay outside `List`; render `Empty` when the completed response has no results.
+Items can be strings or arbitrary objects. Use `itemToStringValue` to supply the text used for filtering, completion, and form submission. Objects shaped as `{ value, label }` use their label automatically. Render the same item value supplied through Root; no Twenty-specific item shape or selection equality prop is required. Autocomplete owns text input rather than a separate selected object value.
+
+For grouped data, pass groups with an `items` array. Root preserves the item type for `itemToStringValue` and `onItemHighlighted`. Render each group's filtered children through `Group` and `Collection`:
```tsx
import { Autocomplete } from 'twenty-ui/primitives/input';
-type LocationSuggestionsProps = {
- query: string;
- locations: string[];
- open: boolean;
- onQueryChange: (query: string) => void;
- onOpenChange: (open: boolean) => void;
- onSelect: (location: string) => void;
-};
+type City = { id: number; name: string; country: string };
+type CityGroup = { label: string; items: City[] };
-export const LocationSuggestions = ({
- query,
- locations,
- open,
- onQueryChange,
- onOpenChange,
- onSelect,
-}: LocationSuggestionsProps) => (
+const CITY_GROUPS: CityGroup[] = [
+ {
+ label: 'Europe',
+ items: [
+ { id: 1, name: 'Paris', country: 'France' },
+ { id: 2, name: 'Lisbon', country: 'Portugal' },
+ ],
+ },
+];
+
+export const GroupedCityInput = () => (
<Autocomplete.Root
- items={locations}
- value={query}
- open={open}
- filter={null}
+ items={CITY_GROUPS}
+ itemToStringValue={(city) => city.name}
autoHighlight="always"
- onValueChange={(value, details) => {
- if (details.reason !== 'escape-key') {
- onQueryChange(value);
- }
- }}
- onOpenChange={(nextOpen, details) => {
- if (details.reason !== 'input-change') {
- onOpenChange(nextOpen);
- }
- }}
>
- <Autocomplete.Input aria-label="Location" />
- <Autocomplete.Popup>
- <Autocomplete.Empty>No matching locations</Autocomplete.Empty>
- <Autocomplete.List>
- {(location: string) => (
- <Autocomplete.Item
- key={location}
- value={location}
- onClick={() => onSelect(location)}
- >
- {location}
- </Autocomplete.Item>
- )}
- </Autocomplete.List>
- </Autocomplete.Popup>
+ <Autocomplete.Input aria-label="City" />
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.Empty>No matching cities</Autocomplete.Empty>
+ <Autocomplete.List>
+ {(group: CityGroup) => (
+ <Autocomplete.Group key={group.label} items={group.items}>
+ <Autocomplete.GroupLabel>{group.label}</Autocomplete.GroupLabel>
+ <Autocomplete.Collection>
+ {(city: City) => (
+ <Autocomplete.Item
+ key={city.id}
+ value={city}
+ description={city.country}
+ >
+ {city.name}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.Collection>
+ </Autocomplete.Group>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
</Autocomplete.Root>
);
```
-The parent owns debounce, request cancellation, and stale response protection. In this example, typing does not open the list until the parent supplies its results and sets `open`. Escape closes the list and preserves the query.
+<StoryEmbed
+ storyId="ui-input-autocomplete-collections--grouped-objects"
+ title="Grouped object suggestions"
+ height={440}
+/>
+
+`Item.startIcon`, `Item.endIcon`, and `Item.description` provide supporting content. Compose `Trigger` and `Clear` with Twenty UI [Button](/ui/primitives/input/button) through `render`. `Icon` can contain an icon from `twenty-ui/icon`. Keep `Status` and `Empty` mounted while updating their children so screen readers can announce changes.
+
+## External filtering and server suggestions
+
+Use `filteredItems` when your application owns filtering. It must preserve the flat or grouped structure of `items`. `filter` accepts a custom matching function; `filter={null}` disables internal filtering for results already filtered by a server.
+
+```tsx
+import { useState } from 'react';
+import { Autocomplete } from 'twenty-ui/primitives/input';
+
+const CITIES = ['Paris', 'London', 'Lisbon'];
+
+export const CityPrefixInput = () => {
+ const [value, setValue] = useState('');
+ const { startsWith } = Autocomplete.useFilter();
+ const filteredItems = CITIES.filter((city) => startsWith(city, value));
+
+ return (
+ <Autocomplete.Root
+ items={CITIES}
+ filteredItems={filteredItems}
+ value={value}
+ onValueChange={setValue}
+ autoHighlight="always"
+ >
+ <Autocomplete.Input aria-label="City prefix" />
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.Empty>No matching cities</Autocomplete.Empty>
+ <Autocomplete.List>
+ {(city: string) => (
+ <Autocomplete.Item key={city} value={city}>
+ {city}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>
+ );
+};
+```
+
+Keep Root mounted when results arrive asynchronously. Control `open` independently so a response can open suggestions while the input remains focused. A mounted `Status` can announce loading; update `Empty` when the completed response has no results. The parent owns debounce, request cancellation, and stale response protection.
+
+`onValueChange` and `onOpenChange` receive the upstream event details, including `reason`, native `event`, `trigger`, `cancel()`, and `allowPropagation()`. Controlled callers decide which requested updates to commit. For example, ignore the `escape-key` value change to keep a server query, or ignore `input-change` opening until results arrive. `onItemHighlighted` receives the original typed item and its highlight reason. Cancellation keeps the installed Base UI semantics; it does not replace the application's controlled-state policy.
+
+## Input composition and native forms
+
+`Input` accepts `size="sm"` or `size="md"` and uses the same styles as [Input](/ui/primitives/input/input). Compose it with an existing input using `render`. Forward the supplied ref, native attributes, and handlers to the actual input element.
+
+`InputGroup` provides layout and an anchor without adding input borders. It can contain chips or render an existing wrapper. Use [InputGroup](/ui/primitives/input/input-group) through its `render` prop when the whole group needs input styling. Give the input an accessible label or compose it with [Field](/ui/primitives/input/field).
+
+Root preserves the upstream `name`, `form`, `disabled`, `readOnly`, and native form behavior. Input's native attributes and ref target its input. `submitOnItemClick` opts into form submission when selecting a suggestion; the default does not submit.
+
+Input preserves Base UI's native IME handling, including composition events and its keyboard confirmation guard.
+
+The installed Base UI version retains an uncontrolled query on native form reset. For a controlled query, handle the form's `onReset` and restore the application's initial value.
+
+## Placement, portal destination, and dismissal
+
+`Positioner` defaults to `side="bottom"`, `align="start"`, and `sideOffset={8}`. It retains the installed Base UI anchor and positioning contract, including element/ref/function/virtual anchors, functional offsets, `positionMethod`, `collisionBoundary`, `collisionPadding`, `collisionAvoidance`, `arrowPadding`, `sticky`, and `disableAnchorTracking`. Configure these on Positioner. DirectionProvider controls logical placement and DOM direction.
+
+`Popup` uses the anchor width as its minimum width. Set its `width` to supply a fixed content width. Its native props, styles, render composition, and ref target the content element independently of Positioner and Portal. Popup's `initialFocus` and `finalFocus` retain upstream focus options. By default, suggestions keep focus in the input.
+
+Configure `container` and `keepMounted` on `Portal`. Omitting the container uses the nearest scoped ThemeProvider destination, then Base UI's parent portal or document body. An explicit `null` waits without rendering until a container is supplied. Element, ShadowRoot, and ref destinations pass through to Base UI. An unresolved ref retains Base UI's parent-portal/body fallback.
+
+The default scoped destination preserves its CSS tokens and color scheme. An explicit destination inherits CSS from its actual DOM scope, so place it inside the intended theme scope or supply those styles there. React context and direction remain available across portals. ShadowRoot targets need the library's CSS and theme styles in that shadow tree.
-## Input composition and placement
+Arrow keys change the highlighted item while the input keeps focus. Enter selects it; Escape and outside interaction request dismissal using upstream semantics. An outside press can activate the destination control. Higher-level pickers can own a different activation policy in their adapter. Call `event.preventBaseUIHandler()` in Input's `onKeyDown` to skip the built-in handler for a key you handle yourself. Use `event.preventDefault()` as well when suppressing the browser's native action.
-`Input` accepts `size="sm"` or `size="md"` and uses the same styles as [Input](/ui/primitives/input/input). Use its `render` prop to compose an existing input. That input must forward its ref, native input attributes, and event handlers to the actual input element so keyboard navigation and accessible state remain connected.
+`Root.inline` with `open` renders suggestions without the popup assembly. Inline items retain their `onClick` selection callbacks, but the installed upstream component fills the input automatically only when its Popup is present. Handle `Item.onClick` when inline selection should update your controlled text. `Root.grid` and `Row` support grid navigation. These modes retain the upstream collection and rendering APIs.
-`InputGroup` provides layout and an anchor without adding input borders. It can contain chips or render an existing wrapper. Use [InputGroup](/ui/primitives/input/input-group) through its `render` prop when the whole group needs input styling.
+## Migration
-`Popup` defaults to `side="bottom"`, `align="start"`, and `sideOffset={8}`. It uses the anchor's width as its minimum width and the [theme's portal container](/ui/theming#scope-an-override) unless you provide `container`. Set `width` to override the anchor width with a fixed popup width. Customize placement with `side`, `align`, offsets, `collisionPadding`, or `anchor`.
+Wrap Popup with `Autocomplete.Positioner` and `Autocomplete.Portal`. Positioner requires the Portal context; inline suggestions omit the whole popup assembly. Move placement, anchor, and collision props from Popup to Positioner. Move `container` and mounting configuration to Portal. Keep width, content styles, native props, handlers, and refs on Popup. Use an explicit `Arrow` child for an arrow.
-Use `Item.startIcon`, `Item.endIcon`, and `Item.description` for supporting content. Arrow keys change the highlighted item without moving DOM focus from the input; Enter chooses that item and Escape dismisses the popup. A press outside the input group and popup also dismisses it without activating the element that was pressed. Call `event.preventDefault()` in the input's `onKeyDown` to handle a key yourself and skip this built-in behavior. Give the input an accessible label or compose it with [Field](/ui/primitives/input/field).
+Inside front components, keep the existing scoped portal policy. This API does not expand renderer portal destinations or geometry, scrolling, and dismissal capabilities; those renderer capabilities have separate ownership. Production picker adapters retain their deliberate activation workflows.
## Props
-The reference is generated from the public component types. Parts that render an element also accept its native attributes and event handlers.
+The reference is generated from the public component types. Native attributes, accessible names, and event handlers are also accepted on rendered parts.
<AutocompleteReference />
diff --git a/packages/twenty-docs/ui/primitives/overview.mdx b/packages/twenty-docs/ui/primitives/overview.mdx
index bd350ab4a9f..bfe785ebd0e 100644
--- a/packages/twenty-docs/ui/primitives/overview.mdx
+++ b/packages/twenty-docs/ui/primitives/overview.mdx
@@ -45,6 +45,8 @@ Some primitives package supporting overlay elements inside their `Popup` part:
Place content directly inside these popup parts. Their portal may move the rendered DOM to another container while preserving the component hierarchy and context. See [theming](/ui/theming#scope-an-override) for scoped portal containers.
+[Autocomplete](/ui/primitives/input/autocomplete) exposes separate `Portal`, `Positioner`, and `Popup` parts. Configure the destination and mounting on Portal, placement and collision handling on Positioner, and content width and native props on Popup. Their refs and render composition target their own elements. Autocomplete also preserves the installed upstream collection, grouping, grid, filtering, and status parts.
+
[Dialog](/ui/primitives/surfaces/dialog) and [AlertDialog](/ui/primitives/surfaces/alert-dialog) expose separate `Portal`, `Backdrop`, `Viewport` and `Popup` parts. Configure mounting and the destination on Portal, overlay appearance on Backdrop and Viewport, and content size and focus on Popup. Each part preserves its own native attributes, ref target and render composition. These dialog APIs are for standalone UI and the Twenty host. Front components use the [SDK host dialog API](/developers/extend/apps/layout/front-components#host-communication-api).
### Custom components
diff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiAutocomplete.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiAutocomplete.stories.tsx
index b7232be4781..0c6e94276df 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiAutocomplete.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiAutocomplete.stories.tsx
@@ -6,8 +6,10 @@ import {
} from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
import { type TwentyUiGalleryStory } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryStory';
import { autocompleteCompositionTest } from '@/__stories__/twenty-ui-gallery/utils/autocompleteCompositionTest';
+import { autocompleteDismissalTest } from '@/__stories__/twenty-ui-gallery/utils/autocompleteDismissalTest';
import { autocompleteEmptyTest } from '@/__stories__/twenty-ui-gallery/utils/autocompleteEmptyTest';
import { autocompleteInputTest } from '@/__stories__/twenty-ui-gallery/utils/autocompleteInputTest';
+import { autocompletePartsTest } from '@/__stories__/twenty-ui-gallery/utils/autocompletePartsTest';
import { createGalleryStory } from '@/__stories__/twenty-ui-gallery/utils/createGalleryStory';
import { FrontComponentRenderer } from '@/host/components/FrontComponentRenderer';
@@ -56,3 +58,27 @@ export const EmptyPreact: TwentyUiGalleryStory = createGalleryStory({
runtime: 'preact',
play: autocompleteEmptyTest,
});
+
+export const PartsReact: TwentyUiGalleryStory = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-autocomplete-parts',
+ runtime: 'react',
+ play: autocompletePartsTest,
+});
+
+export const PartsPreact: TwentyUiGalleryStory = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-autocomplete-parts',
+ runtime: 'preact',
+ play: autocompletePartsTest,
+});
+
+export const DismissalReact: TwentyUiGalleryStory = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-autocomplete-parts',
+ runtime: 'react',
+ play: autocompleteDismissalTest,
+});
+
+export const DismissalPreact: TwentyUiGalleryStory = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-autocomplete-parts',
+ runtime: 'preact',
+ play: autocompleteDismissalTest,
+});
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 8901b582b51..efccc7cf2e0 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
@@ -47,6 +47,7 @@ effect within the interaction timeout.
| `twenty-ui-number-stepper` | NumberStepper (pointer stepping, selected-range paste, caret restoration, keyboard bounds, disabled/read-only state and forms) |
| `twenty-ui-number-field` | NumberField (locale formatting and paste, controlled/uncontrolled values, callback details, native forms and refs, bounds and render composition) |
| `twenty-ui-autocomplete` | Autocomplete (caret keys, controlled editing, composition, filtering, disabled state, Empty; `TwentyUiAutocomplete.stories.tsx`) |
+| `twenty-ui-autocomplete-parts` | Autocomplete grouped objects, popup parts, native refs/render, controlled updates, Clear, selection and cancelable Escape |
| `twenty-ui-display-helpers` | Text |
| `twenty-ui-avatar-controls` | Avatar (stable presentational root, compound fallback, refs, explicit button/link composition and native keyboard/disabled behavior) |
| `twenty-ui-avatar-group` | AvatarGroup (derived and partial totals, custom overflow, keyed child state, native refs and explicit button/link composition) |
@@ -125,11 +126,36 @@ that area so Floating UI popups flip and size themselves to fit it. The portal
fixture covers callbacks, removal, menu placement, interface zoom, and an
oversized portal that stays clipped while a host control remains usable.
-The Autocomplete fixture uses the public inline list interface to isolate input
-behavior from popup support. Its Empty section runs Base UI's live-region marker
-through a narrow worker TreeWalker that supports SHOW_TEXT, nextNode and
-currentNode without callback filters; document Selection and DOM Range are
-outside this scope.
+The string Autocomplete fixture uses the public inline list interface for caret
+editing, controlled updates, IME confirmation, filtering and Empty. Its Empty
+section runs Base UI's live-region marker through a narrow worker TreeWalker
+that supports SHOW_TEXT, nextNode and currentNode without callback filters;
+document Selection and DOM Range are outside this scope.
+
+The grouped object fixture composes Portal, Positioner and Popup separately.
+Its React/Preact cases require visible popup content and check native input refs
+and element render composition, group filtering and empty results, item labels
+and selection callbacks, controlled external updates, Clear, keyboard highlight
+reasons, and cancelable Escape dismissal. The fixed Positioner configuration is
+forwarded. Separate React/Preact probes pass basic bottom/start placement with
+an 8px offset and nonzero visible host geometry. They do not establish collision
+handling or placement under scrolling and zoom.
+
+Three renderer gaps remain outside that positive coverage. A strict outside-press
+success probe fails in both runtimes: the host button activates once, but the
+popup remains open because events outside the owned component do not reach the
+worker. C07 owns that dismissal transport. A separate strict native-input
+semantics probe also fails in both runtimes after a controlled update while
+closed. Base UI compares the registered element's tag name with `INPUT`, while
+the worker retains `HTML-INPUT` for remote DOM transport. It consequently treats
+the input as a custom control and removes its combobox role and expanded state
+while closed. The role returns while the popup is open, and the Trigger retains
+its controlled expanded state. A strict scrolling probe highlights the final
+option in a 40-item list after keyboard navigation, but the option stays below
+the host list's visible bounds in both runtimes. This leaves the C06 scroll
+transport incomplete. No tag-name override or known-failure acceptance pin is
+introduced. These gaps and the remaining C05/C06/C07 work prevent these stories
+from establishing integrated V1 acceptance.
## ImageInput file selection
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-autocomplete-parts.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-autocomplete-parts.front-component.tsx
new file mode 100644
index 00000000000..cc98f875b27
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-autocomplete-parts.front-component.tsx
@@ -0,0 +1,159 @@
+import { useRef, useState } from 'react';
+import { defineFrontComponent } from 'twenty-sdk/define';
+import { isDefined } from 'twenty-shared/utils';
+import { Autocomplete, Button } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
+
+import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';
+
+type Person = { identifier: string; name: string };
+type PeopleGroup = { label: string; items: readonly Person[] };
+
+const PEOPLE_GROUPS: readonly PeopleGroup[] = [
+ {
+ label: 'Sales',
+ items: [
+ { identifier: 'alice', name: 'Alice Johnson' },
+ { identifier: 'bob', name: 'Bob Smith' },
+ ],
+ },
+ {
+ label: 'Support',
+ items: [{ identifier: 'carol', name: 'Carol Wilson' }],
+ },
+];
+
+const AutocompletePartsExample = () => {
+ const [value, setValue] = useState('');
+ const [open, setOpen] = useState(false);
+ const [cancelEscape, setCancelEscape] = useState(true);
+ const [changeDetails, setChangeDetails] = useState('none');
+ const [openDetails, setOpenDetails] = useState('none');
+ const [highlightDetails, setHighlightDetails] = useState('none');
+ const [selectedPerson, setSelectedPerson] = useState('none');
+ const [selections, setSelections] = useState(0);
+ const [inputTarget, setInputTarget] = useState('none');
+ const inputRef = useRef<HTMLInputElement>(null);
+
+ return (
+ <TwentyUiGalleryCard title="Autocomplete parts">
+ <Autocomplete.Root
+ items={PEOPLE_GROUPS}
+ itemToStringValue={(person) => person.name}
+ value={value}
+ open={open}
+ autoHighlight="always"
+ openOnInputClick
+ onValueChange={(nextValue, details) => {
+ setValue(nextValue);
+ setChangeDetails(`${details.reason}/${details.event.type}`);
+ setInputTarget(
+ inputRef.current?.getAttribute('data-native-owner') ?? 'missing',
+ );
+ }}
+ onOpenChange={(nextOpen, details) => {
+ const shouldCancelEscape =
+ cancelEscape && details.reason === 'escape-key';
+
+ if (shouldCancelEscape) {
+ details.cancel();
+ setOpenDetails(`${details.reason}/canceled:${details.isCanceled}`);
+ return;
+ }
+
+ setOpen(nextOpen);
+ setOpenDetails(`${details.reason}/${details.event.type}`);
+ }}
+ onItemHighlighted={(person, details) => {
+ setHighlightDetails(
+ `${isDefined(person) ? person.name : 'none'}/${details.reason}`,
+ );
+ }}
+ >
+ <Autocomplete.InputGroup>
+ <Autocomplete.Input
+ ref={inputRef}
+ aria-label="Account owner"
+ name="accountOwner"
+ render={<input data-native-owner="account-owner" />}
+ />
+ <Autocomplete.Trigger
+ aria-label="Show people"
+ render={<Button variant="outline" />}
+ >
+ <Autocomplete.Icon>Show people</Autocomplete.Icon>
+ </Autocomplete.Trigger>
+ <Autocomplete.Clear render={<Button variant="ghost" />}>
+ Clear people
+ </Autocomplete.Clear>
+ </Autocomplete.InputGroup>
+ <Autocomplete.Portal data-autocomplete-portal="">
+ <Autocomplete.Positioner
+ side="bottom"
+ align="start"
+ sideOffset={8}
+ positionMethod="fixed"
+ collisionAvoidance={{ side: 'flip', align: 'shift' }}
+ data-autocomplete-positioner=""
+ >
+ <Autocomplete.Popup
+ render={<section role="region" aria-label="People suggestions" />}
+ data-autocomplete-popup=""
+ >
+ <Autocomplete.Arrow />
+ <Autocomplete.Status>People matches</Autocomplete.Status>
+ <Autocomplete.Empty>No matching people.</Autocomplete.Empty>
+ <Autocomplete.List aria-label="People">
+ {(group: PeopleGroup) => (
+ <Autocomplete.Group key={group.label} items={group.items}>
+ <Autocomplete.GroupLabel>
+ {group.label}
+ </Autocomplete.GroupLabel>
+ <Autocomplete.Collection>
+ {(person: Person) => (
+ <Autocomplete.Item
+ key={person.identifier}
+ value={person}
+ onClick={() => {
+ setSelectedPerson(person.name);
+ setSelections((count) => count + 1);
+ }}
+ >
+ {person.name}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.Collection>
+ </Autocomplete.Group>
+ )}
+ </Autocomplete.List>
+ <Button onClick={() => setCancelEscape(false)}>
+ Allow Escape
+ </Button>
+ <Autocomplete.Separator />
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ <Text role="status" aria-label="Owner value">
+ <Autocomplete.Value>
+ {(currentValue) => currentValue || 'empty'}
+ </Autocomplete.Value>
+ </Text>
+ </Autocomplete.Root>
+ <Button onClick={() => setValue('Carol Wilson')}>Set Carol</Button>
+ <Text role="status" aria-label="Owner callbacks">
+ Change: {changeDetails}; Open: {openDetails}; Highlight:{' '}
+ {highlightDetails}; Input: {inputTarget}
+ </Text>
+ <Text role="status" aria-label="Owner selection">
+ {selectedPerson}; Selections: {selections}
+ </Text>
+ </TwentyUiGalleryCard>
+ );
+};
+
+export default defineFrontComponent({
+ universalIdentifier: '0561616d-6aa8-4c65-b0e4-a8bda6dd5d30',
+ name: 'twenty-ui-autocomplete-parts',
+ description: 'Autocomplete grouped objects, public popup parts and callbacks',
+ component: AutocompletePartsExample,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/autocompleteDismissalTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/autocompleteDismissalTest.ts
new file mode 100644
index 00000000000..d6b4d62327c
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/autocompleteDismissalTest.ts
@@ -0,0 +1,47 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+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 autocompleteDismissalTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ await expectFrontComponentMounted(canvas);
+
+ const input = canvas.getByLabelText<HTMLInputElement>('Account owner');
+ const trigger = canvas.getByRole('button', { name: 'Show people' });
+ const callbacks = canvas.getByRole('status', { name: 'Owner callbacks' });
+ const selection = canvas.getByRole('status', { name: 'Owner selection' });
+
+ await userEvent.click(trigger);
+ await waitFor(() => expect(input).toHaveAttribute('aria-expanded', 'true'));
+ await waitFor(() =>
+ expect(
+ page.getByRole('region', { name: 'People suggestions' }),
+ ).toBeVisible(),
+ );
+ await userEvent.click(input);
+ await userEvent.keyboard('{ArrowDown}');
+ await waitFor(() => expect(callbacks).toHaveTextContent('/keyboard'));
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(callbacks).toHaveTextContent('Open: escape-key/canceled:true'),
+ );
+ await expect(input).toHaveAttribute('aria-expanded', 'true');
+ await expect(selection).toHaveTextContent('none; Selections: 0');
+
+ await userEvent.click(page.getByRole('button', { name: 'Allow Escape' }));
+ await userEvent.click(input);
+ await waitFor(() => expect(input).toHaveAttribute('aria-expanded', 'true'));
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(trigger).toHaveAttribute('aria-expanded', 'false'),
+ );
+ await expect(callbacks).toHaveTextContent('Open: escape-key/keydown');
+ await expect(selection).toHaveTextContent('none; Selections: 0');
+ await expect(input).toHaveFocus();
+ await expect(errorHandler).not.toHaveBeenCalled();
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/autocompletePartsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/autocompletePartsTest.ts
new file mode 100644
index 00000000000..07aeb82af93
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/autocompletePartsTest.ts
@@ -0,0 +1,71 @@
+import { expect, fireEvent, userEvent, waitFor, within } from 'storybook/test';
+
+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 autocompletePartsTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ await expectFrontComponentMounted(canvas);
+
+ const input = canvas.getByLabelText<HTMLInputElement>('Account owner');
+ const trigger = canvas.getByRole('button', { name: 'Show people' });
+ const callbacks = canvas.getByRole('status', { name: 'Owner callbacks' });
+ const value = canvas.getByRole('status', { name: 'Owner value' });
+ const selection = canvas.getByRole('status', { name: 'Owner selection' });
+
+ await expect(input.tagName).toBe('INPUT');
+ await expect(input).toHaveAttribute('data-native-owner', 'account-owner');
+ await expect(input).toHaveAttribute('name', 'accountOwner');
+ await expect(trigger).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.click(trigger);
+ await waitFor(() => expect(input).toHaveAttribute('aria-expanded', 'true'));
+ await expect(input).toHaveAttribute('role', 'combobox');
+ const popup = await page.findByRole('region', { name: 'People suggestions' });
+ await expect(popup.tagName).toBe('SECTION');
+ await waitFor(() => expect(popup).toBeVisible());
+ await expect(popup.closest('[data-autocomplete-positioner]')).toHaveStyle({
+ position: 'fixed',
+ });
+ await expect(page.getByRole('group', { name: 'Sales' })).toBeVisible();
+ await expect(page.getByRole('group', { name: 'Support' })).toBeVisible();
+ await expect(page.getAllByRole('option')).toHaveLength(3);
+
+ await fireEvent.input(input, { target: { value: 'Bob' } });
+ const bob = await page.findByRole('option', { name: 'Bob Smith' });
+ await waitFor(() => expect(page.getAllByRole('option')).toHaveLength(1));
+ await expect(callbacks).toHaveTextContent(
+ /Change: input-change\/(input|change)/,
+ );
+ await expect(callbacks).toHaveTextContent('Input: account-owner');
+ await expect(value).toHaveTextContent('Bob');
+ await userEvent.click(bob);
+ await waitFor(() => expect(input).toHaveValue('Bob Smith'));
+ await expect(selection).toHaveTextContent('Bob Smith; Selections: 1');
+ await expect(callbacks).toHaveTextContent('Change: item-press/click');
+ await waitFor(() =>
+ expect(trigger).toHaveAttribute('aria-expanded', 'false'),
+ );
+
+ await userEvent.click(
+ await canvas.findByRole('button', { name: 'Set Carol' }),
+ );
+ await waitFor(() => expect(input).toHaveValue('Carol Wilson'));
+ await expect(value).toHaveTextContent('Carol Wilson');
+ await userEvent.click(canvas.getByRole('button', { name: 'Clear people' }));
+ await waitFor(() => expect(input).toHaveValue(''));
+ await expect(callbacks).toHaveTextContent('Change: clear-press/click');
+ await expect(value).toHaveTextContent('empty');
+
+ await userEvent.click(input);
+ await fireEvent.input(input, { target: { value: 'Nobody' } });
+ await waitFor(() =>
+ expect(page.getByText('No matching people.')).toBeVisible(),
+ );
+ await expect(page.queryAllByRole('option')).toHaveLength(0);
+ await expect(selection).toHaveTextContent('Bob Smith; Selections: 1');
+ await expect(errorHandler).not.toHaveBeenCalled();
+};
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventLocationInput.tsx b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventLocationInput.tsx
index fb9b4882237..a5d384f1e72 100644
--- a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventLocationInput.tsx
+++ b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventLocationInput.tsx
@@ -2,8 +2,8 @@ import { StyledComposerTextInput } from '@/activities/components/ComposerTextInp
import { PlaceAutocompleteSelect } from '@/geo-map/components/PlaceAutocompleteSelect';
import { usePlaceAutocomplete } from '@/geo-map/hooks/usePlaceAutocomplete';
import { AutocompleteRoot } from '@/ui/input/components/AutocompleteRoot';
-import { Autocomplete } from 'twenty-ui/primitives/input';
import { isDefined } from 'twenty-shared/utils';
+import { Autocomplete } from 'twenty-ui/primitives/input';
const CALENDAR_EVENT_LOCATION_AUTOCOMPLETE_DROPDOWN_ID =
'calendar-event-location-autocomplete-dropdown';
diff --git a/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientsFieldInput.tsx b/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientsFieldInput.tsx
index 48d9ea19a71..021f020e4e9 100644
--- a/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientsFieldInput.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientsFieldInput.tsx
@@ -7,7 +7,6 @@ import { isNonEmptyString } from '@sniptt/guards';
import { atom, useStore } from 'jotai';
import {
type ClipboardEvent,
- type KeyboardEvent,
type MouseEvent,
type ReactNode,
useContext,
@@ -18,7 +17,10 @@ import {
} from 'react';
import { flushSync } from 'react-dom';
import { isDefined } from 'twenty-shared/utils';
-import { Autocomplete } from 'twenty-ui/primitives/input';
+import {
+ type AutocompleteInputProps,
+ Autocomplete,
+} from 'twenty-ui/primitives/input';
import { themeCssVariables } from 'twenty-ui/theme';
import { useDebouncedCallback } from 'use-debounce';
@@ -47,6 +49,7 @@ import { usePushFocusItemToFocusStack } from '@/ui/utilities/focus/hooks/usePush
import { useRemoveFocusItemFromFocusStackById } from '@/ui/utilities/focus/hooks/useRemoveFocusItemFromFocusStackById';
import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';
import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement';
+import { isKeyboardEventComposing } from '@/ui/utilities/hotkey/utils/isKeyboardEventComposing';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
const SUGGESTIONS_SEARCH_DEBOUNCE_MS = 300;
@@ -420,8 +423,12 @@ export const EmailRecipientsFieldInput = ({
dependencies: [handleSubmitHotkey],
});
- const handleInputKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
- if (event.ctrlKey || event.metaKey) {
+ const handleInputKeyDown: AutocompleteInputProps['onKeyDown'] = (event) => {
+ if (
+ isKeyboardEventComposing(event.nativeEvent) ||
+ event.ctrlKey ||
+ event.metaKey
+ ) {
return;
}
@@ -433,6 +440,7 @@ export const EmailRecipientsFieldInput = ({
switch (event.key) {
case 'Enter': {
event.preventDefault();
+ event.preventBaseUIHandler();
if (!isEditing && isDropdownOpen && suggestions.length > 0) {
const highlightedSuggestionId = store.get(
@@ -471,6 +479,7 @@ export const EmailRecipientsFieldInput = ({
case ',':
case ';': {
event.preventDefault();
+ event.preventBaseUIHandler();
if (!bufferIsEmpty) {
commitInputAndCloseSuggestions();
@@ -480,6 +489,7 @@ export const EmailRecipientsFieldInput = ({
case ' ': {
if (isValidEmailRecipientAddress(inputValue.trim())) {
event.preventDefault();
+ event.preventBaseUIHandler();
commitInputAndCloseSuggestions();
}
return;
@@ -490,6 +500,7 @@ export const EmailRecipientsFieldInput = ({
}
event.preventDefault();
+ event.preventBaseUIHandler();
if (selectedChipIndices.length > 0) {
removeSelectedRecipients();
@@ -502,6 +513,7 @@ export const EmailRecipientsFieldInput = ({
case 'Delete': {
if (bufferIsEmpty && selectedChipIndices.length > 0) {
event.preventDefault();
+ event.preventBaseUIHandler();
removeSelectedRecipients();
}
return;
@@ -509,6 +521,7 @@ export const EmailRecipientsFieldInput = ({
case 'ArrowDown': {
if (!isEditing && !isDropdownOpen && suggestions.length > 0) {
event.preventDefault();
+ event.preventBaseUIHandler();
openSuggestions();
}
return;
@@ -519,6 +532,7 @@ export const EmailRecipientsFieldInput = ({
}
event.preventDefault();
+ event.preventBaseUIHandler();
scrollChipIntoView(
event.shiftKey ? extendChipSelection(-1) : moveChipSelection(-1),
);
@@ -530,6 +544,7 @@ export const EmailRecipientsFieldInput = ({
}
event.preventDefault();
+ event.preventBaseUIHandler();
scrollChipIntoView(
event.shiftKey ? extendChipSelection(1) : moveChipSelection(1),
);
@@ -538,6 +553,7 @@ export const EmailRecipientsFieldInput = ({
case 'Escape': {
if (isDropdownOpen) {
event.preventDefault();
+ event.preventBaseUIHandler();
event.stopPropagation();
closeSuggestions();
return;
@@ -545,12 +561,14 @@ export const EmailRecipientsFieldInput = ({
if (isEditing) {
event.preventDefault();
+ event.preventBaseUIHandler();
cancelEditing();
return;
}
if (selectedChipIndices.length > 0) {
event.preventDefault();
+ event.preventBaseUIHandler();
clearChipSelection();
}
return;
diff --git a/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/EmailRecipientsFieldInput.stories.tsx b/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/EmailRecipientsFieldInput.stories.tsx
index 6714be3bc26..8a68b570d00 100644
--- a/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/EmailRecipientsFieldInput.stories.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/recipients/components/__stories__/EmailRecipientsFieldInput.stories.tsx
@@ -1,6 +1,13 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { HttpResponse, graphql } from 'msw';
-import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import {
+ expect,
+ fireEvent,
+ fn,
+ userEvent,
+ waitFor,
+ within,
+} from 'storybook/test';
import { ComponentDecorator } from 'twenty-ui/testing';
import { StatefulEmailRecipientsFieldInput } from '@/activities/emails/recipients/components/__stories__/StatefulEmailRecipientsFieldInput';
@@ -125,6 +132,47 @@ export const CommitsBufferWhileSearchIsPending: Story = {
expect(canvas.getByText('[email protected]')).toBeVisible();
expect(canvas.queryByText('Jeffery Griffin')).not.toBeInTheDocument();
expect(input).toHaveValue('');
+ expect(input).toHaveFocus();
+ await waitFor(() =>
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument(),
+ );
+ },
+};
+
+export const KeepsCompositionConfirmationInTheInput: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const screen = within(canvasElement.ownerDocument.body);
+ const input = await canvas.findByRole('combobox', { name: 'To' });
+
+ await userEvent.type(input, 'jeff');
+ await screen.findByRole('option', { name: /Jeffery Griffin/ });
+ fireEvent.compositionStart(input);
+ fireEvent.keyDown(input, {
+ key: 'Enter',
+ code: 'Enter',
+ keyCode: 229,
+ which: 229,
+ isComposing: true,
+ });
+
+ expect(input).toHaveValue('jeff');
+ expect(
+ within(canvas.getByRole('group', { name: 'to recipients' })).queryByText(
+ 'Jeffery Griffin',
+ ),
+ ).not.toBeInTheDocument();
+ expect(screen.getByRole('listbox')).toBeVisible();
+
+ fireEvent.compositionEnd(input);
+ await userEvent.keyboard('{Enter}');
+
+ expect(canvas.getByText('Jeffery Griffin')).toBeVisible();
+ expect(input).toHaveValue('');
+ expect(input).toHaveFocus();
+ await waitFor(() =>
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument(),
+ );
},
};
diff --git a/packages/twenty-front/src/modules/ui/field/input/components/AddressInput.tsx b/packages/twenty-front/src/modules/ui/field/input/components/AddressInput.tsx
index 10f7f81c181..4a0c94ff41a 100644
--- a/packages/twenty-front/src/modules/ui/field/input/components/AddressInput.tsx
+++ b/packages/twenty-front/src/modules/ui/field/input/components/AddressInput.tsx
@@ -10,8 +10,8 @@ import { TextInput } from '@/ui/input/components/TextInput';
import { AutocompleteRoot } from '@/ui/input/components/AutocompleteRoot';
import { type AddressInputProps } from '@/ui/field/input/types/AddressInputProps';
import { CountrySelect } from '@/ui/input/components/internal/country/components/CountrySelect';
-import { Autocomplete } from 'twenty-ui/primitives/input';
import { isDefined } from 'twenty-shared/utils';
+import { Autocomplete } from 'twenty-ui/primitives/input';
import { MOBILE_VIEWPORT } from 'twenty-ui/theme';
import { turnIntoEmptyStringIfWhitespacesOnly } from '~/utils/string/turnIntoEmptyStringIfWhitespacesOnly';
diff --git a/packages/twenty-front/src/modules/ui/input/components/AutocompleteContent.tsx b/packages/twenty-front/src/modules/ui/input/components/AutocompleteContent.tsx
index d708c475579..53236c961f7 100644
--- a/packages/twenty-front/src/modules/ui/input/components/AutocompleteContent.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/AutocompleteContent.tsx
@@ -6,8 +6,9 @@ import { ParentClickOutsideIdContext } from '@/ui/utilities/pointer-event/contex
type AutocompleteContentProps = Pick<
ComponentProps<typeof Autocomplete.Popup>,
- 'children' | 'align' | 'sideOffset' | 'width'
->;
+ 'children' | 'width'
+> &
+ Pick<ComponentProps<typeof Autocomplete.Positioner>, 'align' | 'sideOffset'>;
export const AutocompleteContent = ({
children,
@@ -22,16 +23,18 @@ export const AutocompleteContent = ({
};
return (
- <Autocomplete.Popup
- data-click-outside-id={parentClickOutsideId}
- align={align}
- sideOffset={sideOffset}
- width={width}
- onMouseDown={keepFocusInInput}
- >
- <DropdownClickOutsideListenerExclusion>
- {children}
- </DropdownClickOutsideListenerExclusion>
- </Autocomplete.Popup>
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner align={align} sideOffset={sideOffset}>
+ <Autocomplete.Popup
+ data-click-outside-id={parentClickOutsideId}
+ width={width}
+ onMouseDown={keepFocusInInput}
+ >
+ <DropdownClickOutsideListenerExclusion>
+ {children}
+ </DropdownClickOutsideListenerExclusion>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
);
};
diff --git a/packages/twenty-front/src/modules/ui/input/components/AutocompleteRoot.tsx b/packages/twenty-front/src/modules/ui/input/components/AutocompleteRoot.tsx
index 2ad6069db21..bb922da0924 100644
--- a/packages/twenty-front/src/modules/ui/input/components/AutocompleteRoot.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/AutocompleteRoot.tsx
@@ -1,5 +1,6 @@
import { type ReactNode } from 'react';
import { isNonEmptyArray } from 'twenty-shared/utils';
+import { preventDismissingClickActivation } from 'twenty-ui/utilities';
import {
type AutocompleteRootProps as AutocompletePrimitiveRootProps,
Autocomplete,
@@ -76,16 +77,23 @@ export const AutocompleteRoot = <TItem,>({
return;
}
- if (!open) {
- closeDropdown(dropdownId);
- onClose?.();
+ if (open) {
+ openDropdown({
+ dropdownComponentInstanceIdFromProps: dropdownId,
+ globalHotkeysConfig,
+ });
return;
}
- openDropdown({
- dropdownComponentInstanceIdFromProps: dropdownId,
- globalHotkeysConfig,
- });
+ closeDropdown(dropdownId);
+ onClose?.();
+
+ const shouldPreventOutsideClickActivation =
+ details.reason === 'outside-press' && !details.isCanceled;
+
+ if (shouldPreventOutsideClickActivation) {
+ preventDismissingClickActivation(details.event);
+ }
};
const handleItemHighlighted: AutocompletePrimitiveRootProps<TItem>['onItemHighlighted'] =
diff --git a/packages/twenty-front/src/modules/ui/input/components/__tests__/AutocompleteRoot.test.tsx b/packages/twenty-front/src/modules/ui/input/components/__tests__/AutocompleteRoot.test.tsx
index ec4a66b56ac..6a475ec0f6c 100644
--- a/packages/twenty-front/src/modules/ui/input/components/__tests__/AutocompleteRoot.test.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/__tests__/AutocompleteRoot.test.tsx
@@ -66,6 +66,54 @@ const AutocompleteExample = ({
};
describe('AutocompleteRoot', () => {
+ it('dismisses a picker before activating the outside target on a later click', async () => {
+ const user = userEvent.setup();
+ const store = createStore();
+ const onOutsideClick = jest.fn();
+
+ render(
+ <JotaiProvider store={store}>
+ <AutocompleteExample />
+ <button onClick={onOutsideClick}>Outside action</button>
+ </JotaiProvider>,
+ );
+
+ const outsideButton = screen.getByRole('button', {
+ name: 'Outside action',
+ });
+ await user.type(screen.getByRole('combobox'), 'Pa');
+ await user.click(outsideButton);
+
+ await waitFor(() =>
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument(),
+ );
+ expect(onOutsideClick).not.toHaveBeenCalled();
+ expect(store.get(focusStackState.atom)).toEqual([]);
+
+ await user.click(outsideButton);
+
+ expect(onOutsideClick).toHaveBeenCalledTimes(1);
+ });
+
+ it('allows an outside target to activate after keyboard dismissal', async () => {
+ const user = userEvent.setup();
+ const store = createStore();
+ const onOutsideClick = jest.fn();
+
+ render(
+ <JotaiProvider store={store}>
+ <AutocompleteExample />
+ <button onClick={onOutsideClick}>Outside action</button>
+ </JotaiProvider>,
+ );
+
+ await user.type(screen.getByRole('combobox'), 'Pa');
+ await user.keyboard('{Escape}');
+ await user.click(screen.getByRole('button', { name: 'Outside action' }));
+
+ expect(onOutsideClick).toHaveBeenCalledTimes(1);
+ });
+
it('keeps input focus while navigating and restores the focus stack on Escape', async () => {
const user = userEvent.setup();
const store = createStore();
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 353508c6038..cce8b646c21 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -415,10 +415,37 @@ export const DOCUMENTED_COMPONENTS = [
source: 'primitives/input/Autocomplete/Autocomplete.tsx',
entryPoint: 'twenty-ui/primitives/input',
slug: 'input/autocomplete',
+ partPropOverrides: {
+ Root: {
+ items: {
+ type: 'readonly TItem[] | readonly { items: readonly TItem[] }[]',
+ required: false,
+ },
+ filteredItems: {
+ type: 'readonly TItem[] | readonly { items: readonly TItem[] }[]',
+ },
+ filter: {
+ type: 'AutocompleteRootProps<TItem>["filter"]',
+ },
+ itemToStringValue: {
+ type: '(itemValue: TItem) => string',
+ },
+ onItemHighlighted: {
+ type: '(highlightedValue: TItem | undefined, eventDetails: AutocompleteRootHighlightEventDetails) => void',
+ },
+ },
+ },
partPropDescriptions: {
Root: {
items:
- 'Items to display in the list. Nullish entries are not supported.',
+ 'Flat items or groups with an items array. Preserves the upstream item type; nullish entries are not supported.',
+ },
+ Value: {
+ children:
+ 'Content or render function receiving the current input text.',
+ },
+ Collection: {
+ children: 'Render function receiving each filtered item and its index.',
},
Input: {
size: 'Visual size of the input. Inside an InputGroup, the group size applies.',
@@ -426,8 +453,16 @@ export const DOCUMENTED_COMPONENTS = [
Popup: {
width:
'Width of the popup. Overrides its default minimum anchor width.',
+ },
+ Portal: {
container:
- 'Element the popup is portaled into. Defaults to the theme portal container.',
+ 'Portal destination. Omitted uses the scoped theme container; explicit null waits without rendering. Element, ShadowRoot and ref targets pass through to Base UI.',
+ },
+ Positioner: {
+ ref: 'Ref to the positioning div, separate from Popup and Portal.',
+ sideOffset:
+ 'Distance from the anchor. Defaults to 8; supports functional offsets.',
+ align: 'Alignment relative to the anchor. Defaults to start.',
},
},
},
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index ba3248aebcd..2fac6a35e04 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -800,13 +800,55 @@
"Textarea": "primitives/input/Textarea/Textarea"
},
"types": {
+ "AutocompleteArrowProps": "primitives/input/Autocomplete/types/AutocompleteArrowProps",
+ "AutocompleteArrowState": "primitives/input/Autocomplete/types/AutocompleteArrowState",
+ "AutocompleteBackdropProps": "primitives/input/Autocomplete/types/AutocompleteBackdropProps",
+ "AutocompleteBackdropState": "primitives/input/Autocomplete/types/AutocompleteBackdropState",
+ "AutocompleteClearProps": "primitives/input/Autocomplete/types/AutocompleteClearProps",
+ "AutocompleteClearState": "primitives/input/Autocomplete/types/AutocompleteClearState",
+ "AutocompleteCollectionProps": "primitives/input/Autocomplete/types/AutocompleteCollectionProps",
+ "AutocompleteCollectionState": "primitives/input/Autocomplete/types/AutocompleteCollectionState",
"AutocompleteEmptyProps": "primitives/input/Autocomplete/types/AutocompleteEmptyProps",
+ "AutocompleteEmptyState": "primitives/input/Autocomplete/types/AutocompleteEmptyState",
+ "AutocompleteFilter": "primitives/input/Autocomplete/types/AutocompleteFilter",
+ "AutocompleteFilterOptions": "primitives/input/Autocomplete/types/AutocompleteFilterOptions",
+ "AutocompleteGroupLabelProps": "primitives/input/Autocomplete/types/AutocompleteGroupLabelProps",
+ "AutocompleteGroupLabelState": "primitives/input/Autocomplete/types/AutocompleteGroupLabelState",
+ "AutocompleteGroupProps": "primitives/input/Autocomplete/types/AutocompleteGroupProps",
+ "AutocompleteGroupState": "primitives/input/Autocomplete/types/AutocompleteGroupState",
+ "AutocompleteIconProps": "primitives/input/Autocomplete/types/AutocompleteIconProps",
+ "AutocompleteIconState": "primitives/input/Autocomplete/types/AutocompleteIconState",
"AutocompleteInputGroupProps": "primitives/input/Autocomplete/types/AutocompleteInputGroupProps",
+ "AutocompleteInputGroupState": "primitives/input/Autocomplete/types/AutocompleteInputGroupState",
"AutocompleteInputProps": "primitives/input/Autocomplete/types/AutocompleteInputProps",
+ "AutocompleteInputState": "primitives/input/Autocomplete/types/AutocompleteInputState",
"AutocompleteItemProps": "primitives/input/Autocomplete/types/AutocompleteItemProps",
+ "AutocompleteItemState": "primitives/input/Autocomplete/types/AutocompleteItemState",
"AutocompleteListProps": "primitives/input/Autocomplete/types/AutocompleteListProps",
+ "AutocompleteListState": "primitives/input/Autocomplete/types/AutocompleteListState",
"AutocompletePopupProps": "primitives/input/Autocomplete/types/AutocompletePopupProps",
+ "AutocompletePopupState": "primitives/input/Autocomplete/types/AutocompletePopupState",
+ "AutocompletePortalProps": "primitives/input/Autocomplete/types/AutocompletePortalProps",
+ "AutocompletePortalState": "primitives/input/Autocomplete/types/AutocompletePortalState",
+ "AutocompletePositionerProps": "primitives/input/Autocomplete/types/AutocompletePositionerProps",
+ "AutocompletePositionerState": "primitives/input/Autocomplete/types/AutocompletePositionerState",
+ "AutocompleteRootActions": "primitives/input/Autocomplete/types/AutocompleteRootActions",
+ "AutocompleteRootChangeEventDetails": "primitives/input/Autocomplete/types/AutocompleteRootChangeEventDetails",
+ "AutocompleteRootChangeEventReason": "primitives/input/Autocomplete/types/AutocompleteRootChangeEventReason",
+ "AutocompleteRootHighlightEventDetails": "primitives/input/Autocomplete/types/AutocompleteRootHighlightEventDetails",
+ "AutocompleteRootHighlightEventReason": "primitives/input/Autocomplete/types/AutocompleteRootHighlightEventReason",
"AutocompleteRootProps": "primitives/input/Autocomplete/types/AutocompleteRootProps",
+ "AutocompleteRootState": "primitives/input/Autocomplete/types/AutocompleteRootState",
+ "AutocompleteRowProps": "primitives/input/Autocomplete/types/AutocompleteRowProps",
+ "AutocompleteRowState": "primitives/input/Autocomplete/types/AutocompleteRowState",
+ "AutocompleteSeparatorProps": "primitives/input/Autocomplete/types/AutocompleteSeparatorProps",
+ "AutocompleteSeparatorState": "primitives/input/Autocomplete/types/AutocompleteSeparatorState",
+ "AutocompleteStatusProps": "primitives/input/Autocomplete/types/AutocompleteStatusProps",
+ "AutocompleteStatusState": "primitives/input/Autocomplete/types/AutocompleteStatusState",
+ "AutocompleteTriggerProps": "primitives/input/Autocomplete/types/AutocompleteTriggerProps",
+ "AutocompleteTriggerState": "primitives/input/Autocomplete/types/AutocompleteTriggerState",
+ "AutocompleteValueProps": "primitives/input/Autocomplete/types/AutocompleteValueProps",
+ "AutocompleteValueState": "primitives/input/Autocomplete/types/AutocompleteValueState",
"ButtonColor": "primitives/input/Button/types/ButtonColor",
"ButtonGroupProps": "primitives/input/ButtonGroup/types/ButtonGroupProps",
"ButtonLoadingPosition": "primitives/input/Button/types/ButtonLoadingPosition",
@@ -1165,6 +1207,7 @@
"MOBILE_MEDIA_QUERY": "utilities/responsive/constants/MobileMediaQuery",
"normalizeSearchText": "utilities/utils/normalizeSearchText",
"parseThemeColor": "utilities/color/utils/parseThemeColor",
+ "preventDismissingClickActivation": "utilities/utils/preventDismissingClickActivation",
"stringToThemeColor": "utilities/color/utils/stringToThemeColorP3String",
"stringToThemeColorP3String": "utilities/color/utils/stringToThemeColorP3String",
"themeColorSchema": "utilities/color/utils/themeColorSchema",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 30bc0732c02..700c4682bf8 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -3978,14 +3978,14 @@
},
{
"name": "filter",
- "type": "((item: TItem, query: string, itemToString?: ((item: TItem) => string) | undefined) => boolean) | null",
+ "type": "AutocompleteRootProps<TItem>[\"filter\"]",
"required": false,
"defaultValue": null,
"description": "Filter function used to match items against the input query."
},
{
"name": "filteredItems",
- "type": "readonly TItem[] | readonly Group<TItem>[]",
+ "type": "readonly TItem[] | readonly { items: readonly TItem[] }[]",
"required": false,
"defaultValue": null,
"description": "Filtered items to display in the list.\nWhen provided, the list uses these items instead of filtering the `items` prop internally.\nWhen `items` is also provided, this array must preserve its flat or grouped structure.\nNullish entries are not supported, as in `items`.\nUse when you want to control filtering logic externally with the `useFilter()` hook."
@@ -4034,14 +4034,14 @@
},
{
"name": "items",
- "type": "readonly TItem[]",
+ "type": "readonly TItem[] | readonly { items: readonly TItem[] }[]",
"required": false,
"defaultValue": null,
- "description": "Items to display in the list. Nullish entries are not supported."
+ "description": "Flat items or groups with an items array. Preserves the upstream item type; nullish entries are not supported."
},
{
"name": "itemToStringValue",
- "type": "((itemValue: TItem) => string)",
+ "type": "(itemValue: TItem) => string",
"required": false,
"defaultValue": null,
"description": "When the item values are objects (`<Autocomplete.Item value={object}>`), this function converts the object value to a string representation for both display in the input and form submission.\nIf the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop."
@@ -4097,7 +4097,7 @@
},
{
"name": "onItemHighlighted",
- "type": "((highlightedValue: TItem | undefined, eventDetails: HighlightEventDetails) => void)",
+ "type": "(highlightedValue: TItem | undefined, eventDetails: AutocompleteRootHighlightEventDetails) => void",
"required": false,
"defaultValue": null,
"description": "Callback fired when an item is highlighted or unhighlighted.\nReceives the highlighted item value (or `undefined` if no item is highlighted) and event details with a `reason` property describing why the highlight changed.\nThe `reason` can be:\n- `'keyboard'`: the highlight changed due to keyboard navigation.\n- `'pointer'`: the highlight changed due to pointer hovering.\n- `'none'`: the highlight changed programmatically."
@@ -4174,6 +4174,58 @@
}
]
},
+ {
+ "name": "Value",
+ "props": [
+ {
+ "name": "children",
+ "type": "ReactNode | ((value: string) => ReactNode)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Content or render function receiving the current input text."
+ }
+ ]
+ },
+ {
+ "name": "Trigger",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: AutocompleteTriggerState) => 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": "disabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether the component should ignore user interaction."
+ },
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the component renders a native `<button>` element when replacing it\nvia the `render` prop.\nSet to `false` if the rendered element is not a button (for example, `<div>`)."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, AutocompleteTriggerState>",
+ "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: AutocompleteTriggerState) => 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": "InputGroup",
"props": [
@@ -4241,14 +4293,153 @@
]
},
{
- "name": "Popup",
+ "name": "Icon",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ComboboxIconState) => 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": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxIconState>",
+ "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: ComboboxIconState) => 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": "Clear",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ComboboxClearState) => 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": "disabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether the component should ignore user interaction."
+ },
+ {
+ "name": "keepMounted",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether the component should remain mounted in the DOM when not visible."
+ },
+ {
+ "name": "nativeButton",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "true",
+ "description": "Whether the component renders a native `<button>` element when replacing it\nvia the `render` prop.\nSet to `false` if the rendered element is not a button (for example, `<div>`)."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxClearState>",
+ "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: ComboboxClearState) => 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": "Portal",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ComboboxPortalState) => 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": "Portal destination. Omitted uses the scoped theme container; explicit null waits without rendering. Element, ShadowRoot and ref targets pass through to Base UI."
+ },
+ {
+ "name": "keepMounted",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether to keep the portal mounted in the DOM while the popup is hidden."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxPortalState>",
+ "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: ComboboxPortalState) => 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: ComboboxBackdropState) => 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": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxBackdropState>",
+ "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: ComboboxBackdropState) => 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": "start",
- "description": "How to align the popup relative to the specified side."
+ "description": "Alignment relative to the anchor. Defaults to start."
},
{
"name": "alignOffset",
@@ -4264,13 +4455,34 @@
"defaultValue": null,
"description": "An element to position the popup against.\nBy default, the popup will be positioned against the trigger."
},
+ {
+ "name": "arrowPadding",
+ "type": "number",
+ "required": false,
+ "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: ComboboxPopupState) => string | undefined)",
+ "type": "string | ((state: ComboboxPositionerState) => 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",
@@ -4279,29 +4491,29 @@
"description": "Additional space to maintain from the edge of the collision boundary."
},
{
- "name": "container",
- "type": "HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null",
+ "name": "disableAnchorTracking",
+ "type": "boolean",
"required": false,
- "defaultValue": null,
- "description": "Element the popup is portaled into. Defaults to the theme portal container."
+ "defaultValue": "false",
+ "description": "Whether to disable the popup from tracking any layout shift of its positioning anchor."
},
{
- "name": "finalFocus",
- "type": "boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null)",
+ "name": "positionMethod",
+ "type": "\"absolute\" | \"fixed\"",
"required": false,
- "defaultValue": null,
- "description": "Determines the element to focus when the popup is closed.\n\n- `false`: Do not move focus.\n- `true`: Move focus based on the default behavior (trigger or previously focused element).\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, or `false`/`undefined` to do nothing."
+ "defaultValue": "absolute",
+ "description": "Determines which CSS `position` property to use."
},
{
- "name": "initialFocus",
- "type": "boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null)",
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
"required": false,
"defaultValue": null,
- "description": "Determines the element to focus when the popup is opened.\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, or `false`/`undefined` to do nothing."
+ "description": "Ref to the positioning div, separate from Popup and Portal."
},
{
"name": "render",
- "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxPopupState>",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxPositionerState>",
"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."
@@ -4318,7 +4530,54 @@
"type": "number | OffsetFunction",
"required": false,
"defaultValue": "8",
- "description": "Distance between the anchor and the popup in pixels.\nAlso accepts a function that returns the distance 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."
+ "description": "Distance from the anchor. Defaults to 8; supports functional offsets."
+ },
+ {
+ "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: ComboboxPositionerState) => 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": "className",
+ "type": "string | ((state: ComboboxPopupState) => 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",
+ "type": "boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Determines the element to focus when the popup is closed.\n\n- `false`: Do not move focus.\n- `true`: Move focus based on the default behavior (trigger or previously focused element).\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, or `false`/`undefined` to do nothing."
+ },
+ {
+ "name": "initialFocus",
+ "type": "boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Determines the element to focus when the popup is opened.\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, or `false`/`undefined` to do nothing."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxPopupState>",
+ "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",
@@ -4336,6 +4595,32 @@
}
]
},
+ {
+ "name": "Arrow",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ComboboxArrowState) => 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": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxArrowState>",
+ "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: ComboboxArrowState) => 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": "List",
"props": [
@@ -4362,6 +4647,91 @@
}
]
},
+ {
+ "name": "Status",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ComboboxStatusState) => 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": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxStatusState>",
+ "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: ComboboxStatusState) => 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": "Group",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ComboboxGroupState) => 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": "items",
+ "type": "readonly any[]",
+ "required": false,
+ "defaultValue": null,
+ "description": "Items to be rendered within this group.\nWhen provided, child `Collection` components will use these items."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxGroupState>",
+ "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: ComboboxGroupState) => 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": "GroupLabel",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ComboboxGroupLabelState) => 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": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxGroupLabelState>",
+ "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: ComboboxGroupLabelState) => 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": "Item",
"props": [
@@ -4451,6 +4821,44 @@
}
]
},
+ {
+ "name": "Row",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ComboboxRowState) => 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": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ComboboxRowState>",
+ "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: ComboboxRowState) => 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": "Collection",
+ "props": [
+ {
+ "name": "children",
+ "type": "(item: any, index: number) => ReactNode",
+ "required": true,
+ "defaultValue": null,
+ "description": "Render function receiving each filtered item and its index."
+ }
+ ]
+ },
{
"name": "Empty",
"props": [
@@ -4476,6 +4884,39 @@
"description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
}
]
+ },
+ {
+ "name": "Separator",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: AutocompleteSeparatorState) => 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": "orientation",
+ "type": "\"horizontal\" | \"vertical\"",
+ "required": false,
+ "defaultValue": "horizontal",
+ "description": "The orientation of the separator."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, AutocompleteSeparatorState>",
+ "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: AutocompleteSeparatorState) => 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."
+ }
+ ]
}
]
},
diff --git a/packages/twenty-ui/scripts/generateDocsData.ts b/packages/twenty-ui/scripts/generateDocsData.ts
index af66f5765ab..fc142f33480 100644
--- a/packages/twenty-ui/scripts/generateDocsData.ts
+++ b/packages/twenty-ui/scripts/generateDocsData.ts
@@ -143,11 +143,13 @@ const extractProps = ({
name,
propDescriptions = {},
propDefaults = {},
+ propOverrides = {},
}: {
symbol: ts.Symbol;
name: string;
propDescriptions?: Partial<Record<string, string>>;
propDefaults?: Partial<Record<string, string>>;
+ propOverrides?: Partial<Record<string, { type: string; required?: boolean }>>;
}): ComponentDocumentation['props'] => {
const declaration = symbol.valueDeclaration;
@@ -197,13 +199,17 @@ const extractProps = ({
);
}
+ const propOverride = propOverrides[prop.name];
+
return {
name: prop.name,
- type: normalizeDocumentationPropType({
- type: prop.type,
- required: prop.required,
- }),
- required: prop.required,
+ type:
+ propOverride?.type ??
+ normalizeDocumentationPropType({
+ type: prop.type,
+ required: prop.required,
+ }),
+ required: propOverride?.required ?? prop.required,
defaultValue:
propDefaults[prop.name] ??
normalizeDocumentationDefaultValue(prop.defaultValue),
@@ -259,6 +265,12 @@ const components: ComponentDocumentation[] = DOCUMENTED_COMPONENTS.map(
const partPropDefaults: Partial<
Record<string, Partial<Record<string, string>>>
> = 'partPropDefaults' in component ? component.partPropDefaults : {};
+ const partPropOverrides: Partial<
+ Record<
+ string,
+ Partial<Record<string, { type: string; required?: boolean }>>
+ >
+ > = 'partPropOverrides' in component ? component.partPropOverrides : {};
const componentParts = type
.getProperties()
.filter((part) => COMPONENT_PART_NAME_PATTERN.test(part.name))
@@ -287,6 +299,7 @@ const components: ComponentDocumentation[] = DOCUMENTED_COMPONENTS.map(
name: `${component.name}.${part.name}`,
propDescriptions: partPropDescriptions[part.name],
propDefaults: partPropDefaults[part.name],
+ propOverrides: partPropOverrides[part.name],
}),
};
});
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownRoot.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownRoot.tsx
index 1c6fb89fd55..b064f92a37a 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownRoot.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownRoot.tsx
@@ -1,7 +1,7 @@
import { useCallback, useContext, useRef, useState } from 'react';
import { Popover } from '@ui/primitives/surfaces/Popover/Popover';
-import { preventDismissingClickActivation } from '@ui/utilities/internal/preventDismissingClickActivation';
+import { preventDismissingClickActivation } from '@ui/utilities/utils/preventDismissingClickActivation';
import { isDefined } from '@ui/utilities/utils/isDefined';
import { type DropdownRootProps } from '../types/DropdownRootProps';
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.module.scss b/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.module.scss
index b1f71cd5eee..84a12a9386a 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.module.scss
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.module.scss
@@ -28,6 +28,10 @@
padding: var(--t-spacing-1);
transition: opacity duration(fast) ease-out;
+ &:has(> .arrow) {
+ overflow: visible;
+ }
+
&[data-starting-style],
&[data-ending-style] {
opacity: 0;
@@ -38,6 +42,67 @@
}
}
+.arrow {
+ --tw-autocomplete-arrow-size: 6px;
+
+ position: absolute;
+ background: inherit;
+ backdrop-filter: var(--t-blur-medium);
+
+ &[data-side='top'],
+ &[data-side='bottom'] {
+ width: calc(2 * var(--tw-autocomplete-arrow-size));
+ height: var(--tw-autocomplete-arrow-size);
+ }
+
+ &[data-side='left'],
+ &[data-side='right'],
+ &[data-side='inline-start'],
+ &[data-side='inline-end'] {
+ width: var(--tw-autocomplete-arrow-size);
+ height: calc(2 * var(--tw-autocomplete-arrow-size));
+ }
+
+ &[data-side='top'] {
+ bottom: calc(-1 * var(--tw-autocomplete-arrow-size));
+ clip-path: polygon(0 0, 100% 0, 50% 100%);
+ }
+
+ &[data-side='bottom'] {
+ top: calc(-1 * var(--tw-autocomplete-arrow-size));
+ clip-path: polygon(50% 0, 100% 100%, 0 100%);
+ }
+
+ &[data-side='left'],
+ &[data-side='inline-start']:dir(ltr),
+ &[data-side='inline-end']:dir(rtl) {
+ right: calc(-1 * var(--tw-autocomplete-arrow-size));
+ clip-path: polygon(0 0, 100% 50%, 0 100%);
+ }
+
+ &[data-side='right'],
+ &[data-side='inline-end']:dir(ltr),
+ &[data-side='inline-start']:dir(rtl) {
+ left: calc(-1 * var(--tw-autocomplete-arrow-size));
+ clip-path: polygon(100% 0, 100% 100%, 0 50%);
+ }
+}
+
+.separator {
+ block-size: 1px;
+ flex: none;
+ background: var(--t-border-color-light);
+ margin-inline: calc(-1 * var(--t-spacing-1));
+
+ &[data-orientation='vertical'] {
+ block-size: auto;
+ inline-size: 1px;
+ margin-block: calc(-1 * var(--t-spacing-1));
+ margin-inline: 0;
+ align-self: stretch;
+ }
+}
+
.list {
max-block-size: 176px;
outline: none;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.module.scss.d.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.module.scss.d.ts
index 154524e3c5d..10d5e8ab087 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.module.scss.d.ts
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.module.scss.d.ts
@@ -2,6 +2,8 @@ declare const classNames: {
readonly inputGroup: 'inputGroup';
readonly positioner: 'positioner';
readonly popup: 'popup';
+ readonly arrow: 'arrow';
+ readonly separator: 'separator';
readonly list: 'list';
readonly empty: 'empty';
};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.tsx
index 1b29d98ccc1..63eebedb884 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.tsx
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/Autocomplete.tsx
@@ -1,19 +1,40 @@
+import { Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+import { AutocompleteArrow } from './internal/AutocompleteArrow';
import { AutocompleteEmpty } from './internal/AutocompleteEmpty';
import { AutocompleteInput } from './internal/AutocompleteInput';
import { AutocompleteInputGroup } from './internal/AutocompleteInputGroup';
import { AutocompleteItem } from './internal/AutocompleteItem';
import { AutocompleteList } from './internal/AutocompleteList';
import { AutocompletePopup } from './internal/AutocompletePopup';
-import { AutocompleteRoot } from './internal/AutocompleteRoot';
+import { AutocompletePortal } from './internal/AutocompletePortal';
+import { AutocompletePositioner } from './internal/AutocompletePositioner';
+import { AutocompleteSeparator } from './internal/AutocompleteSeparator';
const createAutocomplete = () => ({
- Root: AutocompleteRoot,
+ Root: AutocompletePrimitive.Root,
+ Value: AutocompletePrimitive.Value,
+ Trigger: AutocompletePrimitive.Trigger,
InputGroup: AutocompleteInputGroup,
Input: AutocompleteInput,
+ Icon: AutocompletePrimitive.Icon,
+ Clear: AutocompletePrimitive.Clear,
+ Portal: AutocompletePortal,
+ Backdrop: AutocompletePrimitive.Backdrop,
+ Positioner: AutocompletePositioner,
Popup: AutocompletePopup,
+ Arrow: AutocompleteArrow,
List: AutocompleteList,
+ Status: AutocompletePrimitive.Status,
+ Group: AutocompletePrimitive.Group,
+ GroupLabel: AutocompletePrimitive.GroupLabel,
Item: AutocompleteItem,
+ Row: AutocompletePrimitive.Row,
+ Collection: AutocompletePrimitive.Collection,
Empty: AutocompleteEmpty,
+ Separator: AutocompleteSeparator,
+ useFilter: AutocompletePrimitive.useFilter,
+ useFilteredItems: AutocompletePrimitive.useFilteredItems,
});
export const Autocomplete = /* @__PURE__ */ createAutocomplete();
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.collection.stories.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.collection.stories.tsx
new file mode 100644
index 00000000000..981e17721d8
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.collection.stories.tsx
@@ -0,0 +1,82 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { ComponentDecorator } from '@ui/testing';
+
+import { AutocompleteFilteredExample } from './AutocompleteFilteredExample';
+import { AutocompleteGroupedExample } from './AutocompleteGroupedExample';
+
+const meta: Meta<typeof AutocompleteGroupedExample> = {
+ title: 'UI/Input/Autocomplete/Collections',
+ component: AutocompleteGroupedExample,
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 340, height: 340 } },
+};
+
+export default meta;
+type Story = StoryObj<typeof AutocompleteGroupedExample>;
+
+export const GroupedObjects: Story = {};
+
+export const GroupedObjectInteractions: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const input = canvas.getByRole('combobox', { name: 'City' });
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Show cities' }));
+ await body.findByRole('option', { name: 'Paris France' });
+ await waitFor(() => {
+ expect(body.getByText('Western Europe')).toBeVisible();
+ expect(body.getByText('Central Europe')).toBeVisible();
+ });
+ await userEvent.type(input, 'li');
+ const lisbon = await body.findByRole('option', { name: 'Lisbon Portugal' });
+ const berlin = body.getByRole('option', { name: 'Berlin Germany' });
+ await expect(
+ body.queryByRole('option', { name: 'Paris France' }),
+ ).not.toBeInTheDocument();
+ await waitFor(() =>
+ expect(input).toHaveAttribute('aria-activedescendant', lisbon.id),
+ );
+ await userEvent.keyboard('{ArrowDown}');
+ await expect(input).toHaveAttribute('aria-activedescendant', berlin.id);
+ await userEvent.keyboard('{Enter}');
+ await expect(input).toHaveValue('Berlin');
+ await expect(canvas.getByRole('status')).toHaveTextContent(
+ 'City query: Berlin',
+ );
+ await expect(input).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.click(canvas.getByRole('button', { name: 'Clear city' }));
+ await expect(input).toHaveValue('');
+ await expect(input).toHaveFocus();
+ await userEvent.type(input, 'Tokyo');
+ await expect(await body.findByText('No matching cities')).toBeVisible();
+ },
+};
+
+export const ExternalFiltering: Story = {
+ render: () => <AutocompleteFilteredExample />,
+ play: async ({ canvasElement }) => {
+ const input = within(canvasElement).getByRole('combobox', {
+ name: 'City prefix',
+ });
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.type(input, 'ri');
+ await expect(
+ await body.findByText('No city starts with this query'),
+ ).toBeVisible();
+ await expect(
+ body.queryByRole('option', { name: 'Paris' }),
+ ).not.toBeInTheDocument();
+ await userEvent.clear(input);
+ await userEvent.type(input, 'Pa');
+ const paris = await body.findByRole('option', { name: 'Paris' });
+ await waitFor(() =>
+ expect(input).toHaveAttribute('aria-activedescendant', paris.id),
+ );
+ await userEvent.keyboard('{Enter}');
+ await expect(input).toHaveValue('Paris');
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.composition.stories.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.composition.stories.tsx
new file mode 100644
index 00000000000..7aa7915d04e
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.composition.stories.tsx
@@ -0,0 +1,158 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import {
+ expect,
+ fireEvent,
+ fn,
+ userEvent,
+ waitFor,
+ within,
+} from 'storybook/test';
+
+import { ComponentDecorator } from '@ui/testing';
+
+import { type AutocompleteRootProps } from '../types/AutocompleteRootProps';
+import { AutocompleteExample } from './AutocompleteExample';
+
+const meta: Meta<typeof AutocompleteExample> = {
+ title: 'UI/Input/Autocomplete/Composition',
+ component: AutocompleteExample,
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 280, height: 260 } },
+};
+
+export default meta;
+type Story = StoryObj<typeof AutocompleteExample>;
+
+export const CallbackDetails: Story = {
+ args: {
+ onValueChange: fn(),
+ onOpenChange: fn(),
+ onItemHighlighted: fn(),
+ },
+ play: async ({ canvasElement, args }) => {
+ const input = within(canvasElement).getByRole('combobox', {
+ name: 'Fruit',
+ });
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.type(input, 'Ch');
+ const cherry = await body.findByRole('option', { name: 'Cherry' });
+ await waitFor(() =>
+ expect(input).toHaveAttribute('aria-activedescendant', cherry.id),
+ );
+ await expect(args.onValueChange).toHaveBeenLastCalledWith(
+ 'Ch',
+ expect.objectContaining({
+ reason: 'input-change',
+ event: expect.objectContaining({ type: 'input', target: input }),
+ cancel: expect.anything(),
+ allowPropagation: expect.anything(),
+ isCanceled: false,
+ }),
+ );
+ await expect(args.onItemHighlighted).toHaveBeenCalledWith(
+ 'Cherry',
+ expect.objectContaining({ reason: 'none' }),
+ );
+ await userEvent.keyboard('{Enter}');
+ await expect(input).toHaveValue('Cherry');
+ await expect(args.onValueChange).toHaveBeenLastCalledWith(
+ 'Cherry',
+ expect.objectContaining({
+ reason: 'item-press',
+ event: expect.objectContaining({ type: 'keydown', target: input }),
+ }),
+ );
+ await expect(args.onOpenChange).toHaveBeenLastCalledWith(
+ false,
+ expect.objectContaining({ reason: 'item-press' }),
+ );
+ },
+};
+
+export const CompositionConfirmation: Story = {
+ args: { onValueChange: fn() },
+ play: async ({ canvasElement, args }) => {
+ const input = within(canvasElement).getByRole('combobox', {
+ name: 'Fruit',
+ });
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.click(input);
+ await fireEvent.compositionStart(input);
+ await fireEvent.input(input, {
+ target: { value: 'Ch' },
+ inputType: 'insertCompositionText',
+ isComposing: true,
+ });
+ await body.findByRole('listbox');
+ const apple = body.getByRole('option', { name: 'Apple' });
+ await waitFor(() =>
+ expect(input).toHaveAttribute('aria-activedescendant', apple.id),
+ );
+ await expect(args.onValueChange).not.toHaveBeenCalled();
+ await fireEvent.keyDown(input, {
+ key: 'Enter',
+ code: 'Enter',
+ keyCode: 229,
+ which: 229,
+ isComposing: true,
+ });
+ await expect(input).toHaveValue('Ch');
+ await expect(input).toHaveAttribute('aria-expanded', 'true');
+ await expect(args.onValueChange).not.toHaveBeenCalled();
+ await fireEvent.compositionEnd(input, { data: 'Ch' });
+ const cherry = await body.findByRole('option', { name: 'Cherry' });
+ await waitFor(() =>
+ expect(input).toHaveAttribute('aria-activedescendant', cherry.id),
+ );
+ await expect(args.onValueChange).toHaveBeenLastCalledWith(
+ 'Ch',
+ expect.objectContaining({
+ reason: 'input-change',
+ event: expect.objectContaining({
+ type: 'compositionend',
+ target: input,
+ }),
+ }),
+ );
+ await userEvent.keyboard('{Enter}');
+ await expect(input).toHaveValue('Cherry');
+ await expect(input).toHaveAttribute('aria-expanded', 'false');
+ },
+};
+
+export const CancelledDismissal: Story = {
+ args: {
+ onOpenChange: fn<
+ NonNullable<AutocompleteRootProps<string>['onOpenChange']>
+ >((_nextOpen, details) => {
+ if (details.reason === 'escape-key') {
+ details.cancel();
+ }
+ }),
+ },
+ play: async ({ canvasElement, args }) => {
+ const input = within(canvasElement).getByRole('combobox', {
+ name: 'Fruit',
+ });
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.type(input, 'Ch');
+ await body.findByRole('option', { name: 'Cherry' });
+ await waitFor(() => expect(body.getByRole('listbox')).toBeVisible());
+ await userEvent.keyboard('{Escape}');
+ await expect(args.onOpenChange).toHaveBeenLastCalledWith(
+ false,
+ expect.objectContaining({
+ reason: 'escape-key',
+ event: expect.objectContaining({ type: 'keydown', target: input }),
+ isCanceled: true,
+ isPropagationAllowed: false,
+ }),
+ );
+ await expect(input).toHaveAttribute('aria-expanded', 'true');
+ await expect(input).toHaveFocus();
+ await expect(body.getByRole('listbox')).toBeVisible();
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.interactions.stories.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.interactions.stories.tsx
index 8dc4d2200af..cac0caefe25 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.interactions.stories.tsx
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.interactions.stories.tsx
@@ -3,6 +3,8 @@ import { useState } from 'react';
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
import { Button } from '@ui/primitives/input/Button/Button';
+import { Input } from '@ui/primitives/input/Input/Input';
+import { Text } from '@ui/primitives/typography/Text/Text';
import { ComponentDecorator } from '@ui/testing';
import { Autocomplete } from '../Autocomplete';
@@ -93,16 +95,20 @@ const ControlledResultsExample = () => {
}
}}
>
- <Autocomplete.Input render={<input aria-label="Location" />} />
- <Autocomplete.Popup width={200} style={{ maxInlineSize: 180 }}>
- <Autocomplete.List>
- {(item: string) => (
- <Autocomplete.Item key={item} value={item}>
- {item}
- </Autocomplete.Item>
- )}
- </Autocomplete.List>
- </Autocomplete.Popup>
+ <Autocomplete.Input render={<Input aria-label="Location" />} />
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup width={200} style={{ maxInlineSize: 180 }}>
+ <Autocomplete.List>
+ {(item: string) => (
+ <Autocomplete.Item key={item} value={item}>
+ {item}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
</Autocomplete.Root>
<Button
onMouseDown={(event) => event.preventDefault()}
@@ -116,7 +122,7 @@ const ControlledResultsExample = () => {
<Button onClick={() => setOutsideClickCount((count) => count + 1)}>
Outside
</Button>
- <span>{`Outside clicks: ${outsideClickCount}`}</span>
+ <Text>{`Outside clicks: ${outsideClickCount}`}</Text>
</>
);
};
@@ -156,14 +162,14 @@ export const ControlledResults: Story = {
expect(input).toHaveAttribute('aria-expanded', 'false'),
);
await expect(input).toHaveValue('Paris');
- await expect(canvas.getByText('Outside clicks: 0')).toBeVisible();
- await userEvent.click(outsideButton);
await expect(canvas.getByText('Outside clicks: 1')).toBeVisible();
},
};
const PreventedEnterExample = () => {
const [enterCount, setEnterCount] = useState(0);
+ const [shouldPreventBaseUIHandler, setShouldPreventBaseUIHandler] =
+ useState(true);
return (
<>
@@ -171,23 +177,37 @@ const PreventedEnterExample = () => {
<Autocomplete.Input
aria-label="Fruit"
onKeyDown={(event) => {
- if (event.key === 'Enter') {
- event.preventDefault();
- setEnterCount((count) => count + 1);
+ if (event.key !== 'Enter') {
+ return;
+ }
+
+ event.preventDefault();
+
+ if (shouldPreventBaseUIHandler) {
+ event.preventBaseUIHandler();
}
+
+ setEnterCount((count) => count + 1);
}}
/>
- <Autocomplete.Popup>
- <Autocomplete.List>
- {(fruit: string) => (
- <Autocomplete.Item key={fruit} value={fruit}>
- {fruit}
- </Autocomplete.Item>
- )}
- </Autocomplete.List>
- </Autocomplete.Popup>
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.List>
+ {(fruit: string) => (
+ <Autocomplete.Item key={fruit} value={fruit}>
+ {fruit}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
</Autocomplete.Root>
- <span>{`Enter count: ${enterCount}`}</span>
+ <Text>{`Enter count: ${enterCount}`}</Text>
+ <Button onClick={() => setShouldPreventBaseUIHandler(false)}>
+ Allow Base UI selection
+ </Button>
</>
);
};
@@ -207,5 +227,18 @@ export const PreventedKeyDown: Story = {
await expect(canvas.getByText('Enter count: 1')).toBeVisible();
await expect(input).toHaveValue('a');
await expect(input).toHaveAttribute('aria-expanded', 'true');
+ await userEvent.keyboard('{Escape}');
+ await userEvent.click(
+ await canvas.findByRole('button', { name: 'Allow Base UI selection' }),
+ );
+ await userEvent.type(input, 'p');
+ const reopenedApple = await body.findByRole('option', { name: 'Apple' });
+ await waitFor(() =>
+ expect(input).toHaveAttribute('aria-activedescendant', reopenedApple.id),
+ );
+ await userEvent.keyboard('{Enter}');
+ await expect(canvas.getByText('Enter count: 2')).toBeVisible();
+ await expect(input).toHaveValue('Apple');
+ await expect(input).toHaveAttribute('aria-expanded', 'false');
},
};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.positioning.stories.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.positioning.stories.tsx
new file mode 100644
index 00000000000..60641653081
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/Autocomplete.positioning.stories.tsx
@@ -0,0 +1,79 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { ComponentDecorator } from '@ui/testing';
+
+import { AutocompleteGridExample } from './AutocompleteGridExample';
+import { AutocompletePositionedExample } from './AutocompletePositionedExample';
+
+const meta: Meta<typeof AutocompletePositionedExample> = {
+ title: 'UI/Input/Autocomplete/Positioning',
+ component: AutocompletePositionedExample,
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 340, height: 320 } },
+};
+
+export default meta;
+type Story = StoryObj<typeof AutocompletePositionedExample>;
+
+export const ExplicitDestination: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const input = canvas.getByRole('combobox', { name: 'Fruit' });
+ const destination = canvas.getByRole('region', {
+ name: 'Suggestion destination',
+ });
+ const portal = within(destination).getByTestId('suggestion-portal');
+ const positioner = within(portal).getByTestId('suggestion-positioner');
+ const popup = within(positioner).getByTestId('suggestion-popup');
+
+ await expect(
+ within(portal).getByTestId('suggestion-backdrop'),
+ ).toBeInTheDocument();
+ await expect(popup.tagName).toBe('SECTION');
+ await expect(input).toHaveAttribute('data-composed-input', 'true');
+ await waitFor(() => expect(popup).toBeVisible());
+ await expect(positioner).toHaveAttribute('data-side', 'bottom');
+ await expect(positioner).toHaveAttribute('data-align', 'end');
+ await expect(positioner).toHaveStyle({ position: 'fixed' });
+ await waitFor(() => {
+ const anchorBounds = input.getBoundingClientRect();
+ const popupBounds = popup.getBoundingClientRect();
+ expect(Math.abs(popupBounds.width - 180)).toBeLessThan(1);
+ expect(Math.abs(popupBounds.right - anchorBounds.right)).toBeLessThan(1);
+ expect(
+ Math.abs(
+ popupBounds.top - anchorBounds.bottom - anchorBounds.height / 2,
+ ),
+ ).toBeLessThan(1);
+ });
+ await userEvent.click(input);
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(popup).not.toBeVisible());
+ await expect(portal).toBeInTheDocument();
+ await expect(input).toHaveFocus();
+ },
+};
+
+export const InlineGrid: Story = {
+ render: () => <AutocompleteGridExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const input = canvas.getByRole('combobox', { name: 'Fruit grid' });
+ await expect(canvas.getByRole('grid')).toBeVisible();
+ await expect(canvas.getAllByRole('row')).toHaveLength(2);
+ await expect(canvas.getByRole('status')).toHaveTextContent(
+ 'Suggestions: 4',
+ );
+ await userEvent.click(input);
+ await userEvent.keyboard('{ArrowDown}');
+ await expect(input).toHaveFocus();
+ await expect(input).toHaveAttribute(
+ 'aria-activedescendant',
+ canvas.getByRole('gridcell', { name: 'Cherry' }).id,
+ );
+ await userEvent.keyboard('{Enter}');
+ await expect(input).toHaveValue('Cherry');
+ await expect(canvas.getByRole('grid')).toBeVisible();
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteExample.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteExample.tsx
index 0adac489559..87ea9aa0dd3 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteExample.tsx
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteExample.tsx
@@ -12,15 +12,19 @@ export const AutocompleteExample = (
<Autocomplete.InputGroup>
<Autocomplete.Input aria-label="Fruit" placeholder="Search fruits" />
</Autocomplete.InputGroup>
- <Autocomplete.Popup>
- <Autocomplete.Empty>No fruits found</Autocomplete.Empty>
- <Autocomplete.List>
- {(fruit: string) => (
- <Autocomplete.Item key={fruit} value={fruit}>
- {fruit}
- </Autocomplete.Item>
- )}
- </Autocomplete.List>
- </Autocomplete.Popup>
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.Empty>No fruits found</Autocomplete.Empty>
+ <Autocomplete.List>
+ {(fruit: string) => (
+ <Autocomplete.Item key={fruit} value={fruit}>
+ {fruit}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
</Autocomplete.Root>
);
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteFilteredCount.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteFilteredCount.tsx
new file mode 100644
index 00000000000..9be7d1975cb
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteFilteredCount.tsx
@@ -0,0 +1,13 @@
+import { Text } from '@ui/primitives/typography/Text/Text';
+
+import { Autocomplete } from '../Autocomplete';
+
+export const AutocompleteFilteredCount = () => {
+ const items = Autocomplete.useFilteredItems<string>();
+
+ return (
+ <Autocomplete.Status
+ render={<Text />}
+ >{`Suggestions: ${items.length}`}</Autocomplete.Status>
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteFilteredExample.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteFilteredExample.tsx
new file mode 100644
index 00000000000..69db0d73217
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteFilteredExample.tsx
@@ -0,0 +1,39 @@
+import { useState } from 'react';
+
+import { Autocomplete } from '../Autocomplete';
+
+const CITIES = ['Paris', 'London', 'Lisbon'];
+
+export const AutocompleteFilteredExample = () => {
+ const [value, setValue] = useState('');
+ const { startsWith } = Autocomplete.useFilter();
+ const filteredItems = CITIES.filter((city) => startsWith(city, value));
+
+ return (
+ <Autocomplete.Root
+ items={CITIES}
+ filteredItems={filteredItems}
+ value={value}
+ onValueChange={setValue}
+ autoHighlight="always"
+ >
+ <Autocomplete.Input aria-label="City prefix" />
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.Empty>
+ No city starts with this query
+ </Autocomplete.Empty>
+ <Autocomplete.List>
+ {(city: string) => (
+ <Autocomplete.Item key={city} value={city}>
+ {city}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteGridExample.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteGridExample.tsx
new file mode 100644
index 00000000000..1755cedc438
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteGridExample.tsx
@@ -0,0 +1,44 @@
+import { useState } from 'react';
+
+import { Autocomplete } from '../Autocomplete';
+import { AutocompleteFilteredCount } from './AutocompleteFilteredCount';
+
+const FRUITS = ['Apple', 'Banana', 'Cherry', 'Date'];
+
+export const AutocompleteGridExample = () => {
+ const [value, setValue] = useState('');
+
+ return (
+ <Autocomplete.Root
+ items={FRUITS}
+ value={value}
+ onValueChange={setValue}
+ grid
+ inline
+ open
+ mode="none"
+ autoHighlight="always"
+ >
+ <Autocomplete.Input aria-label="Fruit grid" />
+ <Autocomplete.List>
+ <Autocomplete.Row style={{ display: 'flex' }}>
+ <Autocomplete.Item value="Apple" onClick={() => setValue('Apple')}>
+ Apple
+ </Autocomplete.Item>
+ <Autocomplete.Item value="Banana" onClick={() => setValue('Banana')}>
+ Banana
+ </Autocomplete.Item>
+ </Autocomplete.Row>
+ <Autocomplete.Row style={{ display: 'flex' }}>
+ <Autocomplete.Item value="Cherry" onClick={() => setValue('Cherry')}>
+ Cherry
+ </Autocomplete.Item>
+ <Autocomplete.Item value="Date" onClick={() => setValue('Date')}>
+ Date
+ </Autocomplete.Item>
+ </Autocomplete.Row>
+ </Autocomplete.List>
+ <AutocompleteFilteredCount />
+ </Autocomplete.Root>
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteGroupedExample.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteGroupedExample.tsx
new file mode 100644
index 00000000000..4ce4d24cfda
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompleteGroupedExample.tsx
@@ -0,0 +1,78 @@
+import { IconChevronDown, IconX } from '@ui/icon';
+import { Button } from '@ui/primitives/input/Button/Button';
+import { Text } from '@ui/primitives/typography/Text/Text';
+
+import { Autocomplete } from '../Autocomplete';
+
+type City = { id: number; name: string; country: string };
+type CityGroup = { label: string; items: City[] };
+
+const CITY_GROUPS: CityGroup[] = [
+ {
+ label: 'Western Europe',
+ items: [
+ { id: 1, name: 'Paris', country: 'France' },
+ { id: 2, name: 'Lisbon', country: 'Portugal' },
+ ],
+ },
+ {
+ label: 'Central Europe',
+ items: [{ id: 3, name: 'Berlin', country: 'Germany' }],
+ },
+];
+
+export const AutocompleteGroupedExample = () => (
+ <Autocomplete.Root
+ items={CITY_GROUPS}
+ itemToStringValue={(city) => city.name}
+ autoHighlight="always"
+ >
+ <Autocomplete.InputGroup style={{ gap: 4 }}>
+ <Autocomplete.Input aria-label="City" placeholder="Search cities" />
+ <Autocomplete.Clear
+ aria-label="Clear city"
+ render={<Button variant="ghost" size="sm" startIcon={<IconX />} />}
+ />
+ <Autocomplete.Trigger
+ aria-label="Show cities"
+ render={<Button variant="ghost" size="sm" />}
+ >
+ <Autocomplete.Icon>
+ <IconChevronDown />
+ </Autocomplete.Icon>
+ </Autocomplete.Trigger>
+ </Autocomplete.InputGroup>
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.Arrow />
+ <Autocomplete.Empty>No matching cities</Autocomplete.Empty>
+ <Autocomplete.List>
+ {(group: CityGroup, groupIndex: number) => (
+ <Autocomplete.Group key={group.label} items={group.items}>
+ {groupIndex > 0 && <Autocomplete.Separator />}
+ <Autocomplete.GroupLabel>{group.label}</Autocomplete.GroupLabel>
+ <Autocomplete.Collection>
+ {(city: City) => (
+ <Autocomplete.Item
+ key={city.id}
+ value={city}
+ description={city.country}
+ >
+ {city.name}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.Collection>
+ </Autocomplete.Group>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ <Autocomplete.Status render={<Text />}>
+ <Autocomplete.Value>
+ {(value) => (value ? `City query: ${value}` : 'Type to search cities')}
+ </Autocomplete.Value>
+ </Autocomplete.Status>
+ </Autocomplete.Root>
+);
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompletePositionedExample.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompletePositionedExample.tsx
new file mode 100644
index 00000000000..dcb8f356770
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__stories__/AutocompletePositionedExample.tsx
@@ -0,0 +1,58 @@
+import { useRef, useState } from 'react';
+
+import { Input } from '@ui/primitives/input/Input/Input';
+
+import { Autocomplete } from '../Autocomplete';
+
+const FRUITS = ['Apple', 'Banana', 'Cherry'];
+
+export const AutocompletePositionedExample = () => {
+ const inputRef = useRef<HTMLInputElement>(null);
+ const [container, setContainer] = useState<HTMLDivElement | null>(null);
+
+ return (
+ <>
+ <Autocomplete.Root items={FRUITS} defaultOpen autoHighlight="always">
+ <Autocomplete.Input
+ aria-label="Fruit"
+ ref={inputRef}
+ render={<Input data-composed-input="true" />}
+ />
+ <Autocomplete.Portal
+ container={container}
+ keepMounted
+ data-testid="suggestion-portal"
+ >
+ <Autocomplete.Backdrop data-testid="suggestion-backdrop" />
+ <Autocomplete.Positioner
+ anchor={inputRef}
+ side="bottom"
+ align="end"
+ sideOffset={({ anchor }) => anchor.height / 2}
+ positionMethod="fixed"
+ collisionAvoidance={{ side: 'none', align: 'none' }}
+ data-testid="suggestion-positioner"
+ >
+ <Autocomplete.Popup
+ width={180}
+ render={<section data-testid="suggestion-popup" />}
+ >
+ <Autocomplete.List>
+ {(fruit: string) => (
+ <Autocomplete.Item key={fruit} value={fruit}>
+ {fruit}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>
+ <div
+ ref={setContainer}
+ role="region"
+ aria-label="Suggestion destination"
+ />
+ </>
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__tests__/Autocomplete.behavior.test.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__tests__/Autocomplete.behavior.test.tsx
new file mode 100644
index 00000000000..f07512f2614
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__tests__/Autocomplete.behavior.test.tsx
@@ -0,0 +1,339 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { createRef, useState } from 'react';
+import { expectTypeOf, vi } from 'vitest';
+
+import {
+ Autocomplete,
+ type AutocompleteRootChangeEventDetails,
+ type AutocompleteRootProps,
+ Field,
+} from '@ui/primitives/input';
+import { DirectionProvider } from '@ui/primitives/layout';
+import { ThemeProvider } from '@ui/theme';
+
+const FRUITS = ['Apple', 'Banana', 'Cherry'];
+const FruitSearch = (props: Omit<AutocompleteRootProps<string>, 'items'>) => (
+ <Autocomplete.Root items={FRUITS} autoHighlight="always" {...props}>
+ <Autocomplete.Input aria-label="Fruit" />
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.Empty>No fruit found</Autocomplete.Empty>
+ <Autocomplete.List>
+ {(fruit: string) => (
+ <Autocomplete.Item key={fruit} value={fruit}>
+ {fruit}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>
+);
+const ControlledSearch = () => {
+ const [value, setValue] = useState('');
+ const [open, setOpen] = useState(false);
+ return (
+ <>
+ <FruitSearch
+ value={value}
+ open={open}
+ onValueChange={setValue}
+ onOpenChange={setOpen}
+ />
+ <button onClick={() => setValue('Cherry')}>Use cherry</button>
+ </>
+ );
+};
+
+describe('Autocomplete public contract', () => {
+ it('preserves installed Root overloads and generic prop contracts', () => {
+ expectTypeOf(Autocomplete.Root).toEqualTypeOf<
+ typeof AutocompletePrimitive.Root
+ >();
+ expectTypeOf<AutocompleteRootProps<{ title: string }>>().toEqualTypeOf<
+ AutocompletePrimitive.Root.Props<{ title: string }>
+ >();
+ });
+
+ it('filters string items and exposes the upstream empty state', async () => {
+ const user = userEvent.setup();
+ render(<FruitSearch />);
+ const input = screen.getByRole('combobox', { name: 'Fruit' });
+ await user.type(input, 'ban');
+ expect(await screen.findByRole('option', { name: 'Banana' })).toBeVisible();
+ expect(screen.queryByRole('option', { name: 'Apple' })).toBeNull();
+ await user.clear(input);
+ await user.type(input, 'missing');
+ expect(await screen.findByText('No fruit found')).toBeVisible();
+ expect(screen.queryAllByRole('option')).toHaveLength(0);
+ });
+
+ it('infers grouped object items and forwards highlight values', async () => {
+ const user = userEvent.setup();
+ const onItemHighlighted = vi.fn();
+ const groups = [
+ {
+ title: 'Produce',
+ items: [
+ { code: 'a', title: 'Apple' },
+ { code: 'b', title: 'Banana' },
+ ],
+ },
+ ];
+ render(
+ <Autocomplete.Root
+ items={groups}
+ itemToStringValue={(item) => item.title}
+ autoHighlight="always"
+ onItemHighlighted={(item, details) =>
+ onItemHighlighted(item?.code, details)
+ }
+ >
+ <Autocomplete.Input aria-label="Produce" />
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.List>
+ {(group: (typeof groups)[number]) => (
+ <Autocomplete.Group key={group.title} items={group.items}>
+ <Autocomplete.GroupLabel>
+ {group.title}
+ </Autocomplete.GroupLabel>
+ <Autocomplete.Collection>
+ {(item: (typeof groups)[number]['items'][number]) => (
+ <Autocomplete.Item key={item.code} value={item}>
+ {item.title}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.Collection>
+ </Autocomplete.Group>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>,
+ );
+ await user.type(screen.getByRole('combobox', { name: 'Produce' }), 'ban');
+ expect(await screen.findByRole('option', { name: 'Banana' })).toBeVisible();
+ expect(onItemHighlighted).toHaveBeenCalledWith(
+ 'b',
+ expect.objectContaining({ reason: expect.any(String) }),
+ );
+ await user.keyboard('{Enter}');
+ expect(screen.getByRole('combobox', { name: 'Produce' })).toHaveValue(
+ 'Banana',
+ );
+ });
+
+ it('uses upstream object labels without requiring a custom item shape', async () => {
+ const user = userEvent.setup();
+ const item = { value: 'a', label: 'Apple', extra: 42 };
+ render(
+ <Autocomplete.Root items={[item]} autoHighlight="always">
+ <Autocomplete.Input aria-label="Label" />
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>
+ <Autocomplete.List>
+ {(fruit: typeof item) => (
+ <Autocomplete.Item value={fruit}>
+ {fruit.label}
+ </Autocomplete.Item>
+ )}
+ </Autocomplete.List>
+ </Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>,
+ );
+ await user.type(screen.getByRole('combobox', { name: 'Label' }), 'app');
+ await user.keyboard('{Enter}');
+ expect(screen.getByRole('combobox', { name: 'Label' })).toHaveValue(
+ 'Apple',
+ );
+ });
+
+ it('retains controlled input and popup updates', async () => {
+ const user = userEvent.setup();
+ render(<ControlledSearch />);
+ const input = screen.getByRole('combobox', { name: 'Fruit' });
+ await user.type(input, 'ban');
+ expect(input).toHaveValue('ban');
+ await user.keyboard('{Enter}');
+ expect(input).toHaveValue('Banana');
+ await waitFor(() =>
+ expect(input).toHaveAttribute('aria-expanded', 'false'),
+ );
+ await user.click(screen.getByRole('button', { name: 'Use cherry' }));
+ expect(input).toHaveValue('Cherry');
+ });
+
+ it('delivers native change details and cancellable dismissal', async () => {
+ const user = userEvent.setup();
+ const onValueChange = vi.fn();
+ const onOpenChange = vi.fn(
+ (open: boolean, details: AutocompleteRootChangeEventDetails) => {
+ if (!open) details.cancel();
+ },
+ );
+ render(
+ <FruitSearch onValueChange={onValueChange} onOpenChange={onOpenChange} />,
+ );
+ const input = screen.getByRole('combobox', { name: 'Fruit' });
+ await user.type(input, 'b');
+ expect(onValueChange).toHaveBeenCalledWith(
+ 'b',
+ expect.objectContaining({
+ reason: 'input-change',
+ event: expect.any(Event),
+ cancel: expect.any(Function),
+ }),
+ );
+ await user.keyboard('{Escape}');
+ expect(onOpenChange).toHaveBeenLastCalledWith(
+ false,
+ expect.objectContaining({
+ reason: 'escape-key',
+ isCanceled: true,
+ event: expect.any(KeyboardEvent),
+ }),
+ );
+ expect(input).toHaveAttribute('aria-expanded', 'true');
+ });
+
+ it('allows the dismissing outside click to activate its target', async () => {
+ const user = userEvent.setup();
+ const onClick = vi.fn();
+ const onOpenChange = vi.fn();
+ render(
+ <>
+ <FruitSearch onOpenChange={onOpenChange} />
+ <button onClick={onClick}>Outside action</button>
+ </>,
+ );
+ const outsideAction = screen.getByRole('button', {
+ name: 'Outside action',
+ });
+ await user.type(screen.getByRole('combobox', { name: 'Fruit' }), 'a');
+ await screen.findByRole('option', { name: 'Apple' });
+ await user.click(outsideAction);
+ expect(onClick).toHaveBeenCalledTimes(1);
+ expect(onOpenChange).toHaveBeenLastCalledWith(
+ false,
+ expect.objectContaining({ reason: 'outside-press', isCanceled: false }),
+ );
+ expect(screen.getByRole('combobox', { name: 'Fruit' })).toHaveAttribute(
+ 'aria-expanded',
+ 'false',
+ );
+ });
+
+ it('preserves Field naming and native form submission/reset', async () => {
+ const user = userEvent.setup();
+ const ref = createRef<HTMLInputElement>();
+ render(
+ <form aria-label="Search form">
+ <Field.Root name="fruit">
+ <Field.Label>Named fruit</Field.Label>
+ <Autocomplete.Root defaultValue="Apple" required>
+ <Autocomplete.Input ref={ref} />
+ </Autocomplete.Root>
+ <Field.Description>Choose produce</Field.Description>
+ </Field.Root>
+ </form>,
+ );
+ const form = screen.getByRole<HTMLFormElement>('form', {
+ name: 'Search form',
+ });
+ const input = screen.getByRole('combobox', { name: 'Named fruit' });
+ expect(input).toHaveAccessibleDescription('Choose produce');
+ expect(Object.fromEntries(new FormData(form))).toEqual({ fruit: 'Apple' });
+ await user.clear(input);
+ expect(ref.current?.checkValidity()).toBe(false);
+ await user.type(input, 'Banana');
+ expect(Object.fromEntries(new FormData(form))).toEqual({ fruit: 'Banana' });
+ form.reset();
+ await waitFor(() => expect(input).toHaveValue('Banana'));
+ });
+
+ it('does not confirm a highlighted item during IME confirmation', async () => {
+ const user = userEvent.setup();
+ const onValueChange = vi.fn();
+ render(<FruitSearch onValueChange={onValueChange} />);
+ const input = screen.getByRole('combobox', { name: 'Fruit' });
+ await user.type(input, 'a');
+ await screen.findByRole('option', { name: 'Apple' });
+ onValueChange.mockClear();
+ fireEvent.compositionStart(input);
+ fireEvent.keyDown(input, {
+ key: 'Enter',
+ code: 'Enter',
+ keyCode: 229,
+ which: 229,
+ isComposing: true,
+ });
+ expect(onValueChange).not.toHaveBeenCalled();
+ expect(input).toHaveValue('a');
+ fireEvent.compositionEnd(input, { data: 'a' });
+ await user.keyboard('{Enter}');
+ expect(input).toHaveValue('Apple');
+ });
+
+ it('preserves scoped portal direction, explicit targets and null containers', () => {
+ const target = document.createElement('div');
+ document.body.append(target);
+ const { rerender, unmount } = render(
+ <DirectionProvider direction="rtl">
+ <ThemeProvider
+ colorScheme="dark"
+ applyToRoot={false}
+ className="search-scope"
+ >
+ <Autocomplete.Root open>
+ <Autocomplete.Input aria-label="Scoped" />
+ <Autocomplete.Portal data-testid="portal">
+ <Autocomplete.Positioner data-testid="positioner">
+ <Autocomplete.Popup>Options</Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>
+ </ThemeProvider>
+ </DirectionProvider>,
+ );
+ expect(
+ screen.getByTestId('portal').closest('.search-scope'),
+ ).not.toBeNull();
+ expect(screen.getByTestId('portal')).toHaveAttribute('dir', 'rtl');
+ expect(screen.getByTestId('positioner')).toHaveAttribute('dir', 'rtl');
+ rerender(
+ <Autocomplete.Root open>
+ <Autocomplete.Input aria-label="Explicit" />
+ <Autocomplete.Portal container={target} dir="ltr" data-testid="portal">
+ <Autocomplete.Positioner dir="ltr">
+ <Autocomplete.Popup>Options</Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>,
+ );
+ expect(screen.getByTestId('portal').parentElement).toBe(target);
+ expect(screen.getByTestId('portal')).toHaveAttribute('dir', 'ltr');
+ rerender(
+ <Autocomplete.Root open>
+ <Autocomplete.Input aria-label="Hidden" />
+ <Autocomplete.Portal container={null}>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>Hidden options</Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </Autocomplete.Root>,
+ );
+ expect(screen.queryByText('Hidden options')).toBeNull();
+ unmount();
+ target.remove();
+ });
+});
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/__tests__/Autocomplete.test.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/__tests__/Autocomplete.test.tsx
index a1fe7b1b812..105cddf1e71 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/__tests__/Autocomplete.test.tsx
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/__tests__/Autocomplete.test.tsx
@@ -4,7 +4,7 @@ import { runComponentConformance } from '@test-utilities/conformance/runComponen
import inputStyles from '@ui/primitives/input/Input/Input.module.scss';
import listItemStyles from '@ui/primitives/navigation/ListItem/ListItem.module.scss';
-import { Autocomplete } from '../Autocomplete';
+import { Autocomplete } from '@ui/primitives/input';
import styles from '../Autocomplete.module.scss';
const RootWrapper = ({ children }: { children: ReactNode }) => (
@@ -18,7 +18,11 @@ const OpenWrapper = ({ children }: { children: ReactNode }) => (
);
const PopupWrapper = ({ children }: { children: ReactNode }) => (
<OpenWrapper>
- <Autocomplete.Popup>{children}</Autocomplete.Popup>
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>
+ <Autocomplete.Popup>{children}</Autocomplete.Popup>
+ </Autocomplete.Positioner>
+ </Autocomplete.Portal>
</OpenWrapper>
);
const ListWrapper = ({ children }: { children: ReactNode }) => (
@@ -46,7 +50,13 @@ runComponentConformance({
name: 'Autocomplete.Popup',
element: <Autocomplete.Popup />,
refInstanceOf: HTMLDivElement,
- wrapper: OpenWrapper,
+ wrapper: ({ children }) => (
+ <OpenWrapper>
+ <Autocomplete.Portal>
+ <Autocomplete.Positioner>{children}</Autocomplete.Positioner>
+ </Autocomplete.Portal>
+ </OpenWrapper>
+ ),
ownClassName: styles.popup,
});
runComponentConformance({
@@ -70,3 +80,54 @@ runComponentConformance({
wrapper: PopupWrapper,
ownClassName: styles.empty,
});
+
+runComponentConformance({
+ name: 'Autocomplete.Arrow',
+ element: <Autocomplete.Arrow />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: PopupWrapper,
+ ownClassName: styles.arrow,
+});
+
+runComponentConformance({
+ name: 'Autocomplete.Separator',
+ element: <Autocomplete.Separator />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: PopupWrapper,
+ ownClassName: styles.separator,
+});
+
+runComponentConformance({
+ name: 'Autocomplete.Portal',
+ element: <Autocomplete.Portal />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: OpenWrapper,
+});
+
+runComponentConformance({
+ name: 'Autocomplete.Positioner',
+ element: <Autocomplete.Positioner />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: ({ children }) => (
+ <OpenWrapper>
+ <Autocomplete.Portal>{children}</Autocomplete.Portal>
+ </OpenWrapper>
+ ),
+ ownClassName: styles.positioner,
+});
+
+runComponentConformance({
+ name: 'Autocomplete.Trigger',
+ element: <Autocomplete.Trigger>Show options</Autocomplete.Trigger>,
+ refInstanceOf: HTMLButtonElement,
+ wrapper: RootWrapper,
+ renderPropTagName: 'button',
+});
+
+runComponentConformance({
+ name: 'Autocomplete.Clear',
+ element: <Autocomplete.Clear keepMounted>Clear</Autocomplete.Clear>,
+ refInstanceOf: HTMLButtonElement,
+ wrapper: RootWrapper,
+ renderPropTagName: 'button',
+});
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteArrow.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteArrow.tsx
new file mode 100644
index 00000000000..00b5fceda12
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteArrow.tsx
@@ -0,0 +1,16 @@
+import { Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+
+import styles from '../Autocomplete.module.scss';
+import { type AutocompleteArrowProps } from '../types/AutocompleteArrowProps';
+
+export const AutocompleteArrow = ({
+ className,
+ ...props
+}: AutocompleteArrowProps) => (
+ <AutocompletePrimitive.Arrow
+ {...props}
+ className={mergeClassNames(styles.arrow, className)}
+ />
+);
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteInput.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteInput.tsx
index 67884841f0f..e9c6ad777b4 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteInput.tsx
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteInput.tsx
@@ -12,7 +12,6 @@ import { type AutocompleteInputProps } from '../types/AutocompleteInputProps';
export const AutocompleteInput = ({
size,
className,
- onKeyDown,
...props
}: AutocompleteInputProps) => {
const inputGroup = useContext(InputGroupContext);
@@ -26,13 +25,6 @@ export const AutocompleteInput = ({
className,
)}
data-grouped={isDefined(inputGroup) || undefined}
- onKeyDown={(event) => {
- onKeyDown?.(event);
-
- if (event.defaultPrevented) {
- event.preventBaseUIHandler();
- }
- }}
/>
);
};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePopup.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePopup.tsx
index 9af424a162e..34bbdc7b233 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePopup.tsx
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePopup.tsx
@@ -1,8 +1,6 @@
import { Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
import { isFunction } from '@sniptt/guards';
-import { useProvidedTextDirection } from '@ui/primitives/layout/DirectionProvider/internal/useProvidedTextDirection';
-import { useThemeContainer } from '@ui/theme';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
import { isDefined } from '@ui/utilities/utils/isDefined';
@@ -10,47 +8,18 @@ import styles from '../Autocomplete.module.scss';
import { type AutocompletePopupProps } from '../types/AutocompletePopupProps';
export const AutocompletePopup = ({
- side = 'bottom',
- align = 'start',
- sideOffset = 8,
- alignOffset,
- anchor,
- collisionPadding,
width,
style,
- container,
className,
...props
-}: AutocompletePopupProps) => {
- const themeContainer = useThemeContainer();
- const direction = useProvidedTextDirection();
-
- return (
- <AutocompletePrimitive.Portal
- container={
- container === undefined ? (themeContainer ?? undefined) : container
- }
- >
- <AutocompletePrimitive.Positioner
- dir={direction}
- side={side}
- align={align}
- sideOffset={sideOffset}
- alignOffset={alignOffset}
- anchor={anchor}
- collisionPadding={collisionPadding}
- className={styles.positioner}
- >
- <AutocompletePrimitive.Popup
- {...props}
- className={mergeClassNames(styles.popup, className)}
- style={(state) => ({
- width,
- minInlineSize: isDefined(width) ? 0 : undefined,
- ...(isFunction(style) ? style(state) : style),
- })}
- />
- </AutocompletePrimitive.Positioner>
- </AutocompletePrimitive.Portal>
- );
-};
+}: AutocompletePopupProps) => (
+ <AutocompletePrimitive.Popup
+ {...props}
+ className={mergeClassNames(styles.popup, className)}
+ style={(state) => ({
+ width,
+ minInlineSize: isDefined(width) ? 0 : undefined,
+ ...(isFunction(style) ? style(state) : style),
+ })}
+ />
+);
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePortal.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePortal.tsx
new file mode 100644
index 00000000000..f64c4143431
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePortal.tsx
@@ -0,0 +1,25 @@
+import { Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+import { isUndefined } from '@sniptt/guards';
+
+import { useProvidedTextDirection } from '@ui/primitives/layout/DirectionProvider/internal/useProvidedTextDirection';
+import { useThemeContainer } from '@ui/theme';
+
+import { type AutocompletePortalProps } from '../types/AutocompletePortalProps';
+
+export const AutocompletePortal = ({
+ container,
+ ...props
+}: AutocompletePortalProps) => {
+ const themeContainer = useThemeContainer();
+ const direction = useProvidedTextDirection();
+
+ return (
+ <AutocompletePrimitive.Portal
+ dir={direction}
+ {...props}
+ container={
+ isUndefined(container) ? (themeContainer ?? undefined) : container
+ }
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePositioner.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePositioner.tsx
new file mode 100644
index 00000000000..563d425a3e9
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompletePositioner.tsx
@@ -0,0 +1,26 @@
+import { Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+import { useProvidedTextDirection } from '@ui/primitives/layout/DirectionProvider/internal/useProvidedTextDirection';
+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+
+import styles from '../Autocomplete.module.scss';
+import { type AutocompletePositionerProps } from '../types/AutocompletePositionerProps';
+
+export const AutocompletePositioner = ({
+ className,
+ align = 'start',
+ sideOffset = 8,
+ ...props
+}: AutocompletePositionerProps) => {
+ const direction = useProvidedTextDirection();
+
+ return (
+ <AutocompletePrimitive.Positioner
+ dir={direction}
+ align={align}
+ sideOffset={sideOffset}
+ {...props}
+ className={mergeClassNames(styles.positioner, className)}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteRoot.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteRoot.tsx
deleted file mode 100644
index 2e8010c641b..00000000000
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteRoot.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
-
-import { preventDismissingClickActivation } from '@ui/utilities/internal/preventDismissingClickActivation';
-
-import { type AutocompleteRootProps } from '../types/AutocompleteRootProps';
-
-export const AutocompleteRoot = <TItem,>({
- onOpenChange,
- ...props
-}: AutocompleteRootProps<TItem>) => (
- <AutocompletePrimitive.Root
- {...props}
- onOpenChange={(open, eventDetails) => {
- onOpenChange?.(open, eventDetails);
-
- if (
- open ||
- eventDetails.isCanceled ||
- eventDetails.reason !== 'outside-press'
- ) {
- return;
- }
-
- preventDismissingClickActivation(eventDetails.event);
- }}
- />
-);
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteSeparator.tsx b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteSeparator.tsx
new file mode 100644
index 00000000000..235e9afbea9
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/internal/AutocompleteSeparator.tsx
@@ -0,0 +1,16 @@
+import { Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+
+import styles from '../Autocomplete.module.scss';
+import { type AutocompleteSeparatorProps } from '../types/AutocompleteSeparatorProps';
+
+export const AutocompleteSeparator = ({
+ className,
+ ...props
+}: AutocompleteSeparatorProps) => (
+ <AutocompletePrimitive.Separator
+ {...props}
+ className={mergeClassNames(styles.separator, className)}
+ />
+);
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteArrowProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteArrowProps.ts
new file mode 100644
index 00000000000..bc734ee9d89
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteArrowProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteArrowProps = AutocompletePrimitive.Arrow.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteArrowState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteArrowState.ts
new file mode 100644
index 00000000000..c12070e671f
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteArrowState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteArrowState = AutocompletePrimitive.Arrow.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteBackdropProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteBackdropProps.ts
new file mode 100644
index 00000000000..b44009e10a2
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteBackdropProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteBackdropProps = AutocompletePrimitive.Backdrop.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteBackdropState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteBackdropState.ts
new file mode 100644
index 00000000000..385ca59839f
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteBackdropState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteBackdropState = AutocompletePrimitive.Backdrop.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteClearProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteClearProps.ts
new file mode 100644
index 00000000000..6a1f6fbf25c
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteClearProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteClearProps = AutocompletePrimitive.Clear.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteClearState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteClearState.ts
new file mode 100644
index 00000000000..430630fec32
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteClearState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteClearState = AutocompletePrimitive.Clear.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteCollectionProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteCollectionProps.ts
new file mode 100644
index 00000000000..00851e01982
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteCollectionProps.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteCollectionProps =
+ AutocompletePrimitive.Collection.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteCollectionState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteCollectionState.ts
new file mode 100644
index 00000000000..c0221a5ca26
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteCollectionState.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteCollectionState =
+ AutocompletePrimitive.Collection.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteEmptyState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteEmptyState.ts
new file mode 100644
index 00000000000..6b5e0dcdff5
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteEmptyState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteEmptyState = AutocompletePrimitive.Empty.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteFilter.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteFilter.ts
new file mode 100644
index 00000000000..d2072d9dd26
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteFilter.ts
@@ -0,0 +1,3 @@
+import { type AutocompleteFilter as UpstreamAutocompleteFilter } from '@base-ui/react/autocomplete';
+
+export type AutocompleteFilter = UpstreamAutocompleteFilter;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteFilterOptions.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteFilterOptions.ts
new file mode 100644
index 00000000000..16f378b03f5
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteFilterOptions.ts
@@ -0,0 +1,3 @@
+import { type AutocompleteFilterOptions as UpstreamAutocompleteFilterOptions } from '@base-ui/react/autocomplete';
+
+export type AutocompleteFilterOptions = UpstreamAutocompleteFilterOptions;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupLabelProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupLabelProps.ts
new file mode 100644
index 00000000000..f99cbc0fa4b
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupLabelProps.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteGroupLabelProps =
+ AutocompletePrimitive.GroupLabel.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupLabelState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupLabelState.ts
new file mode 100644
index 00000000000..e10e1691c30
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupLabelState.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteGroupLabelState =
+ AutocompletePrimitive.GroupLabel.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupProps.ts
new file mode 100644
index 00000000000..35c5530d09c
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteGroupProps = AutocompletePrimitive.Group.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupState.ts
new file mode 100644
index 00000000000..bfa7f96444d
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteGroupState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteGroupState = AutocompletePrimitive.Group.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteIconProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteIconProps.ts
new file mode 100644
index 00000000000..8a01cf2409d
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteIconProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteIconProps = AutocompletePrimitive.Icon.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteIconState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteIconState.ts
new file mode 100644
index 00000000000..2935e017b1e
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteIconState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteIconState = AutocompletePrimitive.Icon.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteInputGroupState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteInputGroupState.ts
new file mode 100644
index 00000000000..08e5c5e60e1
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteInputGroupState.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteInputGroupState =
+ AutocompletePrimitive.InputGroup.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteInputState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteInputState.ts
new file mode 100644
index 00000000000..9e7bcd61644
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteInputState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteInputState = AutocompletePrimitive.Input.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteItemState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteItemState.ts
new file mode 100644
index 00000000000..13697dd210e
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteItemState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteItemState = AutocompletePrimitive.Item.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteListState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteListState.ts
new file mode 100644
index 00000000000..ddfea04e113
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteListState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteListState = AutocompletePrimitive.List.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePopupProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePopupProps.ts
index 9310f9b0e67..ee43ca75456 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePopupProps.ts
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePopupProps.ts
@@ -1,15 +1,5 @@
import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
-export type AutocompletePopupProps = AutocompletePrimitive.Popup.Props &
- Pick<
- AutocompletePrimitive.Positioner.Props,
- | 'side'
- | 'align'
- | 'sideOffset'
- | 'alignOffset'
- | 'anchor'
- | 'collisionPadding'
- > & {
- width?: number | string;
- container?: AutocompletePrimitive.Portal.Props['container'];
- };
+export type AutocompletePopupProps = AutocompletePrimitive.Popup.Props & {
+ width?: number | string;
+};
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePopupState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePopupState.ts
new file mode 100644
index 00000000000..1649aef61f6
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePopupState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompletePopupState = AutocompletePrimitive.Popup.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePortalProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePortalProps.ts
new file mode 100644
index 00000000000..8c6a88c91b3
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePortalProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompletePortalProps = AutocompletePrimitive.Portal.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePortalState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePortalState.ts
new file mode 100644
index 00000000000..0592f5be9cc
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePortalState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompletePortalState = AutocompletePrimitive.Portal.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePositionerProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePositionerProps.ts
new file mode 100644
index 00000000000..d97764ac422
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePositionerProps.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompletePositionerProps =
+ AutocompletePrimitive.Positioner.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePositionerState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePositionerState.ts
new file mode 100644
index 00000000000..5d70667d197
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompletePositionerState.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompletePositionerState =
+ AutocompletePrimitive.Positioner.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootActions.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootActions.ts
new file mode 100644
index 00000000000..afaf32156b8
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootActions.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteRootActions = AutocompletePrimitive.Root.Actions;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootChangeEventDetails.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootChangeEventDetails.ts
new file mode 100644
index 00000000000..4a9684bff13
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootChangeEventDetails.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteRootChangeEventDetails =
+ AutocompletePrimitive.Root.ChangeEventDetails;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootChangeEventReason.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootChangeEventReason.ts
new file mode 100644
index 00000000000..d5af8f77f93
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootChangeEventReason.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteRootChangeEventReason =
+ AutocompletePrimitive.Root.ChangeEventReason;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootHighlightEventDetails.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootHighlightEventDetails.ts
new file mode 100644
index 00000000000..48eb35181d9
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootHighlightEventDetails.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteRootHighlightEventDetails =
+ AutocompletePrimitive.Root.HighlightEventDetails;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootHighlightEventReason.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootHighlightEventReason.ts
new file mode 100644
index 00000000000..bb7ba0a78c9
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootHighlightEventReason.ts
@@ -0,0 +1,4 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteRootHighlightEventReason =
+ AutocompletePrimitive.Root.HighlightEventReason;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootProps.ts
index 5a25b2df083..6b7e5c4c4f6 100644
--- a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootProps.ts
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootProps.ts
@@ -1,8 +1,4 @@
import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
-export type AutocompleteRootProps<TItem> = Omit<
- AutocompletePrimitive.Root.Props<TItem>,
- 'items'
-> & {
- items?: readonly TItem[];
-};
+export type AutocompleteRootProps<TItem> =
+ AutocompletePrimitive.Root.Props<TItem>;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootState.ts
new file mode 100644
index 00000000000..d29bc0bae6d
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRootState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteRootState = AutocompletePrimitive.Root.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRowProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRowProps.ts
new file mode 100644
index 00000000000..87470bbca07
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRowProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteRowProps = AutocompletePrimitive.Row.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRowState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRowState.ts
new file mode 100644
index 00000000000..f8624837507
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteRowState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteRowState = AutocompletePrimitive.Row.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteSeparatorProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteSeparatorProps.ts
new file mode 100644
index 00000000000..360e39db541
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteSeparatorProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteSeparatorProps = AutocompletePrimitive.Separator.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteSeparatorState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteSeparatorState.ts
new file mode 100644
index 00000000000..63aca79395f
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteSeparatorState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteSeparatorState = AutocompletePrimitive.Separator.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteStatusProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteStatusProps.ts
new file mode 100644
index 00000000000..e27c933a7af
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteStatusProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteStatusProps = AutocompletePrimitive.Status.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteStatusState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteStatusState.ts
new file mode 100644
index 00000000000..01f0c765408
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteStatusState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteStatusState = AutocompletePrimitive.Status.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteTriggerProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteTriggerProps.ts
new file mode 100644
index 00000000000..49b934853b4
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteTriggerProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteTriggerProps = AutocompletePrimitive.Trigger.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteTriggerState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteTriggerState.ts
new file mode 100644
index 00000000000..b063e5cb924
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteTriggerState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteTriggerState = AutocompletePrimitive.Trigger.State;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteValueProps.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteValueProps.ts
new file mode 100644
index 00000000000..56a19f956b7
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteValueProps.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteValueProps = AutocompletePrimitive.Value.Props;
diff --git a/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteValueState.ts b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteValueState.ts
new file mode 100644
index 00000000000..47489297c80
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/input/Autocomplete/types/AutocompleteValueState.ts
@@ -0,0 +1,3 @@
+import { type Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete';
+
+export type AutocompleteValueState = AutocompletePrimitive.Value.State;
diff --git a/packages/twenty-ui/src/primitives/input/index.ts b/packages/twenty-ui/src/primitives/input/index.ts
index e19bdc5cf38..734e81cd7bc 100644
--- a/packages/twenty-ui/src/primitives/input/index.ts
+++ b/packages/twenty-ui/src/primitives/input/index.ts
@@ -8,13 +8,55 @@
*/
export { Autocomplete } from './Autocomplete/Autocomplete';
+export type { AutocompleteArrowProps } from './Autocomplete/types/AutocompleteArrowProps';
+export type { AutocompleteArrowState } from './Autocomplete/types/AutocompleteArrowState';
+export type { AutocompleteBackdropProps } from './Autocomplete/types/AutocompleteBackdropProps';
+export type { AutocompleteBackdropState } from './Autocomplete/types/AutocompleteBackdropState';
+export type { AutocompleteClearProps } from './Autocomplete/types/AutocompleteClearProps';
+export type { AutocompleteClearState } from './Autocomplete/types/AutocompleteClearState';
+export type { AutocompleteCollectionProps } from './Autocomplete/types/AutocompleteCollectionProps';
+export type { AutocompleteCollectionState } from './Autocomplete/types/AutocompleteCollectionState';
export type { AutocompleteEmptyProps } from './Autocomplete/types/AutocompleteEmptyProps';
+export type { AutocompleteEmptyState } from './Autocomplete/types/AutocompleteEmptyState';
+export type { AutocompleteFilter } from './Autocomplete/types/AutocompleteFilter';
+export type { AutocompleteFilterOptions } from './Autocomplete/types/AutocompleteFilterOptions';
+export type { AutocompleteGroupLabelProps } from './Autocomplete/types/AutocompleteGroupLabelProps';
+export type { AutocompleteGroupLabelState } from './Autocomplete/types/AutocompleteGroupLabelState';
+export type { AutocompleteGroupProps } from './Autocomplete/types/AutocompleteGroupProps';
+export type { AutocompleteGroupState } from './Autocomplete/types/AutocompleteGroupState';
+export type { AutocompleteIconProps } from './Autocomplete/types/AutocompleteIconProps';
+export type { AutocompleteIconState } from './Autocomplete/types/AutocompleteIconState';
export type { AutocompleteInputGroupProps } from './Autocomplete/types/AutocompleteInputGroupProps';
+export type { AutocompleteInputGroupState } from './Autocomplete/types/AutocompleteInputGroupState';
export type { AutocompleteInputProps } from './Autocomplete/types/AutocompleteInputProps';
+export type { AutocompleteInputState } from './Autocomplete/types/AutocompleteInputState';
export type { AutocompleteItemProps } from './Autocomplete/types/AutocompleteItemProps';
+export type { AutocompleteItemState } from './Autocomplete/types/AutocompleteItemState';
export type { AutocompleteListProps } from './Autocomplete/types/AutocompleteListProps';
+export type { AutocompleteListState } from './Autocomplete/types/AutocompleteListState';
export type { AutocompletePopupProps } from './Autocomplete/types/AutocompletePopupProps';
+export type { AutocompletePopupState } from './Autocomplete/types/AutocompletePopupState';
+export type { AutocompletePortalProps } from './Autocomplete/types/AutocompletePortalProps';
+export type { AutocompletePortalState } from './Autocomplete/types/AutocompletePortalState';
+export type { AutocompletePositionerProps } from './Autocomplete/types/AutocompletePositionerProps';
+export type { AutocompletePositionerState } from './Autocomplete/types/AutocompletePositionerState';
+export type { AutocompleteRootActions } from './Autocomplete/types/AutocompleteRootActions';
+export type { AutocompleteRootChangeEventDetails } from './Autocomplete/types/AutocompleteRootChangeEventDetails';
+export type { AutocompleteRootChangeEventReason } from './Autocomplete/types/AutocompleteRootChangeEventReason';
+export type { AutocompleteRootHighlightEventDetails } from './Autocomplete/types/AutocompleteRootHighlightEventDetails';
+export type { AutocompleteRootHighlightEventReason } from './Autocomplete/types/AutocompleteRootHighlightEventReason';
export type { AutocompleteRootProps } from './Autocomplete/types/AutocompleteRootProps';
+export type { AutocompleteRootState } from './Autocomplete/types/AutocompleteRootState';
+export type { AutocompleteRowProps } from './Autocomplete/types/AutocompleteRowProps';
+export type { AutocompleteRowState } from './Autocomplete/types/AutocompleteRowState';
+export type { AutocompleteSeparatorProps } from './Autocomplete/types/AutocompleteSeparatorProps';
+export type { AutocompleteSeparatorState } from './Autocomplete/types/AutocompleteSeparatorState';
+export type { AutocompleteStatusProps } from './Autocomplete/types/AutocompleteStatusProps';
+export type { AutocompleteStatusState } from './Autocomplete/types/AutocompleteStatusState';
+export type { AutocompleteTriggerProps } from './Autocomplete/types/AutocompleteTriggerProps';
+export type { AutocompleteTriggerState } from './Autocomplete/types/AutocompleteTriggerState';
+export type { AutocompleteValueProps } from './Autocomplete/types/AutocompleteValueProps';
+export type { AutocompleteValueState } from './Autocomplete/types/AutocompleteValueState';
export { Button } from './Button/Button';
export type { ButtonColor } from './Button/types/ButtonColor';
export type { ButtonLoadingPosition } from './Button/types/ButtonLoadingPosition';
diff --git a/packages/twenty-ui/src/utilities/index.ts b/packages/twenty-ui/src/utilities/index.ts
index 08c9a96ee2a..676e54f8e58 100644
--- a/packages/twenty-ui/src/utilities/index.ts
+++ b/packages/twenty-ui/src/utilities/index.ts
@@ -25,3 +25,4 @@ export type { Nullable } from './types/Nullable';
export { getSafeUrl } from './utils/getSafeUrl';
export { isDefined } from './utils/isDefined';
export { normalizeSearchText } from './utils/normalizeSearchText';
+export { preventDismissingClickActivation } from './utils/preventDismissingClickActivation';
diff --git a/packages/twenty-ui/src/utilities/internal/preventDismissingClickActivation.ts b/packages/twenty-ui/src/utilities/utils/preventDismissingClickActivation.ts
similarity index 100%
rename from packages/twenty-ui/src/utilities/internal/preventDismissingClickActivation.ts
rename to packages/twenty-ui/src/utilities/utils/preventDismissingClickActivation.ts