Skip to content

The open alternative to Salesforce, designed for AI.

Keep ListItem presentational (#27683)

Raphaël Bosi79e6796b600f
diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.json
index 7b02c8c2e54..15756244f96 100644
--- a/packages/twenty-docs/docs.json
+++ b/packages/twenty-docs/docs.json
@@ -668,6 +668,7 @@
{
"group": "Navigation",
"pages": [
+ "ui/components/navigation/list-item-button",
"ui/components/navigation/dropdown",
"ui/components/navigation/menu-items",
"ui/components/navigation/menu-picker",
diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.json
index 801c36de570..6b3271c3914 100644
--- a/packages/twenty-docs/navigation/base-structure.json
+++ b/packages/twenty-docs/navigation/base-structure.json
@@ -691,6 +691,7 @@
"key": "uiComponentsNavigation",
"label": "Navigation",
"pages": [
+ "ui/components/navigation/list-item-button",
"ui/components/navigation/dropdown",
"ui/components/navigation/menu-items",
"ui/components/navigation/menu-picker",
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/list-item-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/list-item-button.mdx
new file mode 100644
index 00000000000..5de43bd3394
--- /dev/null
+++ b/packages/twenty-docs/snippets/ui/generated/components/navigation/list-item-button.mdx
@@ -0,0 +1,70 @@
+{/*
+ * _____ _
+ *|_ _|_ _____ _ __ | |_ _ _
+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file
+ * | | \ V V / __/ | | | |_| |_| | DO NOT EDIT - changes will be overwritten
+ * |_| \_/\_/ \___|_| |_|\__|\__, | Generated by: npx nx generate:ui twenty-docs
+ * |___/
+ *
+ * This file is generated from the documentation data in packages/twenty-ui/generated.
+ * To update it, edit the component prop types or design tokens in twenty-ui and run:
+ * npx nx generate:ui twenty-docs
+ */}
+
+<ParamField body="color" type="&quot;danger&quot; | &quot;neutral&quot;">
+ Color of the text and icons. `danger` marks a destructive action.
+</ParamField>
+
+<ParamField body="description" type="ReactNode">
+ Supporting text, placed according to `descriptionPlacement`.
+</ParamField>
+
+<ParamField body="descriptionPlacement" type="&quot;end&quot; | &quot;inline&quot;">
+ Where the description renders: inline after the content or at the end of
+ the row.
+</ParamField>
+
+<ParamField body="disabled" type="boolean" default="false">
+ Disables activation and applies the matching row appearance.
+</ParamField>
+
+<ParamField body="endIcon" type="ReactNode">
+ Icon rendered after the content.
+</ParamField>
+
+<ParamField body="focusableWhenDisabled" type="boolean" default="false">
+ Keeps a disabled button focusable with aria-disabled while preventing activation.
+</ParamField>
+
+<ParamField body="focused" type="boolean">
+ Highlights the row without moving DOM focus.
+</ParamField>
+
+<ParamField body="hasSubmenu" type="boolean">
+ Displays a decorative submenu indicator.
+</ParamField>
+
+<ParamField body="indicator" type="&quot;check&quot; | &quot;checkbox&quot; | &quot;none&quot;">
+ Selection indicator: a check icon after the content or a checkbox before
+ it.
+</ParamField>
+
+<ParamField body="ref" type="Ref&lt;HTMLButtonElement&gt;">
+ Ref to the native HTMLButtonElement.
+</ParamField>
+
+<ParamField body="selected" type="boolean">
+ Applies selected styling and a decorative indicator. The caller supplies selection state and accessible semantics.
+</ParamField>
+
+<ParamField body="shortcut" type="ShortcutDefinition">
+ Displays decorative shortcut hints. The caller registers the shortcuts.
+</ParamField>
+
+<ParamField body="shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`; pass an empty string to omit it.
+</ParamField>
+
+<ParamField body="startIcon" type="ReactNode">
+ Icon rendered before the content.
+</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx b/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
index 486fa3058f1..a07cd8dc687 100644
--- a/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
@@ -33,7 +33,7 @@
</ParamField>
<ParamField body="disabled" type="boolean" default="false">
- Prevents clicks and applies the disabled style.
+ Applies disabled styling only. Set native disabled behavior and accessible semantics on the button, link, or popup item owner.
</ParamField>
<ParamField body="endIcon" type="ReactNode">
@@ -41,7 +41,7 @@
</ParamField>
<ParamField body="focused" type="boolean" default="false">
- Applies the highlighted style, for example to the focused item of a list.
+ Applies highlighted styling without moving DOM focus or handling keyboard navigation.
</ParamField>
<ParamField body="hasSubmenu" type="boolean" default="false">
@@ -53,16 +53,16 @@
it.
</ParamField>
-<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ListItemState&gt;">
- Allows you to replace the component's HTML element
- with a different tag, or compose it with another component.
+<ParamField body="ref" type="Ref&lt;HTMLElement&gt;">
+ Ref to the actual DOM root, including a composed native button or link.
+</ParamField>
- Accepts a `ReactElement` or a function that returns the element to render.
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ListItemState&gt;">
+ Composes the row with an element or render callback. The owner supplies interaction semantics, native attributes, and behavior.
</ParamField>
<ParamField body="selected" type="boolean" default="false">
- Whether the item is selected. Shows the check or checkbox indicator when
- `indicator` is set.
+ Applies selected styling and the configured decorative indicator. Selection state and accessible semantics belong to the owner.
</ParamField>
<ParamField body="shortcut" type="ShortcutDefinition">
diff --git a/packages/twenty-docs/ui/components/navigation/list-item-button.mdx b/packages/twenty-docs/ui/components/navigation/list-item-button.mdx
new file mode 100644
index 00000000000..d1de8a32b47
--- /dev/null
+++ b/packages/twenty-docs/ui/components/navigation/list-item-button.mdx
@@ -0,0 +1,120 @@
+---
+title: ListItemButton
+description: Native action buttons with the shared list row appearance.
+---
+
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
+import ListItemButtonReference from '/snippets/ui/generated/components/navigation/list-item-button.mdx';
+
+Use `ListItemButton` for action rows and standalone selection buttons. It combines [ListItem](/ui/primitives/navigation/list-item) layout with a native button, including Enter and Space activation, focus, and disabled behavior. It defaults to `type="button"`.
+
+<StoryEmbed
+ storyId="ui-components-listitembutton--default"
+ title="ListItemButton example"
+ height={180}
+/>
+
+## Actions and disabled state
+
+Pass `onClick` and `disabled` directly. Disabled buttons use the matching row appearance, prevent activation, and leave the tab order.
+
+```tsx
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { IconCopy } from 'twenty-ui/icon';
+
+type DuplicateActionProps = {
+ onDuplicate: () => void;
+ disabled?: boolean;
+};
+
+export const DuplicateAction = ({
+ onDuplicate,
+ disabled = false,
+}: DuplicateActionProps) => (
+ <ListItemButton
+ disabled={disabled}
+ onClick={onDuplicate}
+ startIcon={<IconCopy />}
+ description="Create a copy"
+ >
+ Duplicate
+ </ListItemButton>
+);
+```
+
+<StoryEmbed
+ storyId="ui-components-listitembutton--disabled"
+ title="Disabled action row"
+ height={180}
+/>
+
+Set `focusableWhenDisabled` to keep a disabled button focusable. It uses `aria-disabled` and continues to block activation. Native button attributes, events, styles, class names, and an `HTMLButtonElement` ref reach the button. Events bubble normally; callers supply any `stopPropagation()` or `preventDefault()` policy.
+
+## Selection and visual slots
+
+Your application owns selection. Pair `selected` with the appropriate accessible state, such as `aria-pressed` for a toggle button. `focused` highlights the row without moving DOM focus. Indicators and shortcut hints are decorative; your application registers shortcuts and handles navigation.
+
+```tsx
+import { useState } from 'react';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+
+export const ShowArchivedToggle = () => {
+ const [selected, setSelected] = useState(false);
+
+ return (
+ <ListItemButton
+ aria-pressed={selected}
+ selected={selected}
+ indicator="check"
+ onClick={() => setSelected(!selected)}
+ >
+ Show archived records
+ </ListItemButton>
+ );
+};
+```
+
+<StoryEmbed
+ storyId="ui-components-listitembutton--selected"
+ title="Selected action row"
+ height={180}
+/>
+
+Use `startIcon`, `endIcon`, `description`, and `descriptionPlacement` for supporting content. `color="danger"` marks a destructive action. `shortcutJoinLabel` controls the text between sequential shortcuts, and `hasSubmenu` displays a submenu indicator.
+
+## Independent controls
+
+Keep independent buttons beside `ListItemButton` so each retains its own focus and activation. The component has no `actions` slot. Use a passive `ListItem` with `actions` when the row itself does not act.
+
+```tsx
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { Button } from 'twenty-ui/primitives/input';
+
+type ContactActionsProps = {
+ onOpen: () => void;
+ onDetails: () => void;
+};
+
+export const ContactActions = ({ onOpen, onDetails }: ContactActionsProps) => (
+ <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
+ <ListItemButton onClick={onOpen} description="Account owner">
+ Alex Morgan
+ </ListItemButton>
+ <Button onClick={onDetails} aria-label="Open Alex Morgan's details">
+ Details
+ </Button>
+ </div>
+);
+```
+
+<StoryEmbed
+ storyId="ui-components-listitembutton--independent-action"
+ title="Sibling action controls"
+ height={180}
+/>
+
+Use `ListItem` for passive content, links, or custom semantic owners. Use the existing [Menu](/ui/primitives/surfaces/menu), [Dropdown](/ui/components/navigation/dropdown), and [Select](/ui/primitives/input/select) item parts within their popup owners, which supply roles and keyboard navigation.
+
+## Props
+
+<ListItemButtonReference />
diff --git a/packages/twenty-docs/ui/components/overview.mdx b/packages/twenty-docs/ui/components/overview.mdx
index 984dc713c23..0e3c6e99210 100644
--- a/packages/twenty-docs/ui/components/overview.mdx
+++ b/packages/twenty-docs/ui/components/overview.mdx
@@ -28,12 +28,13 @@ Import from `twenty-ui/components/input`.
Import from `twenty-ui/components/navigation`.
-| Component | Purpose |
-| --------------------------------------------------- | -------------------------------------------------------------------- |
-| [Dropdown](/ui/components/navigation/dropdown) | Action menus, searchable pickers, and form panels. |
-| [TabButton](/ui/components/navigation/tab-button) | Route links and adjacent actions with the same appearance as tabs. |
-| [Menu rows](/ui/components/navigation/menu-items) | MenuItem, MenuItemAvatar, MenuItemDraggable, and MenuItemSuggestion. |
-| [MenuPicker](/ui/components/navigation/menu-picker) | Compact icon toggles with tooltips. |
+| Component | Purpose |
+| ------------------------------------------------------------ | -------------------------------------------------------------------- |
+| [ListItemButton](/ui/components/navigation/list-item-button) | Native action buttons with list row styling. |
+| [Dropdown](/ui/components/navigation/dropdown) | Action menus, searchable pickers, and form panels. |
+| [TabButton](/ui/components/navigation/tab-button) | Route links and adjacent actions with the same appearance as tabs. |
+| [Menu rows](/ui/components/navigation/menu-items) | MenuItem, MenuItemAvatar, MenuItemDraggable, and MenuItemSuggestion. |
+| [MenuPicker](/ui/components/navigation/menu-picker) | Compact icon toggles with tooltips. |
## Data display
diff --git a/packages/twenty-docs/ui/components/settings/settings-row.mdx b/packages/twenty-docs/ui/components/settings/settings-row.mdx
index 1029c6b43e2..03462ea3256 100644
--- a/packages/twenty-docs/ui/components/settings/settings-row.mdx
+++ b/packages/twenty-docs/ui/components/settings/settings-row.mdx
@@ -57,7 +57,7 @@ export const WorkspaceSettings = () => (
## Row content and accessible text
-`children`, `startElement`, and `description` accept caller-owned nodes. The children supply the switch's accessible name, and the description supplies its accessible description. Keep content inside the label non-interactive. For navigation or action rows, use [ListItem](/ui/primitives/navigation/list-item) with a button or link.
+`children`, `startElement`, and `description` accept caller-owned nodes. The children supply the switch's accessible name, and the description supplies its accessible description. Keep content inside the label non-interactive. Use [ListItemButton](/ui/components/navigation/list-item-button) for action rows, or compose [ListItem](/ui/primitives/navigation/list-item) with a link for navigation.
<StoryEmbed
storyId="ui-components-settingsrow--with-description"
diff --git a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
index 4c1f850d5d4..a3327a1a1d2 100644
--- a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
+++ b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
@@ -7,7 +7,7 @@ import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import ListItemReference from '/snippets/ui/generated/navigation/list-item.mdx';
-`ListItem` supplies the visual layout shared by list and menu rows. Use [Menu](/ui/primitives/surfaces/menu) or [Select](/ui/primitives/input/select) when you need their selection and keyboard behavior.
+`ListItem` supplies the visual layout shared by list and menu rows. It renders a `div` by default for passive content. Use [ListItemButton](/ui/components/navigation/list-item-button) for ordinary action rows. Compose `ListItem` with an anchor for navigation or with a custom semantic owner when needed. Use [Menu](/ui/primitives/surfaces/menu), [Dropdown](/ui/components/navigation/dropdown), or [Select](/ui/primitives/input/select) when you need a complete popup or selection owner.
<StoryEmbed
storyId="ui-navigation-listitem--default"
@@ -36,29 +36,118 @@ ListItem
| `actions` | Optional | Adds trailing content, such as a separately focusable action. |
| `indicator`, `shortcut`, `hasSubmenu` | Optional | Configure built-in selection marks, shortcut hints, and the submenu indicator. |
-The row supplies layout. Use `render` to choose its element and semantics. For a row with independent action buttons, keep the row itself non-interactive so those buttons remain separate controls.
+The row supplies layout. `render` accepts an element or a callback that receives native props and visual state. Spread those props onto the actual root when using a callback. Native attributes, event handlers, `className`, `style`, and `ref` reach that root. For a row with independent action buttons, keep the row itself non-interactive so those buttons remain separate controls.
## Action row
+Use [ListItemButton](/ui/components/navigation/list-item-button) to pair row styling with native button interaction. Pass `disabled` once to control both appearance and activation.
+
```tsx
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { IconCopy } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
-type DuplicateActionProps = { onDuplicate: () => void };
+type DuplicateActionProps = {
+ onDuplicate: () => void;
+ disabled?: boolean;
+};
-export const DuplicateAction = ({ onDuplicate }: DuplicateActionProps) => (
- <ListItem
- render={<button type="button" />}
- startIcon={<IconCopy aria-hidden />}
+export const DuplicateAction = ({
+ onDuplicate,
+ disabled = false,
+}: DuplicateActionProps) => (
+ <ListItemButton
+ disabled={disabled}
+ startIcon={<IconCopy />}
description="Create a copy"
onClick={onDuplicate}
>
Duplicate
+ </ListItemButton>
+);
+```
+
+A custom button owner can still compose `ListItem` through `render`. That owner supplies native focus, Enter and Space activation, and disabled behavior. `ListItem.disabled` supplies only the matching visual style. `shortcut` displays hints; your application registers the shortcuts.
+
+<StoryEmbed
+ storyId="ui-navigation-listitem--button-owner"
+ title="Custom button composition"
+ height={160}
+/>
+
+## Navigation and explicit links
+
+Pass an anchor through `render` when the entire row navigates. Put anchor attributes, including `href`, `target`, and `rel`, on that element.
+
+```tsx
+import { ListItem } from 'twenty-ui/primitives/navigation';
+
+export const DocumentationLink = () => (
+ <ListItem render={<a href="https://twenty.com/developers" />}>
+ Typography documentation
+ </ListItem>
+);
+```
+
+<StoryEmbed
+ storyId="ui-navigation-listitem--link-owner"
+ title="Link row"
+ height={160}
+/>
+
+String labels stay text, including URL-shaped strings. ListItem does not create links. To link part of a non-interactive row, supply an anchor as caller-owned content. Keep that row as a `div` to avoid nested links or buttons. String labels retain their truncation and overflow tooltip; custom content can use [OverflowingTextWithTooltip](/ui/primitives/typography/overflowing-text-with-tooltip) with an explicit rendered anchor.
+
+Links do not have a native `disabled` attribute. If a destination is unavailable, the link owner must supply the appropriate semantics, tab order, and navigation policy. Styling it with `ListItem.disabled` alone does not prevent navigation.
+
+## Popup item owner
+
+Use `Menu.Item`, `Dropdown.ActionItem`, or `Dropdown.OptionItem` inside their respective popup owner. These parts already compose the ListItem layout and expose its visual slots. The popup owner supplies roles, focus, keyboard navigation, activation, and disabled behavior.
+
+```tsx
+import { Button } from 'twenty-ui/primitives/input';
+import { Menu } from 'twenty-ui/primitives/surfaces';
+
+type RecordActionsProps = { onDuplicate: () => void };
+
+export const RecordActions = ({ onDuplicate }: RecordActionsProps) => (
+ <Menu.Root>
+ <Menu.Trigger render={<Button>Record actions</Button>} />
+ <Menu.Popup>
+ <Menu.Item onClick={onDuplicate}>Duplicate record</Menu.Item>
+ <Menu.Item disabled>Unavailable action</Menu.Item>
+ </Menu.Popup>
+ </Menu.Root>
+);
+```
+
+<StoryEmbed
+ storyId="ui-navigation-listitem--menu-owner"
+ title="Menu item owner"
+ height={260}
+/>
+
+## Native event policy
+
+ListItem forwards native event objects and handlers. Clicks bubble normally, including clicks on trailing action controls. Put any intentional boundary on the interactive owner or caller's handler.
+
+```tsx
+import { ListItem } from 'twenty-ui/primitives/navigation';
+
+type OpenRecordProps = { onOpen: () => void };
+
+export const OpenRecord = ({ onOpen }: OpenRecordProps) => (
+ <ListItem
+ render={<button type="button" />}
+ onClick={(event) => {
+ event.stopPropagation();
+ onOpen();
+ }}
+ >
+ Open record
</ListItem>
);
```
-The default element is a `div`. Use `render` to give an interactive row appropriate semantics, such as a button or link. `shortcut` displays shortcut hints; your application must register the shortcuts.
+The caller also owns any `preventDefault()` policy, such as preventing a link's navigation. Passing `onClick` does not add a role, make a `div` keyboard-operable, or change propagation.
## Settings row
@@ -86,11 +175,11 @@ export const ShowArchivedToggle = () => {
};
```
-`selected`, `focused`, and `disabled` control row styling. The `check` and `checkbox` indicators are visual; use a real [Checkbox](/ui/primitives/input/checkbox) for a form control. When using a disabled button or link through `render`, also supply the element's appropriate disabled behavior and semantics.
+`selected`, `focused`, and `disabled` control row styling. They do not register actions, move DOM focus, add accessible roles or states, or suppress events. The `check` and `checkbox` indicators are decorative; use a real [Checkbox](/ui/primitives/input/checkbox) for a form control. Set `aria-pressed`, `aria-selected`, or other state semantics on the owner that needs them.
## Picker rows
-Selection belongs to the parent. `ListItem` has no uncontrolled selection state: pass `selected` and update it from `onClick`. Use `indicator="check"` for a single choice and `indicator="checkbox"` for multiple choices. Both indicators are decorative and share the row's click handler.
+Selection belongs to the parent. `ListItem` has no uncontrolled selection state: pass `selected` and update it from `onClick`. Use `indicator="check"` for a single choice and `indicator="checkbox"` for multiple choices. Both indicators are decorative; the interactive owner handles activation.
In an existing listbox, pass `role="option"` and `aria-selected`, and keep focus and arrow-key handling in the listbox. For a complete selection widget, use [Select](/ui/primitives/input/select). Standalone selection buttons can use `aria-pressed`, as in these examples.
@@ -177,7 +266,7 @@ export const TeammateButtons = () => {
};
```
-The checkbox indicator is not a form control and does not submit a value. Use [Checkbox](/ui/primitives/input/checkbox) when you need form participation. Supply `disabled` to both the row and its rendered native button to prevent activation and remove it from the tab order.
+The checkbox indicator is not a form control and does not submit a value. Use [Checkbox](/ui/primitives/input/checkbox) when you need form participation. Set native `disabled` on the rendered button to prevent activation and remove it from the tab order. Also pass `ListItem.disabled` for its visual appearance.
## Slots
@@ -215,7 +304,7 @@ Use `shortcutJoinLabel` to customize the text between sequential shortcut steps.
## Props
-The reference is generated from the public component types. Native attributes, including accessible names and event handlers, are also accepted on parts that render elements.
+The reference is generated from the public component types. Native `div` attributes and handlers are accepted, including accessible names and native events. Put button- or anchor-specific attributes on the element supplied through `render`. Both `ref` and the rendered element's ref target the actual DOM root.
<ListItemReference />
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 bc5a93c0835..05e64a8a4b0 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
@@ -13,6 +13,8 @@ Popover composes Portal, Positioner, Popup, Arrow and Viewport. Its focused Reac
Typography composition checks constrained text, explicit links, semantic elements, refs and native focus handlers in both runtimes. Overflow tooltip popup acceptance still depends on renderer portal and geometry support.
+ListItemButton checks native action activation, selected state, refs and events, disabled and focusable disabled behavior, ordinary bubbling, caller-owned propagation boundaries, and independent sibling controls in React and Preact. ListItem keeps its default div presentational, including visual disabled, selected and focused state and caller-owned content. Its React/Preact cases check native button/link owners, actual root refs, pointer and keyboard activation, focus handlers, disabled native buttons, event bubbling and explicit propagation boundaries. URL text stays plain unless the caller supplies a link. Menu.Item checks visible pointer activation, disabled behavior and click-to-close. Popup keyboard navigation, outside dismissal and focus restoration remain outside this fixture. The retained overflow-tooltip check re-enters after renderer measurements arrive, so it does not establish first-hover geometry acceptance.
+
Tag and Status retain their presentational span when a native click handler is supplied. Their focused React/Preact fixtures check explicit native button/link composition, keyboard activation, disabled owners, refs, caller-owned links and native handlers. Tag checks positive truncation and native padding styles; Status checks controlled loading, caller-owned busy state and a decorative loader without an implicit live region.
Card composition checks native part props and DOM refs, customized anatomy, ordinary display semantics, independent nested controls, button keyboard activation and disabled state, and explicit link ownership in both runtimes.
@@ -45,7 +47,7 @@ effect within the interaction timeout.
| `twenty-ui-status-controls` | Status (stable presentational root, loading/busy state, node content, refs and explicit button/link composition) |
| `twenty-ui-avatar-image` | Avatar Root/Image/Fallback (image labels/attributes/refs, loading callbacks, decoded images, fallback, replacement and unmount/remount) |
| `twenty-ui-image-input` | ImageInput |
-| `twenty-ui-list-item` | ListItem |
+| `twenty-ui-list-item` | ListItemButton and ListItem (native action composition, visual rows, explicit button/link/Menu.Item owners, refs/events/focus/keyboard, disabled behavior and sibling controls) |
| `twenty-ui-settings-row` | SettingsRow |
| `twenty-ui-tabs` | Tabs |
| `twenty-ui-overflowing-list` | OverflowingList |
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-button-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-button-example.tsx
new file mode 100644
index 00000000000..ee02423df19
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-button-example.tsx
@@ -0,0 +1,101 @@
+import { useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { Button } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
+
+const SPACE_KEY = ' ';
+const SIBLING_STYLE = { display: 'flex', alignItems: 'center', gap: 8 };
+const OUTPUT_STYLE = {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
+ gap: 8,
+};
+
+export const ListItemButtonExample = () => {
+ const [selected, setSelected] = useState(false);
+ const [activations, setActivations] = useState(0);
+ const [bubbledClicks, setBubbledClicks] = useState(0);
+ const [isolatedClicks, setIsolatedClicks] = useState(0);
+ const [detailClicks, setDetailClicks] = useState(0);
+ const [clickTarget, setClickTarget] = useState('none');
+ const [focusTarget, setFocusTarget] = useState('none');
+ const [lastKey, setLastKey] = useState('none');
+
+ return (
+ <>
+ <div
+ role="presentation"
+ onClick={() => setBubbledClicks((count) => count + 1)}
+ >
+ <ListItemButton
+ selected={selected}
+ aria-pressed={selected}
+ indicator="check"
+ description="Action row"
+ onClick={(event) => {
+ setSelected((value) => !value);
+ setActivations((count) => count + 1);
+ setClickTarget(`${event.type}:${event.currentTarget.tagName}`);
+ }}
+ onFocus={(event) => setFocusTarget(event.currentTarget.tagName)}
+ onKeyDown={(event) =>
+ setLastKey(event.key === SPACE_KEY ? 'Space' : event.key)
+ }
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ >
+ Daily summary
+ </ListItemButton>
+ <ListItemButton
+ disabled
+ onClick={() => setActivations((count) => count + 1)}
+ >
+ Unavailable summary
+ </ListItemButton>
+ <ListItemButton
+ disabled
+ focusableWhenDisabled
+ onClick={() => setActivations((count) => count + 1)}
+ >
+ Focusable unavailable summary
+ </ListItemButton>
+ <ListItemButton
+ onClick={(event) => {
+ event.stopPropagation();
+ setIsolatedClicks((count) => count + 1);
+ }}
+ >
+ Isolated summary
+ </ListItemButton>
+ </div>
+ <div style={SIBLING_STYLE}>
+ <ListItemButton onClick={() => setActivations((count) => count + 1)}>
+ Open summary
+ </ListItemButton>
+ <Button onClick={() => setDetailClicks((count) => count + 1)}>
+ Summary details
+ </Button>
+ </div>
+ <div style={OUTPUT_STYLE}>
+ <Text aria-label="Summary state">
+ Summary: {selected ? 'enabled' : 'disabled'}
+ </Text>
+ <Text aria-label="Summary activations">Activations: {activations}</Text>
+ <Text aria-label="Summary bubbled clicks">
+ Bubbled clicks: {bubbledClicks}
+ </Text>
+ <Text aria-label="Summary isolated clicks">
+ Isolated clicks: {isolatedClicks}
+ </Text>
+ <Text aria-label="Summary detail clicks">Details: {detailClicks}</Text>
+ <Text aria-label="Summary click target">Click: {clickTarget}</Text>
+ <Text aria-label="Summary focus target">Focus: {focusTarget}</Text>
+ <Text aria-label="Summary last key">Last key: {lastKey}</Text>
+ </div>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-owner-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-owner-example.tsx
new file mode 100644
index 00000000000..ffc3802fefb
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-owner-example.tsx
@@ -0,0 +1,97 @@
+import { useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { ListItem } from 'twenty-ui/primitives/navigation';
+import { Text } from 'twenty-ui/primitives/typography';
+
+const SPACE_KEY = ' ';
+const OUTPUT_STYLE = {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
+ gap: 8,
+};
+
+export const ListItemOwnerExample = () => {
+ const [selected, setSelected] = useState(false);
+ const [activations, setActivations] = useState(0);
+ const [bubbledClicks, setBubbledClicks] = useState(0);
+ const [suppressedClicks, setSuppressedClicks] = useState(0);
+ const [linkActivations, setLinkActivations] = useState(0);
+ const [clickTarget, setClickTarget] = useState('none');
+ const [focusTarget, setFocusTarget] = useState('none');
+ const [lastKey, setLastKey] = useState('none');
+
+ return (
+ <>
+ <div onClick={() => setBubbledClicks((count) => count + 1)}>
+ <ListItem
+ render={<button type="button" />}
+ selected={selected}
+ indicator="check"
+ description="Workspace preference"
+ onClick={(event) => {
+ setSelected((value) => !value);
+ setActivations((count) => count + 1);
+ setClickTarget(`${event.type}:${event.currentTarget.tagName}`);
+ }}
+ onFocus={(event) => setFocusTarget(event.currentTarget.tagName)}
+ onKeyDown={(event) =>
+ setLastKey(event.key === SPACE_KEY ? 'Space' : event.key)
+ }
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ >
+ Weekly digest
+ </ListItem>
+ <ListItem
+ disabled
+ render={<button type="button" disabled />}
+ onClick={() => setActivations((count) => count + 1)}
+ >
+ Disabled preference
+ </ListItem>
+ <ListItem
+ render={
+ <button
+ type="button"
+ onClick={(event) => event.stopPropagation()}
+ />
+ }
+ onClick={() => setSuppressedClicks((count) => count + 1)}
+ >
+ Isolated preference
+ </ListItem>
+ </div>
+ <ListItem
+ render={<a href="#list-item-profile" target="_self" />}
+ aria-label="Workspace profile"
+ onClick={() => setLinkActivations((count) => count + 1)}
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ >
+ https://twenty.com/workspace
+ </ListItem>
+ <div style={OUTPUT_STYLE}>
+ <Text aria-label="Digest state">
+ Digest: {selected ? 'enabled' : 'disabled'}
+ </Text>
+ <Text aria-label="Digest activations">Activations: {activations}</Text>
+ <Text aria-label="Bubbled clicks">Bubbled clicks: {bubbledClicks}</Text>
+ <Text aria-label="Suppressed clicks">
+ Suppressed clicks: {suppressedClicks}
+ </Text>
+ <Text aria-label="Link activations">
+ Link activations: {linkActivations}
+ </Text>
+ <Text aria-label="Click target">Click: {clickTarget}</Text>
+ <Text aria-label="Focus target">Focus: {focusTarget}</Text>
+ <Text aria-label="Last key">Last key: {lastKey}</Text>
+ </div>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-popup-owner-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-popup-owner-example.tsx
new file mode 100644
index 00000000000..7ec518ac8f5
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-popup-owner-example.tsx
@@ -0,0 +1,43 @@
+import { useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { Button } from 'twenty-ui/primitives/input';
+import { Menu } from 'twenty-ui/primitives/surfaces';
+import { Text } from 'twenty-ui/primitives/typography';
+
+export const ListItemPopupOwnerExample = () => {
+ const [activations, setActivations] = useState(0);
+
+ return (
+ <>
+ <Menu.Root>
+ <Menu.Trigger render={<Button>Preference actions</Button>} />
+ <Menu.Popup>
+ <Menu.Item
+ nativeButton
+ render={<button type="button" />}
+ description="Popup owner"
+ onClick={() => setActivations((count) => count + 1)}
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ >
+ Enable notifications
+ </Menu.Item>
+ <Menu.Item
+ disabled
+ nativeButton
+ render={<button type="button" />}
+ onClick={() => setActivations((count) => count + 1)}
+ >
+ Unavailable notifications
+ </Menu.Item>
+ </Menu.Popup>
+ </Menu.Root>
+ <Text aria-label="Popup activations">
+ Popup activations: {activations}
+ </Text>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-presentation-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-presentation-example.tsx
new file mode 100644
index 00000000000..254d7599a51
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/list-item-presentation-example.tsx
@@ -0,0 +1,54 @@
+import { useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { IconSettings } from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
+import { ListItem } from 'twenty-ui/primitives/navigation';
+import { Text } from 'twenty-ui/primitives/typography';
+
+export const ListItemPresentationExample = () => {
+ const [activations, setActivations] = useState(0);
+ const [bubbledClicks, setBubbledClicks] = useState(0);
+
+ return (
+ <>
+ <div onClick={() => setBubbledClicks((count) => count + 1)}>
+ <ListItem
+ data-testid="presentational-list-item"
+ disabled
+ selected
+ focused
+ indicator="checkbox"
+ startIcon={<IconSettings aria-label="Preference settings" />}
+ endIcon={<Text>End</Text>}
+ description="Visual only"
+ actions={
+ <Button size="sm" onClick={(event) => event.stopPropagation()}>
+ Details
+ </Button>
+ }
+ actionsVisibility="always"
+ shortcut={[['G'], ['P']]}
+ shortcutJoinLabel="then"
+ hasSubmenu
+ onClick={() => setActivations((count) => count + 1)}
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ >
+ Preference
+ </ListItem>
+ </div>
+ <ListItem data-testid="plain-url-list-item">
+ https://twenty.com/preferences
+ </ListItem>
+ <Text aria-label="Presentational activations">
+ Presentational activations: {activations}
+ </Text>
+ <Text aria-label="Presentational bubbled clicks">
+ Presentational bubbled clicks: {bubbledClicks}
+ </Text>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-list-item.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-list-item.front-component.tsx
index 3b42388668d..48cc52bf228 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-list-item.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-list-item.front-component.tsx
@@ -1,58 +1,33 @@
-import { createElement, useState } from 'react';
import { defineFrontComponent } from 'twenty-sdk/define';
import { ListItem } from 'twenty-ui/primitives/navigation';
-import { Text } from 'twenty-ui/primitives/typography';
import { ThemeProvider } from 'twenty-ui/theme';
import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';
+import { ListItemButtonExample } from '@/__stories__/twenty-ui-gallery/list-item-button-example';
+import { ListItemOwnerExample } from '@/__stories__/twenty-ui-gallery/list-item-owner-example';
+import { ListItemPopupOwnerExample } from '@/__stories__/twenty-ui-gallery/list-item-popup-owner-example';
+import { ListItemPresentationExample } from '@/__stories__/twenty-ui-gallery/list-item-presentation-example';
const OVERFLOW_ROW_STYLE = { width: 160 };
-const ListItemExample = () => {
- const [selected, setSelected] = useState(false);
- const [opened, setOpened] = useState(false);
-
- return (
- <TwentyUiGalleryCard title="ListItem">
- <ListItem
- selected={selected}
- indicator="check"
- onClick={() => setSelected(!selected)}
- description="Workspace preference"
- >
- Weekly digest
- </ListItem>
- <ListItem disabled role="button" onClick={() => setSelected(true)}>
- Disabled preference
- </ListItem>
- <ListItem
- render={(renderProps) =>
- createElement('button', { ...renderProps, type: 'button' })
- }
- hasSubmenu
- onClick={() => setOpened(true)}
- onKeyDown={(event) => {
- if (event.key === 'Escape') {
- setOpened(false);
- }
- }}
- >
- Hidden fields
+const ListItemExample = () => (
+ <TwentyUiGalleryCard title="ListItem">
+ <ListItemButtonExample />
+ <ListItemOwnerExample />
+ <ListItemPresentationExample />
+ <ListItemPopupOwnerExample />
+ <ThemeProvider colorScheme="light" applyToRoot={false}>
+ <ListItem style={OVERFLOW_ROW_STYLE}>
+ A long workspace preference that overflows its row
</ListItem>
- <ThemeProvider colorScheme="light" applyToRoot={false}>
- <ListItem style={OVERFLOW_ROW_STYLE}>
- A long workspace preference that overflows its row
- </ListItem>
- </ThemeProvider>
- <Text>Fields: {opened ? 'open' : 'closed'}</Text>
- <Text role="status">Digest: {selected ? 'enabled' : 'disabled'}</Text>
- </TwentyUiGalleryCard>
- );
-};
+ </ThemeProvider>
+ </TwentyUiGalleryCard>
+);
export default defineFrontComponent({
universalIdentifier: '4d23e9af-7cb3-4e4a-bbca-8e960f840003',
name: 'twenty-ui-list-item',
- description: 'ListItem selection and disabled behavior in the sandbox',
+ description:
+ 'ListItemButton actions and ListItem rows with explicit native owners',
component: ListItemExample,
});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
index 35b80aed3ac..97dfa0b8118 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-navigation-gallery.front-component.tsx
@@ -51,14 +51,7 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
{
name: 'ListItem multiple selection',
node: (
- <ListItem
- className=""
- role="option"
- aria-selected={false}
- selected={false}
- indicator="checkbox"
- onClick={() => {}}
- >
+ <ListItem className="" selected={false} indicator="checkbox">
<OverflowingTextWithTooltip text={'Multi select'} />
</ListItem>
),
@@ -66,13 +59,7 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
{
name: 'ListItem multiple avatar selection',
node: (
- <ListItem
- role="option"
- aria-selected={true}
- selected={true}
- indicator="checkbox"
- onClick={() => {}}
- >
+ <ListItem selected={true} indicator="checkbox">
<OverflowingTextWithTooltip text={'Multi avatar'} />
</ListItem>
),
@@ -80,13 +67,7 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
{
name: 'ListItem multiple tag selection',
node: (
- <ListItem
- onClick={() => {}}
- role="option"
- aria-selected={false}
- selected={false}
- indicator="checkbox"
- >
+ <ListItem selected={false} indicator="checkbox">
<Tag color={'blue'}>{'Tag'}</Tag>
</ListItem>
),
@@ -96,7 +77,6 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
node: (
<ListItem
startIcon={<IconUser />}
- onClick={() => {}}
render={<button type="button" />}
hasSubmenu
>
@@ -107,13 +87,7 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
{
name: 'ListItem selection',
node: (
- <ListItem
- onClick={() => {}}
- role="option"
- aria-selected={true}
- selected={true}
- indicator="check"
- >
+ <ListItem selected={true} indicator="check">
<OverflowingTextWithTooltip text={'Select'} />
</ListItem>
),
@@ -121,13 +95,7 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
{
name: 'ListItem avatar selection',
node: (
- <ListItem
- onClick={() => {}}
- role="option"
- aria-selected={true}
- selected={true}
- indicator="check"
- >
+ <ListItem selected={true} indicator="check">
<OverflowingTextWithTooltip text={'Select avatar'} />
</ListItem>
),
@@ -136,9 +104,6 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
name: 'ListItem color selection',
node: (
<ListItem
- onClick={() => {}}
- role="option"
- aria-selected={true}
selected={true}
indicator="check"
startIcon={<ColorSample colorName={'blue'} />}
@@ -150,13 +115,7 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
{
name: 'ListItem tag selection',
node: (
- <ListItem
- onClick={() => {}}
- role="option"
- aria-selected={true}
- selected={true}
- indicator="check"
- >
+ <ListItem selected={true} indicator="check">
<Tag color={'blue'} borderStyle="dashed" variant={'soft'}>
{'Select tag'}
</Tag>
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-picker-list-items.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-picker-list-items.front-component.tsx
index 222459312c9..1b9c37ce64b 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-picker-list-items.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-picker-list-items.front-component.tsx
@@ -1,4 +1,4 @@
-import { createElement, useState } from 'react';
+import { useState } from 'react';
import { defineFrontComponent } from 'twenty-sdk/define';
import { Avatar, ColorSample, Tag } from 'twenty-ui/primitives/data-display';
import { ListItem } from 'twenty-ui/primitives/navigation';
@@ -23,9 +23,7 @@ const PickerListItemsExample = () => {
indicator="check"
startIcon={<Avatar name={name} size="md" />}
description="Person"
- render={(props) =>
- createElement('button', { ...props, type: 'button' })
- }
+ render={<button type="button" />}
onClick={() => setAssignee(name)}
>
{name}
@@ -38,9 +36,7 @@ const PickerListItemsExample = () => {
aria-selected={qualified ? 'true' : 'false'}
selected={qualified}
indicator="checkbox"
- render={(props) =>
- createElement('button', { ...props, type: 'button' })
- }
+ render={<button type="button" />}
onClick={() => {
setQualified(!qualified);
setChanges((count) => count + 1);
@@ -52,6 +48,8 @@ const PickerListItemsExample = () => {
role="option"
aria-selected="false"
disabled
+ render={<button type="button" disabled />}
+ aria-disabled="true"
indicator="checkbox"
startIcon={<ColorSample colorName="red" />}
onClick={() => setChanges((count) => count + 1)}
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemButtonTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemButtonTest.ts
new file mode 100644
index 00000000000..f672c36e6b4
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemButtonTest.ts
@@ -0,0 +1,81 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const listItemButtonTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ const user = userEvent.setup();
+ const summary = canvas.getByRole('button', {
+ name: /^Daily summary\s*Action row$/,
+ });
+
+ expect(summary.tagName).toBe('BUTTON');
+ expect(summary).toHaveAttribute('type', 'button');
+ expect(summary).toHaveAttribute('data-ref-tag', 'HTML-BUTTON');
+ await user.click(summary);
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Summary state')).toHaveTextContent('enabled'),
+ );
+ expect(summary).toHaveAttribute('aria-pressed', 'true');
+ expect(canvas.getByLabelText('Summary click target')).toHaveTextContent(
+ 'click:HTML-BUTTON',
+ );
+ expect(canvas.getByLabelText('Summary focus target')).toHaveTextContent(
+ 'HTML-BUTTON',
+ );
+ expect(summary).toHaveFocus();
+ await user.keyboard('{Enter} ');
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Summary activations')).toHaveTextContent('3'),
+ );
+ expect(canvas.getByLabelText('Summary bubbled clicks')).toHaveTextContent(
+ '3',
+ );
+ expect(canvas.getByLabelText('Summary last key')).toHaveTextContent('Space');
+
+ const disabled = canvas.getByRole('button', { name: 'Unavailable summary' });
+ expect(disabled).toBeDisabled();
+ disabled.focus();
+ expect(disabled).not.toHaveFocus();
+ await user.click(disabled);
+ expect(canvas.getByLabelText('Summary activations')).toHaveTextContent('3');
+
+ const focusable = canvas.getByRole('button', {
+ name: 'Focusable unavailable summary',
+ });
+ expect(focusable).not.toBeDisabled();
+ expect(focusable).toHaveAttribute('aria-disabled', 'true');
+ focusable.focus();
+ expect(focusable).toHaveFocus();
+ await user.keyboard('{Enter} ');
+ await user.click(focusable);
+ expect(canvas.getByLabelText('Summary activations')).toHaveTextContent('3');
+ expect(canvas.getByLabelText('Summary bubbled clicks')).toHaveTextContent(
+ '6',
+ );
+
+ await user.click(canvas.getByRole('button', { name: 'Isolated summary' }));
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Summary isolated clicks')).toHaveTextContent(
+ '1',
+ ),
+ );
+ expect(canvas.getByLabelText('Summary bubbled clicks')).toHaveTextContent(
+ '6',
+ );
+
+ const details = canvas.getByRole('button', { name: 'Summary details' });
+ const openSummary = canvas.getByRole('button', { name: 'Open summary' });
+ expect(openSummary.contains(details)).toBe(false);
+ await user.click(details);
+ await user.keyboard('{Enter} ');
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Summary detail clicks')).toHaveTextContent(
+ '3',
+ ),
+ );
+ expect(details).toHaveFocus();
+ expect(canvas.getByLabelText('Summary activations')).toHaveTextContent('3');
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemOwnerTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemOwnerTest.ts
new file mode 100644
index 00000000000..9d64f6b2ca5
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemOwnerTest.ts
@@ -0,0 +1,67 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const listItemOwnerTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ const user = userEvent.setup();
+ const digest = canvas.getByRole('button', {
+ name: /^Weekly digest\s*Workspace preference$/,
+ });
+
+ expect(digest.tagName).toBe('BUTTON');
+ expect(digest).toHaveAttribute('type', 'button');
+ expect(digest).toHaveAttribute('data-ref-tag', 'HTML-BUTTON');
+ await user.click(digest);
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Digest state')).toHaveTextContent('enabled'),
+ );
+ expect(canvas.getByLabelText('Click target')).toHaveTextContent(
+ 'click:HTML-BUTTON',
+ );
+ expect(canvas.getByLabelText('Focus target')).toHaveTextContent(
+ 'HTML-BUTTON',
+ );
+ expect(digest).toHaveFocus();
+ await user.keyboard('{Enter} ');
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Digest activations')).toHaveTextContent('3'),
+ );
+ expect(canvas.getByLabelText('Bubbled clicks')).toHaveTextContent('3');
+ expect(canvas.getByLabelText('Last key')).toHaveTextContent('Space');
+
+ const disabledPreference = canvas.getByRole('button', {
+ name: 'Disabled preference',
+ });
+
+ expect(disabledPreference).toBeDisabled();
+ await user.click(disabledPreference);
+ await user.tab();
+ expect(disabledPreference).not.toHaveFocus();
+ expect(canvas.getByLabelText('Digest activations')).toHaveTextContent('3');
+ expect(canvas.getByLabelText('Bubbled clicks')).toHaveTextContent('3');
+
+ await user.click(canvas.getByRole('button', { name: 'Isolated preference' }));
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Suppressed clicks')).toHaveTextContent('1'),
+ );
+ expect(canvas.getByLabelText('Bubbled clicks')).toHaveTextContent('3');
+
+ const link = canvas.getByRole('link', { name: 'Workspace profile' });
+
+ expect(link.tagName).toBe('A');
+ expect(link).toHaveAttribute('href', '#list-item-profile');
+ expect(link).toHaveAttribute('target', '_self');
+ expect(link).toHaveAttribute('data-ref-tag', 'HTML-A');
+ expect(link.querySelector('a')).toBeNull();
+ await user.click(link);
+ await user.keyboard('{Enter}');
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Link activations')).toHaveTextContent('2'),
+ );
+ expect(link).toHaveFocus();
+ await user.keyboard(' ');
+ expect(canvas.getByLabelText('Link activations')).toHaveTextContent('2');
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemPopupOwnerTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemPopupOwnerTest.ts
new file mode 100644
index 00000000000..a613b19b418
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemPopupOwnerTest.ts
@@ -0,0 +1,35 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const listItemPopupOwnerTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ const trigger = canvas.getByRole('button', { name: 'Preference actions' });
+
+ await userEvent.click(trigger);
+ await waitFor(() => expect(trigger).toHaveAttribute('aria-expanded', 'true'));
+
+ const item = await page.findByRole('menuitem', {
+ name: /^Enable notifications\s*Popup owner$/,
+ });
+ const disabledItem = page.getByRole('menuitem', {
+ name: 'Unavailable notifications',
+ });
+
+ await waitFor(() => expect(item).toBeVisible());
+ expect(item.tagName).toBe('BUTTON');
+ expect(item).toHaveAttribute('data-ref-tag', 'HTML-BUTTON');
+ expect(disabledItem).toHaveAttribute('aria-disabled', 'true');
+ await userEvent.click(disabledItem);
+ expect(canvas.getByLabelText('Popup activations')).toHaveTextContent('0');
+ await userEvent.click(item);
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Popup activations')).toHaveTextContent('1'),
+ );
+ await waitFor(() =>
+ expect(trigger).toHaveAttribute('aria-expanded', 'false'),
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemPresentationTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemPresentationTest.ts
new file mode 100644
index 00000000000..1c6343e52d0
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemPresentationTest.ts
@@ -0,0 +1,45 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const listItemPresentationTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ const row = canvas.getByTestId('presentational-list-item');
+ const content = within(row);
+
+ expect(row.tagName).toBe('DIV');
+ expect(row).toHaveAttribute('data-ref-tag', 'HTML-DIV');
+ expect(row).not.toHaveAttribute('role');
+ expect(row).not.toHaveAttribute('tabindex');
+ expect(row).not.toHaveAttribute('aria-disabled');
+ expect(row).toHaveAttribute('data-disabled');
+ expect(row).toHaveAttribute('data-selected');
+ expect(row).toHaveAttribute('data-highlighted');
+ expect(content.queryByRole('link')).not.toBeInTheDocument();
+ expect(
+ within(canvas.getByTestId('plain-url-list-item')).queryByRole('link'),
+ ).not.toBeInTheDocument();
+ expect(content.queryByRole('checkbox')).not.toBeInTheDocument();
+ expect(content.getByText('Visual only')).toBeVisible();
+ expect(content.getByText('End')).toBeVisible();
+ expect(content.getByText('then')).toBeVisible();
+ await userEvent.click(content.getByText('Preference'));
+ await waitFor(() =>
+ expect(
+ canvas.getByLabelText('Presentational activations'),
+ ).toHaveTextContent('1'),
+ );
+ expect(
+ canvas.getByLabelText('Presentational bubbled clicks'),
+ ).toHaveTextContent('1');
+ expect(row).not.toHaveFocus();
+ await userEvent.click(content.getByRole('button', { name: 'Details' }));
+ expect(canvas.getByLabelText('Presentational activations')).toHaveTextContent(
+ '1',
+ );
+ expect(
+ canvas.getByLabelText('Presentational bubbled clicks'),
+ ).toHaveTextContent('1');
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemTest.ts
index b9c36c121fd..676d11fdbb8 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/listItemTest.ts
@@ -4,35 +4,29 @@ import { errorHandler } from '@/__stories__/shared/test-utils/createFrontCompone
import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
import { INTERACTION_TIMEOUT } from '@/__stories__/shared/test-utils/timeouts';
import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+import { listItemButtonTest } from '@/__stories__/twenty-ui-gallery/utils/listItemButtonTest';
+import { listItemOwnerTest } from '@/__stories__/twenty-ui-gallery/utils/listItemOwnerTest';
+import { listItemPopupOwnerTest } from '@/__stories__/twenty-ui-gallery/utils/listItemPopupOwnerTest';
+import { listItemPresentationTest } from '@/__stories__/twenty-ui-gallery/utils/listItemPresentationTest';
const OVERFLOW_LABEL = 'A long workspace preference that overflows its row';
-export const listItemTest: TwentyUiGalleryPlayFunction = async ({
- canvasElement,
-}) => {
+export const listItemTest: TwentyUiGalleryPlayFunction = async (context) => {
+ const { canvasElement } = context;
const user = userEvent.setup();
const canvas = within(canvasElement);
const page = within(canvasElement.ownerDocument.body);
await expectFrontComponentMounted(canvas);
+ await listItemButtonTest(context);
+ await listItemOwnerTest(context);
+ await listItemPresentationTest(context);
+ await listItemPopupOwnerTest(context);
- const digest = canvas.getByText('Weekly digest');
-
- await user.click(digest);
- await waitFor(() =>
- expect(canvas.getByRole('status')).toHaveTextContent('Digest: enabled'),
- );
- await user.click(digest);
- await waitFor(() =>
- expect(canvas.getByRole('status')).toHaveTextContent('Digest: disabled'),
- );
- await user.click(canvas.getByText('Disabled preference'));
- expect(canvas.getByRole('status')).toHaveTextContent('Digest: disabled');
- const hiddenFields = canvas.getByRole('button', {
- name: 'Hidden fields',
+ const digest = canvas.getByRole('button', {
+ name: /^Weekly digest\s*Workspace preference$/,
});
- await user.click(hiddenFields);
- await waitFor(() => expect(canvas.getByText('Fields: open')).toBeVisible());
+ await user.click(digest);
const overflowingLabel = canvas.getByText(OVERFLOW_LABEL);
await waitFor(
() =>
@@ -59,15 +53,14 @@ export const listItemTest: TwentyUiGalleryPlayFunction = async ({
{ timeout: INTERACTION_TIMEOUT },
);
- expect(hiddenFields).toHaveFocus();
+ expect(digest).toHaveFocus();
await user.keyboard('{Escape}');
- await waitFor(() => expect(canvas.getByText('Fields: closed')).toBeVisible());
await waitFor(() =>
expect(page.queryByRole('tooltip')).not.toBeInTheDocument(),
);
await user.click(digest);
await waitFor(() =>
- expect(canvas.getByRole('status')).toHaveTextContent('Digest: enabled'),
+ expect(canvas.getByLabelText('Digest activations')).toHaveTextContent('5'),
);
expect(errorHandler).not.toHaveBeenCalled();
};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/pickerListItemsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/pickerListItemsTest.ts
index efb799a6230..3968c684a0d 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/pickerListItemsTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/pickerListItemsTest.ts
@@ -36,9 +36,13 @@ export const pickerListItemsTest: TwentyUiGalleryPlayFunction = async ({
);
expect(canvas.getByRole('status')).toHaveTextContent('Changes: 2');
- await userEvent.click(
- canvas.getByRole('option', { name: 'Unavailable color' }),
- );
+ const unavailableColor = canvas.getByRole('option', {
+ name: 'Unavailable color',
+ });
+
+ expect(unavailableColor).toBeDisabled();
+ expect(unavailableColor).toHaveAttribute('aria-disabled', 'true');
+ await userEvent.click(unavailableColor);
expect(canvas.getByRole('status')).toHaveTextContent('Changes: 2');
expect(canvas.queryByRole('checkbox')).toBeNull();
expect(errorHandler).not.toHaveBeenCalled();
diff --git a/packages/twenty-front/src/modules/ai/components/AgentOutputSchemaBuilder.tsx b/packages/twenty-front/src/modules/ai/components/AgentOutputSchemaBuilder.tsx
index 4d27cf6593d..65a22e80650 100644
--- a/packages/twenty-front/src/modules/ai/components/AgentOutputSchemaBuilder.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AgentOutputSchemaBuilder.tsx
@@ -10,7 +10,7 @@ import { useState } from 'react';
import { isValidAgentResponseSchemaPropertyKey } from 'twenty-shared/ai';
import { IconPlus } from 'twenty-ui/icon';
import { Collapsible } from 'twenty-ui/primitives/layout';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { themeCssVariables } from 'twenty-ui/theme';
import { AgentOutputFieldTypeSelector } from '@/ai/components/AgentOutputFieldTypeSelector';
import { AgentOutputSchemaFieldHeader } from '@/ai/components/AgentOutputSchemaFieldHeader';
@@ -212,10 +212,10 @@ export const AgentOutputSchemaBuilder = ({
{!readonly && (
<StyledAddFieldButtonContainer>
- <ListItem
+ <ListItemButton
startIcon={<IconPlus />}
onClick={addField}
- >{t`Add Output Field`}</ListItem>
+ >{t`Add Output Field`}</ListItemButton>
</StyledAddFieldButtonContainer>
)}
</StyledOutputSchemaContainer>
diff --git a/packages/twenty-front/src/modules/applications/components/AppMenuItem.tsx b/packages/twenty-front/src/modules/applications/components/AppMenuItem.tsx
index 1d59432d021..9f791445047 100644
--- a/packages/twenty-front/src/modules/applications/components/AppMenuItem.tsx
+++ b/packages/twenty-front/src/modules/applications/components/AppMenuItem.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { AppMenuItemIcon } from '@/applications/components/AppMenuItemIcon';
import { useApplicationChipData } from '@/applications/hooks/useApplicationChipData';
import { type ReactNode } from 'react';
@@ -25,7 +25,7 @@ export const AppMenuItem = ({
});
return (
- <ListItem
+ <ListItemButton
startIcon={<AppMenuItemIcon applicationId={applicationId} />}
description={applicationChipData.name}
onClick={onClick}
@@ -34,6 +34,6 @@ export const AppMenuItem = ({
endIcon={RightComponent}
>
{text}
- </ListItem>
+ </ListItemButton>
);
};
diff --git a/packages/twenty-front/src/modules/command-menu-item/components/__stories__/RecordIndexCommandMenuDropdown.stories.tsx b/packages/twenty-front/src/modules/command-menu-item/components/__stories__/RecordIndexCommandMenuDropdown.stories.tsx
index ae630e281b3..6db930dadca 100644
--- a/packages/twenty-front/src/modules/command-menu-item/components/__stories__/RecordIndexCommandMenuDropdown.stories.tsx
+++ b/packages/twenty-front/src/modules/command-menu-item/components/__stories__/RecordIndexCommandMenuDropdown.stories.tsx
@@ -341,7 +341,7 @@ export const AsyncExportStaysOpenWithProgress: Story = {
name: /Export 37%/,
});
- expect(exportAction).toHaveAttribute('aria-disabled', 'true');
+ expect(exportAction).toBeDisabled();
await userEvent.click(exportAction);
expect(jotaiStore.get(headlessCommandContextApisState.atom)).toBe(
diff --git a/packages/twenty-front/src/modules/command-menu-item/components/__stories__/RecordShowSidePanelCommandMenuDropdown.stories.tsx b/packages/twenty-front/src/modules/command-menu-item/components/__stories__/RecordShowSidePanelCommandMenuDropdown.stories.tsx
index 3dc06a94d1e..fe98d12851a 100644
--- a/packages/twenty-front/src/modules/command-menu-item/components/__stories__/RecordShowSidePanelCommandMenuDropdown.stories.tsx
+++ b/packages/twenty-front/src/modules/command-menu-item/components/__stories__/RecordShowSidePanelCommandMenuDropdown.stories.tsx
@@ -158,7 +158,7 @@ export const AsyncExportShowsProgressAndPreventsRepeatedExecution: Story = {
const exportAction = await canvas.findByRole('menuitem', {
name: /Export 37%/,
});
- expect(exportAction).toHaveAttribute('aria-disabled', 'true');
+ expect(exportAction).toBeDisabled();
await userEvent.click(exportAction);
expect(jotaiStore.get(headlessCommandContextApisState.atom)).toBe(
diff --git a/packages/twenty-front/src/modules/log-console/components/LogConsoleTimeRangeDropdown.tsx b/packages/twenty-front/src/modules/log-console/components/LogConsoleTimeRangeDropdown.tsx
index 1c1ea00e692..882e37200a5 100644
--- a/packages/twenty-front/src/modules/log-console/components/LogConsoleTimeRangeDropdown.tsx
+++ b/packages/twenty-front/src/modules/log-console/components/LogConsoleTimeRangeDropdown.tsx
@@ -9,7 +9,7 @@ import {
IconChevronLeft,
} from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
import { useDateTimeFormat } from '@/localization/hooks/useDateTimeFormat';
@@ -97,7 +97,7 @@ export const LogConsoleTimeRangeDropdown = ({
disabled={isWithinRetention}
side="right"
>
- <ListItem
+ <ListItemButton
role="option"
aria-selected={itemTimeRange === timeRange}
selected={itemTimeRange === timeRange}
@@ -106,7 +106,7 @@ export const LogConsoleTimeRangeDropdown = ({
onClick={() => selectTimeRange(itemTimeRange)}
>
{getTimeRangeLabel(itemTimeRange)}
- </ListItem>
+ </ListItemButton>
</Tooltip>
);
};
@@ -139,7 +139,7 @@ export const LogConsoleTimeRangeDropdown = ({
</DropdownMenuHeader>
<DropdownMenuItemsContainer scrollable={false}>
{timeZoneOptions.map((timeZoneOption) => (
- <ListItem
+ <ListItemButton
key={timeZoneOption.value}
role="option"
aria-selected={timeZoneOption.value === logConsoleTimeZone}
@@ -148,7 +148,7 @@ export const LogConsoleTimeRangeDropdown = ({
onClick={() => setLogConsoleTimeZone(timeZoneOption.value)}
>
{timeZoneOption.label}
- </ListItem>
+ </ListItemButton>
))}
</DropdownMenuItemsContainer>
</LegacyDropdownContent>
@@ -166,7 +166,7 @@ export const LogConsoleTimeRangeDropdown = ({
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
description={plural(retentionInDays, {
one: '# day',
other: '# days',
@@ -176,15 +176,15 @@ export const LogConsoleTimeRangeDropdown = ({
onClick={openRetentionSettings}
>
{t`Retention`}
- </ListItem>
- <ListItem
+ </ListItemButton>
+ <ListItemButton
description={selectedTimeZoneLabel}
descriptionPlacement="end"
hasSubmenu
onClick={() => setIsTimeZoneMenuOpen(true)}
>
{t`Time zone`}
- </ListItem>
+ </ListItemButton>
</DropdownMenuItemsContainer>
</LegacyDropdownContent>
)
diff --git a/packages/twenty-front/src/modules/log-console/components/LogConsoleToolbar.tsx b/packages/twenty-front/src/modules/log-console/components/LogConsoleToolbar.tsx
index 4cde4d81a68..de5f3cb0e8c 100644
--- a/packages/twenty-front/src/modules/log-console/components/LogConsoleToolbar.tsx
+++ b/packages/twenty-front/src/modules/log-console/components/LogConsoleToolbar.tsx
@@ -12,6 +12,7 @@ import {
IconFilter,
IconX,
} from 'twenty-ui/icon';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -280,7 +281,7 @@ export const LogConsoleToolbar = ({
const isSelected = isOptionSelected(filter, option);
return (
- <ListItem
+ <ListItemButton
key={option.values.join()}
role="option"
aria-selected={isSelected}
@@ -295,7 +296,7 @@ export const LogConsoleToolbar = ({
onClick={() => toggleOption(filter, option)}
>
{option.tag ?? option.label}
- </ListItem>
+ </ListItemButton>
);
})
) : (
@@ -334,7 +335,7 @@ export const LogConsoleToolbar = ({
<DropdownMenuItemsContainer>
{isNonEmptyArray(matchingFilterFields) ? (
matchingFilterFields.map((filterField) => (
- <ListItem
+ <ListItemButton
key={filterField.id}
role="option"
startIcon={<filterField.Icon />}
@@ -344,7 +345,7 @@ export const LogConsoleToolbar = ({
}}
>
{t(filterField.label)}
- </ListItem>
+ </ListItemButton>
))
) : (
<ListItem disabled>{t`No results`}</ListItem>
@@ -415,17 +416,20 @@ export const LogConsoleToolbar = ({
<LegacyDropdownContent>
<DropdownMenuItemsContainer>
{isNonEmptyArray(filterFields) && (
- <ListItem
+ <ListItemButton
startIcon={<IconFilter />}
hasSubmenu
onClick={() => setIsFilterSubmenuOpen(true)}
>
{t`Filter`}
- </ListItem>
+ </ListItemButton>
)}
- <ListItem startIcon={<logsAction.Icon />} onClick={runLogsAction}>
+ <ListItemButton
+ startIcon={<logsAction.Icon />}
+ onClick={runLogsAction}
+ >
{logsAction.label}
- </ListItem>
+ </ListItemButton>
</DropdownMenuItemsContainer>
</LegacyDropdownContent>
);
diff --git a/packages/twenty-front/src/modules/log-console/components/__stories__/LogConsole.stories.tsx b/packages/twenty-front/src/modules/log-console/components/__stories__/LogConsole.stories.tsx
index c39e3e13120..f1620c40d7c 100644
--- a/packages/twenty-front/src/modules/log-console/components/__stories__/LogConsole.stories.tsx
+++ b/packages/twenty-front/src/modules/log-console/components/__stories__/LogConsole.stories.tsx
@@ -570,7 +570,7 @@ export const TimeRangeMenu: Story = {
expect(
await screen.findByRole('option', { name: 'Last 90 days' }),
- ).toHaveAttribute('aria-disabled', 'true');
+ ).toBeDisabled();
},
};
diff --git a/packages/twenty-front/src/modules/navigation-menu-item/edit/components/__stories__/NavigationMenuItemSelectableItem.stories.tsx b/packages/twenty-front/src/modules/navigation-menu-item/edit/components/__stories__/NavigationMenuItemSelectableItem.stories.tsx
index 6a5620e88b2..35aff6234ef 100644
--- a/packages/twenty-front/src/modules/navigation-menu-item/edit/components/__stories__/NavigationMenuItemSelectableItem.stories.tsx
+++ b/packages/twenty-front/src/modules/navigation-menu-item/edit/components/__stories__/NavigationMenuItemSelectableItem.stories.tsx
@@ -74,7 +74,7 @@ export const IgnoresDisabledDestination: Story = {
await expect(
await canvas.findByRole('menuitem', { name: 'Unavailable destination' }),
- ).toHaveAttribute('aria-disabled', 'true');
+ ).toBeDisabled();
await userEvent.click(await canvas.findByText('Unavailable destination'));
await expect(onChooseUnavailableDestination).not.toHaveBeenCalled();
diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCountrySelect.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCountrySelect.tsx
index 3d1212e0aee..9bc8d35c795 100644
--- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCountrySelect.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCountrySelect.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import { useApplyObjectFilterDropdownFilterValue } from '@/object-record/object-filter-dropdown/hooks/useApplyObjectFilterDropdownFilterValue';
import { fieldMetadataItemUsedInDropdownComponentSelector } from '@/object-record/object-filter-dropdown/states/fieldMetadataItemUsedInDropdownComponentSelector';
@@ -118,8 +119,7 @@ export const ObjectFilterDropdownCountrySelect = () => {
<DropdownMenuItemsContainer isMultiSelect hasMaxHeight>
{filteredSelectedItems?.map((item) => {
return (
- <ListItem
- render={<button type="button" />}
+ <ListItemButton
key={item.id}
role="option"
aria-selected={true}
@@ -131,13 +131,12 @@ export const ObjectFilterDropdownCountrySelect = () => {
startIcon={getCountryFlagMenuItemAvatar(item.name, countries)}
>
{item.name}
- </ListItem>
+ </ListItemButton>
);
})}
{filteredSelectableItems?.map((item) => {
return (
- <ListItem
- render={<button type="button" />}
+ <ListItemButton
key={item.id}
role="option"
aria-selected={false}
@@ -149,7 +148,7 @@ export const ObjectFilterDropdownCountrySelect = () => {
startIcon={getCountryFlagMenuItemAvatar(item.name, countries)}
>
{item.name}
- </ListItem>
+ </ListItemButton>
);
})}
{showNoResult && <ListItem disabled>{t`No results`}</ListItem>}
diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCurrencySelect.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCurrencySelect.tsx
index fd534d178d1..e97bd8ecb1b 100644
--- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCurrencySelect.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCurrencySelect.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import { useApplyObjectFilterDropdownFilterValue } from '@/object-record/object-filter-dropdown/hooks/useApplyObjectFilterDropdownFilterValue';
import { fieldMetadataItemUsedInDropdownComponentSelector } from '@/object-record/object-filter-dropdown/states/fieldMetadataItemUsedInDropdownComponentSelector';
@@ -117,8 +118,7 @@ export const ObjectFilterDropdownCurrencySelect = () => {
<DropdownMenuItemsContainer isMultiSelect hasMaxHeight>
{filteredSelectedItems?.map((item) => {
return (
- <ListItem
- render={<button type="button" />}
+ <ListItemButton
key={item.id}
role="option"
aria-selected={true}
@@ -130,13 +130,12 @@ export const ObjectFilterDropdownCurrencySelect = () => {
startIcon={item.AvatarIcon && <item.AvatarIcon size="16" />}
>
{item.name}
- </ListItem>
+ </ListItemButton>
);
})}
{filteredSelectableItems?.map((item) => {
return (
- <ListItem
- render={<button type="button" />}
+ <ListItemButton
key={item.id}
role="option"
aria-selected={false}
@@ -148,7 +147,7 @@ export const ObjectFilterDropdownCurrencySelect = () => {
startIcon={item.AvatarIcon && <item.AvatarIcon size="16" />}
>
{item.name}
- </ListItem>
+ </ListItemButton>
);
})}
{showNoResult && <ListItem disabled>{t`No results`}</ListItem>}
diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownOptionSelect.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownOptionSelect.tsx
index 0993f019eda..32e8bc2c398 100644
--- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownOptionSelect.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownOptionSelect.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { fieldMetadataItemByIdSelector } from '@/object-metadata/states/fieldMetadataItemByIdSelector';
import { type FieldMetadataItemOption } from '@/object-metadata/types/FieldMetadataItem';
import { useApplyObjectFilterDropdownFilterValue } from '@/object-record/object-filter-dropdown/hooks/useApplyObjectFilterDropdownFilterValue';
@@ -176,8 +177,7 @@ export const ObjectFilterDropdownOptionSelect = ({
<ListItem disabled>{t`No results`}</ListItem>
) : (
optionsInDropdown?.map((option) => (
- <ListItem
- render={<button type="button" />}
+ <ListItemButton
key={option.id}
className=""
focused={option.id === selectedItemId}
@@ -194,7 +194,7 @@ export const ObjectFilterDropdownOptionSelect = ({
) : (
<OverflowingTextWithTooltip text={option.label} />
)}
- </ListItem>
+ </ListItemButton>
))
)}
</DropdownMenuItemsContainer>
diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownRecordPinnedItems.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownRecordPinnedItems.tsx
index ed5997b97ba..d658a809d2a 100644
--- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownRecordPinnedItems.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownRecordPinnedItems.tsx
@@ -1,7 +1,7 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { type SelectableItem } from '@/object-record/select/types/SelectableItem';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { Avatar } from 'twenty-ui/primitives/data-display';
-import { ListItem } from 'twenty-ui/primitives/navigation';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
export const ObjectFilterDropdownRecordPinnedItems = (props: {
@@ -15,8 +15,7 @@ export const ObjectFilterDropdownRecordPinnedItems = (props: {
<DropdownMenuItemsContainer isMultiSelect scrollable={false}>
{props.selectableItems.map((selectableItem) => {
return (
- <ListItem
- render={<button type="button" />}
+ <ListItemButton
key={selectableItem.id}
role="option"
aria-selected={selectableItem.isSelected}
@@ -42,7 +41,7 @@ export const ObjectFilterDropdownRecordPinnedItems = (props: {
}
>
{selectableItem.name}
- </ListItem>
+ </ListItemButton>
);
})}
</DropdownMenuItemsContainer>
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCalendarFieldsContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCalendarFieldsContent.tsx
index 411926cf4be..667a4c25418 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCalendarFieldsContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCalendarFieldsContent.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { type FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
@@ -81,7 +81,7 @@ export const ObjectOptionsDropdownCalendarFieldsContent = () => {
<DropdownMenuSeparator />
<DropdownMenuItemsContainer>
{filteredCalendarFields.map((fieldMetadataItem) => (
- <ListItem
+ <ListItemButton
key={fieldMetadataItem.id}
onClick={() => handleCalendarFieldChange(fieldMetadataItem)}
role="option"
@@ -93,18 +93,18 @@ export const ObjectOptionsDropdownCalendarFieldsContent = () => {
}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
))}
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
startIcon={<IconSettings />}
onClick={() => {
navigateToDateFieldSettings();
closeDropdown();
}}
- >{t`Create date field`}</ListItem>
+ >{t`Create date field`}</ListItemButton>
</DropdownMenuItemsContainer>
</LegacyDropdownContent>
);
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCalendarViewContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCalendarViewContent.tsx
index b8b380b2dc1..58ffe951b43 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCalendarViewContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCalendarViewContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
import { recordIndexCalendarLayoutComponentState } from '@/object-record/record-index/states/recordIndexCalendarLayoutComponentState';
import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
@@ -20,7 +21,6 @@ import {
IconTimelineEvent,
} from 'twenty-ui/icon';
import { Pill } from 'twenty-ui/primitives/data-display';
-import { ListItem } from 'twenty-ui/primitives/navigation';
import { ViewCalendarLayout } from '~/generated-metadata/graphql';
const RECORD_CALENDAR_TIMELINE_VIEW_ID = 'record-calendar-timeline-view';
@@ -84,7 +84,7 @@ export const ObjectOptionsDropdownCalendarViewContent = () => {
itemId={ViewCalendarLayout.DAY}
onEnter={() => handleCalendarViewChange(ViewCalendarLayout.DAY)}
>
- <ListItem
+ <ListItemButton
onClick={() => handleCalendarViewChange(ViewCalendarLayout.DAY)}
focused={selectedItemId === ViewCalendarLayout.DAY}
role="option"
@@ -94,13 +94,13 @@ export const ObjectOptionsDropdownCalendarViewContent = () => {
selected={recordIndexCalendarLayout === ViewCalendarLayout.DAY}
indicator="check"
startIcon={<SelectOptionIcon Icon={IconCalendarEvent} />}
- >{t`Day`}</ListItem>
+ >{t`Day`}</ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId={ViewCalendarLayout.WEEK}
onEnter={() => handleCalendarViewChange(ViewCalendarLayout.WEEK)}
>
- <ListItem
+ <ListItemButton
onClick={() => handleCalendarViewChange(ViewCalendarLayout.WEEK)}
focused={selectedItemId === ViewCalendarLayout.WEEK}
role="option"
@@ -110,13 +110,13 @@ export const ObjectOptionsDropdownCalendarViewContent = () => {
selected={recordIndexCalendarLayout === ViewCalendarLayout.WEEK}
indicator="check"
startIcon={<SelectOptionIcon Icon={IconCalendarWeek} />}
- >{t`Week`}</ListItem>
+ >{t`Week`}</ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId={ViewCalendarLayout.MONTH}
onEnter={() => handleCalendarViewChange(ViewCalendarLayout.MONTH)}
>
- <ListItem
+ <ListItemButton
onClick={() => handleCalendarViewChange(ViewCalendarLayout.MONTH)}
focused={selectedItemId === ViewCalendarLayout.MONTH}
role="option"
@@ -126,10 +126,10 @@ export const ObjectOptionsDropdownCalendarViewContent = () => {
selected={recordIndexCalendarLayout === ViewCalendarLayout.MONTH}
indicator="check"
startIcon={<SelectOptionIcon Icon={IconCalendarMonth} />}
- >{t`Month`}</ListItem>
+ >{t`Month`}</ListItemButton>
</SelectableListItem>
<SelectableListItem itemId={RECORD_CALENDAR_TIMELINE_VIEW_ID}>
- <ListItem
+ <ListItemButton
focused={selectedItemId === RECORD_CALENDAR_TIMELINE_VIEW_ID}
disabled
role="option"
@@ -139,7 +139,7 @@ export const ObjectOptionsDropdownCalendarViewContent = () => {
description={<Pill label={t`Soon`} />}
descriptionPlacement={'end'}
startIcon={<SelectOptionIcon Icon={IconTimelineEvent} />}
- >{t`Timeline`}</ListItem>
+ >{t`Timeline`}</ListItemButton>
</SelectableListItem>
</SelectableList>
</DropdownMenuItemsContainer>
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCustomView.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCustomView.tsx
index aeadc65446c..d0d94e3cf3d 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCustomView.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownCustomView.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { ObjectOptionsDropdownMenuViewName } from '@/object-record/object-options-dropdown/components/ObjectOptionsDropdownMenuViewName';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
@@ -149,7 +149,7 @@ export const ObjectOptionsDropdownCustomView = ({
itemId="Layout"
onEnter={() => onContentChange('layout')}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Layout'}
onClick={() => onContentChange('layout')}
startIcon={
@@ -162,13 +162,13 @@ export const ObjectOptionsDropdownCustomView = ({
description={t(getViewTypeLabel(customViewData.type))}
descriptionPlacement="end"
hasSubmenu
- >{t`Layout`}</ListItem>
+ >{t`Layout`}</ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId="Visibility"
onEnter={() => onContentChange('visibility')}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Visibility'}
onClick={() => onContentChange('visibility')}
startIcon={<IconShare />}
@@ -179,7 +179,7 @@ export const ObjectOptionsDropdownCustomView = ({
}
descriptionPlacement="end"
hasSubmenu
- >{t`Visibility`}</ListItem>
+ >{t`Visibility`}</ListItemButton>
</SelectableListItem>
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
@@ -189,9 +189,13 @@ export const ObjectOptionsDropdownCustomView = ({
<div id="calendar-date-field-picker-menu-item">
<SelectableListItem
itemId="CalendarDateField"
- onEnter={() => onContentChange('calendarFields')}
+ onEnter={
+ isDefaultView
+ ? undefined
+ : () => onContentChange('calendarFields')
+ }
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'CalendarDateField'}
onClick={() => onContentChange('calendarFields')}
startIcon={<IconCalendar />}
@@ -203,14 +207,14 @@ export const ObjectOptionsDropdownCustomView = ({
descriptionPlacement="end"
hasSubmenu
disabled={isDefaultView}
- >{t`Date field`}</ListItem>
+ >{t`Date field`}</ListItemButton>
</SelectableListItem>
</div>
<SelectableListItem
itemId="CalendarView"
onEnter={() => onContentChange('calendarView')}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'CalendarView'}
onClick={() => onContentChange('calendarView')}
startIcon={<IconCalendarWeek />}
@@ -222,7 +226,7 @@ export const ObjectOptionsDropdownCustomView = ({
: t`Day`
}
descriptionPlacement="end"
- >{t`Calendar view`}</ListItem>
+ >{t`Calendar view`}</ListItemButton>
</SelectableListItem>
</>
)}
@@ -230,14 +234,14 @@ export const ObjectOptionsDropdownCustomView = ({
itemId="Fields"
onEnter={() => onContentChange('fields')}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Fields'}
onClick={() => onContentChange('fields')}
startIcon={<IconListDetails />}
description={t`${visibleFieldsCount} selected`}
descriptionPlacement="end"
hasSubmenu
- >{t`Fields`}</ListItem>
+ >{t`Fields`}</ListItemButton>
</SelectableListItem>
{customViewData?.type !== ViewType.CALENDAR && (
<Tooltip
@@ -250,13 +254,16 @@ export const ObjectOptionsDropdownCustomView = ({
<div id="group-by-menu-item">
<SelectableListItem
itemId="Group"
- onEnter={() =>
- isDefined(recordIndexGroupFieldMetadataItem)
- ? onContentChange('recordGroups')
- : onContentChange('recordGroupFields')
+ onEnter={
+ isDefaultView
+ ? undefined
+ : () =>
+ isDefined(recordIndexGroupFieldMetadataItem)
+ ? onContentChange('recordGroups')
+ : onContentChange('recordGroupFields')
}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Group'}
onClick={() =>
isDefined(recordIndexGroupFieldMetadataItem)
@@ -272,7 +279,7 @@ export const ObjectOptionsDropdownCustomView = ({
descriptionPlacement="end"
hasSubmenu
disabled={isDefaultView}
- >{t`Group`}</ListItem>
+ >{t`Group`}</ListItemButton>
</SelectableListItem>
</div>
</Tooltip>
@@ -294,15 +301,15 @@ export const ObjectOptionsDropdownCustomView = ({
<div id="delete-view-menu-item">
<SelectableListItem
itemId="Delete view"
- onEnter={() => handleDelete()}
+ onEnter={isDefaultView || isLastView ? undefined : handleDelete}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Delete view'}
onClick={() => handleDelete()}
startIcon={<IconTrash />}
disabled={isDefaultView || isLastView}
color="danger"
- >{t`Delete view`}</ListItem>
+ >{t`Delete view`}</ListItemButton>
</SelectableListItem>
</div>
</Tooltip>
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownDefaultView.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownDefaultView.tsx
index 34ba75f96ae..fa690043548 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownDefaultView.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownDefaultView.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
@@ -82,14 +83,14 @@ export const ObjectOptionsDropdownDefaultView = () => {
itemId="Fields"
onEnter={() => onContentChange('fields')}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Fields'}
onClick={() => onContentChange('fields')}
startIcon={<IconListDetails />}
description={t`${visibleFieldsCount} selected`}
descriptionPlacement="end"
hasSubmenu
- >{t`Fields`}</ListItem>
+ >{t`Fields`}</ListItemButton>
</SelectableListItem>
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
@@ -101,24 +102,24 @@ export const ObjectOptionsDropdownDefaultView = () => {
copyToClipboard(currentUrl, t`Link copied to clipboard`);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Copy link to view'}
onClick={() => {
const currentUrl = window.location.href;
copyToClipboard(currentUrl, t`Link copied to clipboard`);
}}
startIcon={<IconCopy />}
- >{t`Copy link to view`}</ListItem>
+ >{t`Copy link to view`}</ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId="Create custom view"
onEnter={handleCreateCustomView}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Create custom view'}
onClick={handleCreateCustomView}
startIcon={<IconLayout />}
- >{t`Create custom view`}</ListItem>
+ >{t`Create custom view`}</ListItemButton>
</SelectableListItem>
</DropdownMenuItemsContainer>
</SelectableList>
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownFieldsContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownFieldsContent.tsx
index 39ed2bed624..59945ace7ec 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownFieldsContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownFieldsContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
import { LegacyDropdownContent } from '@/ui/layout/dropdown/components/LegacyDropdownContent';
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader/DropdownMenuHeader';
@@ -11,7 +12,6 @@ import { useLingui } from '@lingui/react/macro';
import { isNonEmptyString } from '@sniptt/guards';
import { useState } from 'react';
import { IconChevronLeft, IconEyeOff } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
export const ObjectOptionsDropdownFieldsContent = () => {
const { t } = useLingui();
@@ -45,12 +45,11 @@ export const ObjectOptionsDropdownFieldsContent = () => {
<ViewFieldsVisibleDropdownSection />
<DropdownMenuSeparator />
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
onClick={() => onContentChange('hiddenFields')}
startIcon={<IconEyeOff />}
- render={<button type="button" />}
hasSubmenu
- >{t`Hidden Fields`}</ListItem>
+ >{t`Hidden Fields`}</ListItemButton>
</DropdownMenuItemsContainer>
</>
)}
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownLayoutContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownLayoutContent.tsx
index df4c0c64c5d..dd623ca111d 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownLayoutContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownLayoutContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
import { useSetViewTypeFromLayoutOptionsMenu } from '@/object-record/object-options-dropdown/hooks/useSetViewTypeFromLayoutOptionsMenu';
import { recordIndexCalendarLayoutComponentState } from '@/object-record/record-index/states/recordIndexCalendarLayoutComponentState';
@@ -36,7 +37,6 @@ import {
IconLayoutList,
IconTable,
} from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
import { ViewCalendarLayout } from '~/generated-metadata/graphql';
export const ObjectOptionsDropdownLayoutContent = () => {
@@ -157,7 +157,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
setAndPersistViewType(ViewType.TABLE);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === ViewType.TABLE}
onClick={async () => {
if (currentView?.type !== ViewType.TABLE) {
@@ -171,7 +171,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
startIcon={<IconTable />}
>
{t(getViewTypeLabel(ViewType.TABLE))}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId={ViewType.LIST}
@@ -179,7 +179,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
setAndPersistViewType(ViewType.LIST);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === ViewType.LIST}
onClick={async () => {
if (currentView?.type !== ViewType.LIST) {
@@ -195,7 +195,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
}
>
{t(getViewTypeLabel(ViewType.LIST))}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId={ViewType.CALENDAR}
@@ -203,7 +203,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
setAndPersistViewType(ViewType.CALENDAR);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === ViewType.CALENDAR}
onClick={handleSelectCalendarViewType}
role="option"
@@ -217,7 +217,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
}
>
{t(getViewTypeLabel(ViewType.CALENDAR))}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId={ViewType.KANBAN}
@@ -225,7 +225,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
setAndPersistViewType(ViewType.KANBAN);
}}
>
- <ListItem
+ <ListItemButton
disabled={isDefaultView}
focused={selectedItemId === ViewType.KANBAN}
onClick={handleSelectKanbanViewType}
@@ -253,7 +253,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
}
>
{t(getViewTypeLabel(ViewType.KANBAN))}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
@@ -264,20 +264,20 @@ export const ObjectOptionsDropdownLayoutContent = () => {
itemId="CalendarDateField"
onEnter={() => onContentChange('calendarFields')}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'CalendarDateField'}
onClick={() => onContentChange('calendarFields')}
startIcon={<IconCalendar />}
description={calendarFieldMetadata?.label}
descriptionPlacement="end"
hasSubmenu
- >{t`Date field`}</ListItem>
+ >{t`Date field`}</ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId="CalendarView"
onEnter={() => onContentChange('calendarView')}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'CalendarView'}
onClick={() => onContentChange('calendarView')}
startIcon={<IconCalendarWeek />}
@@ -290,7 +290,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
}
descriptionPlacement="end"
hasSubmenu
- >{t`Calendar view`}</ListItem>
+ >{t`Calendar view`}</ListItemButton>
</SelectableListItem>
</>
)}
@@ -303,7 +303,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
: onContentChange('recordGroupFields');
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Group'}
onClick={() =>
isDefined(recordIndexGroupFieldMetadataItem)
@@ -314,7 +314,7 @@ export const ObjectOptionsDropdownLayoutContent = () => {
description={recordIndexGroupFieldMetadataItem?.label}
descriptionPlacement="end"
hasSubmenu
- >{t`Group`}</ListItem>
+ >{t`Group`}</ListItemButton>
</SelectableListItem>
)}
{currentView?.type !== ViewType.TABLE &&
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupFieldsContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupFieldsContent.tsx
index 2cfede81ca0..23c6becc157 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupFieldsContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupFieldsContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useObjectNamePluralFromSingular } from '@/object-metadata/hooks/useObjectNamePluralFromSingular';
import { type FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
@@ -124,16 +125,16 @@ export const ObjectOptionsDropdownRecordGroupFieldsContent = () => {
<DropdownMenuSeparator />
<DropdownMenuItemsContainer>
{isRecordGroupingOptionalForViewType(viewType) && (
- <ListItem
+ <ListItemButton
onClick={handleResetRecordGroupField}
role="option"
aria-selected={!isDefined(recordIndexGroupFieldMetadataItem)}
selected={!isDefined(recordIndexGroupFieldMetadataItem)}
indicator="check"
- >{t`None`}</ListItem>
+ >{t`None`}</ListItemButton>
)}
{filteredRecordGroupFieldMetadataItems.map((fieldMetadataItem) => (
- <ListItem
+ <ListItemButton
key={fieldMetadataItem.id}
onClick={() => handleRecordGroupFieldChange(fieldMetadataItem)}
role="option"
@@ -149,7 +150,7 @@ export const ObjectOptionsDropdownRecordGroupFieldsContent = () => {
}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
))}
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupLoadLimitContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupLoadLimitContent.tsx
index faead6ece43..5c3adcfd5bd 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupLoadLimitContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupLoadLimitContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
import { useRecordGroupVisibility } from '@/object-record/record-group/hooks/useRecordGroupVisibility';
import { recordIndexGroupLoadLimitComponentState } from '@/object-record/record-index/states/recordIndexGroupLoadLimitComponentState';
@@ -12,7 +13,6 @@ import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/use
import { t } from '@lingui/core/macro';
import { VIEW_GROUP_LOAD_LIMIT_OPTIONS } from 'twenty-shared/constants';
import { IconChevronLeft } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
export const ObjectOptionsDropdownRecordGroupLoadLimitContent = () => {
const { onContentChange, dropdownId } = useObjectOptionsDropdown();
@@ -55,7 +55,7 @@ export const ObjectOptionsDropdownRecordGroupLoadLimitContent = () => {
itemId={String(loadLimitOption)}
onEnter={() => handleGroupLoadLimitChange(loadLimitOption)}
>
- <ListItem
+ <ListItemButton
onClick={() => handleGroupLoadLimitChange(loadLimitOption)}
focused={selectedItemId === String(loadLimitOption)}
role="option"
@@ -64,7 +64,7 @@ export const ObjectOptionsDropdownRecordGroupLoadLimitContent = () => {
indicator="check"
>
{String(loadLimitOption)}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupSortContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupSortContent.tsx
index 656d1200482..eb9c9d83499 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupSortContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupSortContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { isManyToOneRelationField } from '@/object-metadata/utils/isManyToOneRelationField';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
import { hiddenRecordGroupIdsComponentSelector } from '@/object-record/record-group/states/selectors/hiddenRecordGroupIdsComponentSelector';
@@ -24,7 +25,6 @@ import {
IconSortAZ,
IconSortZA,
} from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
export const ObjectOptionsDropdownRecordGroupSortContent = () => {
const { currentContentId, onContentChange, dropdownId } =
@@ -93,7 +93,7 @@ export const ObjectOptionsDropdownRecordGroupSortContent = () => {
itemId={RecordGroupSort.Manual}
onEnter={() => handleRecordGroupSortChange(RecordGroupSort.Manual)}
>
- <ListItem
+ <ListItemButton
onClick={() =>
handleRecordGroupSortChange(RecordGroupSort.Manual)
}
@@ -107,7 +107,7 @@ export const ObjectOptionsDropdownRecordGroupSortContent = () => {
startIcon={<SelectOptionIcon Icon={IconHandMove} />}
>
{RecordGroupSort.Manual}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
{!isRelationGroupBy && (
<>
@@ -117,7 +117,7 @@ export const ObjectOptionsDropdownRecordGroupSortContent = () => {
handleRecordGroupSortChange(RecordGroupSort.Alphabetical)
}
>
- <ListItem
+ <ListItemButton
onClick={() =>
handleRecordGroupSortChange(RecordGroupSort.Alphabetical)
}
@@ -133,7 +133,7 @@ export const ObjectOptionsDropdownRecordGroupSortContent = () => {
startIcon={<SelectOptionIcon Icon={IconSortAZ} />}
>
{RecordGroupSort.Alphabetical}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId={RecordGroupSort.ReverseAlphabetical}
@@ -143,7 +143,7 @@ export const ObjectOptionsDropdownRecordGroupSortContent = () => {
)
}
>
- <ListItem
+ <ListItemButton
onClick={() =>
handleRecordGroupSortChange(
RecordGroupSort.ReverseAlphabetical,
@@ -165,7 +165,7 @@ export const ObjectOptionsDropdownRecordGroupSortContent = () => {
startIcon={<SelectOptionIcon Icon={IconSortZA} />}
>
{RecordGroupSort.ReverseAlphabetical}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
</>
)}
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent.tsx
index 43285a94108..d0cc63ed0ab 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useEffect } from 'react';
import { isManyToOneRelationField } from '@/object-metadata/utils/isManyToOneRelationField';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
@@ -153,7 +153,7 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {
onContentChange('recordGroupFields')
}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'GroupBy'}
disabled={isGroupByFieldPickerDisabled}
onClick={() => onContentChange('recordGroupFields')}
@@ -161,20 +161,20 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {
description={recordIndexGroupFieldMetadataItem?.label}
descriptionPlacement="end"
hasSubmenu
- >{t`Group by`}</ListItem>
+ >{t`Group by`}</ListItemButton>
</SelectableListItem>
<SelectableListItem
itemId="Sort"
onEnter={() => onContentChange('recordGroupSort')}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Sort'}
onClick={() => onContentChange('recordGroupSort')}
startIcon={<IconArrowsSort />}
description={recordIndexRecordGroupSort}
descriptionPlacement="end"
hasSubmenu
- >{t`Sort`}</ListItem>
+ >{t`Sort`}</ListItemButton>
</SelectableListItem>
</>
)}
@@ -185,7 +185,7 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {
canPersistChanges && onContentChange('recordGroupLoadLimit')
}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'LoadLimit'}
disabled={!canPersistChanges}
onClick={() => onContentChange('recordGroupLoadLimit')}
@@ -193,7 +193,7 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {
description={String(recordIndexGroupLoadLimit)}
descriptionPlacement="end"
hasSubmenu
- >{t`Load limit`}</ListItem>
+ >{t`Load limit`}</ListItemButton>
</SelectableListItem>
)}
<SelectableListItem
@@ -229,10 +229,10 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {
<>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
onClick={() => onContentChange('addRecordGroup')}
startIcon={<IconPlus />}
- >{t`New group`}</ListItem>
+ >{t`New group`}</ListItemButton>
</DropdownMenuItemsContainer>
</>
)}
@@ -249,12 +249,11 @@ export const ObjectOptionsDropdownRecordGroupsContent = () => {
itemId="HiddenGroups"
onEnter={() => onContentChange('hiddenRecordGroups')}
>
- <ListItem
+ <ListItemButton
onClick={() => onContentChange('hiddenRecordGroups')}
startIcon={<IconEyeOff />}
- render={<button type="button" />}
hasSubmenu
- >{`${t`Hidden`} ${recordIndexGroupFieldMetadataItem?.label ?? ''}`}</ListItem>
+ >{`${t`Hidden`} ${recordIndexGroupFieldMetadataItem?.label ?? ''}`}</ListItemButton>
</SelectableListItem>
</SelectableList>
</DropdownMenuItemsContainer>
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownVisibilityContent.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownVisibilityContent.tsx
index 755c01d35b5..92f14261603 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownVisibilityContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/ObjectOptionsDropdownVisibilityContent.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useObjectOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsDropdown';
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
import { LegacyDropdownContent } from '@/ui/layout/dropdown/components/LegacyDropdownContent';
@@ -101,7 +101,7 @@ export const ObjectOptionsDropdownVisibilityContent = () => {
disabled={!!hasViewsPermission}
>
<div id="workspace-visibility-option">
- <ListItem
+ <ListItemButton
focused={selectedItemId === ViewVisibility.WORKSPACE}
onClick={() =>
handleVisibilityChange(ViewVisibility.WORKSPACE)
@@ -113,7 +113,7 @@ export const ObjectOptionsDropdownVisibilityContent = () => {
indicator="check"
description={t`Everyone`}
startIcon={<IconCircle />}
- >{t`Workspace`}</ListItem>
+ >{t`Workspace`}</ListItemButton>
</div>
</Tooltip>
</SelectableListItem>
@@ -124,7 +124,7 @@ export const ObjectOptionsDropdownVisibilityContent = () => {
handleVisibilityChange(ViewVisibility.UNLISTED)
}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === ViewVisibility.UNLISTED}
onClick={() => handleVisibilityChange(ViewVisibility.UNLISTED)}
disabled={!canPersistChanges}
@@ -134,7 +134,7 @@ export const ObjectOptionsDropdownVisibilityContent = () => {
indicator="check"
description={t`Visible to you`}
startIcon={<IconCircleDashed />}
- >{t`Unlisted`}</ListItem>
+ >{t`Unlisted`}</ListItemButton>
</SelectableListItem>
{currentVisibility === ViewVisibility.WORKSPACE && (
<>
@@ -143,11 +143,11 @@ export const ObjectOptionsDropdownVisibilityContent = () => {
itemId="Copy view link"
onEnter={handleCopyLink}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'Copy view link'}
onClick={handleCopyLink}
startIcon={<IconCopy />}
- >{t`Copy view link`}</ListItem>
+ >{t`Copy view link`}</ListItemButton>
</SelectableListItem>
</>
)}
diff --git a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/__tests__/ObjectOptionsDropdownCalendarViewContent.test.tsx b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/__tests__/ObjectOptionsDropdownCalendarViewContent.test.tsx
index 53cec86faf9..8541793aad1 100644
--- a/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/__tests__/ObjectOptionsDropdownCalendarViewContent.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/object-options-dropdown/components/__tests__/ObjectOptionsDropdownCalendarViewContent.test.tsx
@@ -93,8 +93,8 @@ jest.mock('@/views/hooks/useUpdateCurrentView', () => ({
jest.mock('twenty-ui/primitives/data-display', () => ({
Pill: ({ label }: { label: string }) => <span>{label}</span>,
}));
-jest.mock('twenty-ui/primitives/navigation', () => ({
- ListItem: ({
+jest.mock('twenty-ui/components/navigation', () => ({
+ ListItemButton: ({
description,
disabled,
onClick,
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/__stories__/FormWorkspaceMemberFilterValueInput.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/__stories__/FormWorkspaceMemberFilterValueInput.stories.tsx
index f194666d415..9d9d4d52b1f 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/__stories__/FormWorkspaceMemberFilterValueInput.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/__stories__/FormWorkspaceMemberFilterValueInput.stories.tsx
@@ -63,9 +63,7 @@ export const SelectMeAndResetSearch: Story = {
});
const dropdown = within(dialog);
const me = await dropdown.findByRole('button', { name: 'Me' });
- await waitFor(() =>
- expect(me).not.toHaveAttribute('aria-disabled', 'true'),
- );
+ await waitFor(() => expect(me).not.toBeDisabled());
await userEvent.click(me);
await waitFor(() => expect(me).toHaveAttribute('aria-pressed', 'true'));
expect(args.onChange).toHaveBeenCalledWith(
@@ -150,7 +148,7 @@ export const LoadingPreventsSelection: Story = {
);
expect(await dropdown.findByText('Loading...')).toBeVisible();
const me = dropdown.getByRole('button', { name: 'Me' });
- expect(me).toHaveAttribute('aria-disabled', 'true');
+ expect(me).toBeDisabled();
await userEvent.click(me);
expect(args.onChange).not.toHaveBeenCalled();
await userEvent.keyboard('{Escape}');
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/MultiItemFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/MultiItemFieldInput.tsx
index 5144be9cd73..4d238b79eaf 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/MultiItemFieldInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/MultiItemFieldInput.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { MultiItemBaseInput } from '@/object-record/record-field/ui/meta-types/input/components/MultiItemBaseInput';
import { type MultiItemBaseInputProps } from '@/object-record/record-field/ui/meta-types/input/types/MultiItemBaseInputProps';
import { computeUpdatedMultiItemFieldItems } from '@/object-record/record-field/ui/meta-types/input/utils/computeUpdatedMultiItemFieldItems';
@@ -22,7 +23,6 @@ import { CustomError, isDefined, isNonEmptyArray } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components/input';
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
import { IconCheck, IconPlus } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
import { themeCssVariables } from 'twenty-ui/theme';
import { useDebounce } from 'use-debounce';
import { FieldMetadataType } from '~/generated-metadata/graphql';
@@ -375,11 +375,14 @@ export const MultiItemFieldInput = <T,>({
/>
) : !isLimitReached ? (
<StyledAddItemContainer>
- <ListItem onClick={handleAddButtonClick} startIcon={<IconPlus />}>
+ <ListItemButton
+ onClick={handleAddButtonClick}
+ startIcon={<IconPlus />}
+ >
<OverflowingTextWithTooltip
text={newItemLabel || `Add ${placeholder}`}
/>
- </ListItem>
+ </ListItemButton>
</StyledAddItemContainer>
) : null}
</>
diff --git a/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPicker.tsx b/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPicker.tsx
index d5af67e4741..fdfb08c57c8 100644
--- a/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPicker.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPicker.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useCallback, useRef, useState } from 'react';
import { useStore } from 'jotai';
@@ -224,12 +224,12 @@ export const MultipleRecordPicker = ({
const createNewButtonSection =
creatableObjectMetadataItems.length > 0 ? (
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
onClick={handleCreateNewButtonClick}
disabled={isCreatePending}
startIcon={<IconPlus />}
hasSubmenu={creatableObjectMetadataItems.length > 1}
- >{t`Add New`}</ListItem>
+ >{t`Add New`}</ListItemButton>
</DropdownMenuItemsContainer>
) : null;
diff --git a/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPickerCreateTargetSelect.tsx b/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPickerCreateTargetSelect.tsx
index 2cb7258105a..1582e8e7d6f 100644
--- a/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPickerCreateTargetSelect.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPickerCreateTargetSelect.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ObjectMetadataIcon } from '@/object-metadata/components/ObjectMetadataIcon';
import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader/DropdownMenuHeader';
@@ -66,7 +66,7 @@ export const MultipleRecordPickerCreateTargetSelect = ({
itemId={objectMetadataItem.id}
onEnter={() => handleSelect(objectMetadataItem.id)}
>
- <ListItem
+ <ListItemButton
startIcon={
<ObjectMetadataIcon objectMetadataItem={objectMetadataItem} />
}
@@ -75,7 +75,7 @@ export const MultipleRecordPickerCreateTargetSelect = ({
onClick={() => handleSelect(objectMetadataItem.id)}
>
{objectMetadataItem.labelSingular}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPickerMenuItemContent.tsx b/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPickerMenuItemContent.tsx
index 840c071abb5..8a7d2d9e726 100644
--- a/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPickerMenuItemContent.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-picker/multiple-record-picker/components/MultipleRecordPickerMenuItemContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
import { getAvatarShape } from '@/object-metadata/utils/getAvatarShape';
import { MultipleRecordPickerComponentInstanceContext } from '@/object-record/record-picker/multiple-record-picker/states/contexts/MultipleRecordPickerComponentInstanceContext';
@@ -6,6 +7,7 @@ import { multipleRecordPickerIsSelectedComponentFamilySelector } from '@/object-
import { getMultipleRecordPickerSelectableListId } from '@/object-record/record-picker/multiple-record-picker/utils/getMultipleRecordPickerSelectableListId';
import { type RecordPickerPickableMorphItem } from '@/object-record/record-picker/types/RecordPickerPickableMorphItem';
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
+import { useSelectableListNativeItemRef } from '@/ui/layout/selectable-list/hooks/useSelectableListNativeItemRef';
import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilySelectorValue';
@@ -14,7 +16,6 @@ import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/use
import { t } from '@lingui/core/macro';
import { capitalize } from 'twenty-shared/utils';
import { Avatar } from 'twenty-ui/primitives/data-display';
-import { ListItem } from 'twenty-ui/primitives/navigation';
import { type SearchRecord } from '~/generated/graphql';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
@@ -29,6 +30,8 @@ export const MultipleRecordPickerMenuItemContent = ({
objectMetadataItem,
onChange,
}: MultipleRecordPickerMenuItemContentProps) => {
+ const nativeItemRef = useSelectableListNativeItemRef(searchRecord.recordId);
+
const componentInstanceId = useAvailableComponentInstanceIdOrThrow(
MultipleRecordPickerComponentInstanceContext,
);
@@ -76,7 +79,8 @@ export const MultipleRecordPickerMenuItemContent = ({
key={searchRecord.recordId}
onEnter={() => handleSelectChange(!isRecordSelectedWithObjectItem)}
>
- <ListItem
+ <ListItemButton
+ ref={nativeItemRef}
focused={isSelectedItemId}
role="option"
aria-selected={isRecordSelectedWithObjectItem}
@@ -99,7 +103,7 @@ export const MultipleRecordPickerMenuItemContent = ({
}
>
{displayText}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItem.tsx b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItem.tsx
index 9fa70dda9fe..46a8eb2b3a0 100644
--- a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItem.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItem.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
import { getAvatarShape } from '@/object-metadata/utils/getAvatarShape';
import { searchRecordStoreFamilyState } from '@/object-record/record-picker/multiple-record-picker/states/searchRecordStoreComponentFamilyState';
@@ -14,7 +15,6 @@ import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAto
import { useMemo } from 'react';
import { capitalize, isDefined } from 'twenty-shared/utils';
import { Avatar } from 'twenty-ui/primitives/data-display';
-import { ListItem } from 'twenty-ui/primitives/navigation';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
type SingleRecordPickerMenuItemProps = {
@@ -80,7 +80,7 @@ export const SingleRecordPickerMenuItem = ({
onMorphItemSelected(morphItem);
}}
>
- <ListItem
+ <ListItemButton
onClick={() => onMorphItemSelected(morphItem)}
focused={isSelectedItemId}
role="option"
@@ -104,7 +104,7 @@ export const SingleRecordPickerMenuItem = ({
}
>
{searchRecordStore.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItems.tsx b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItems.tsx
index 467512bf3c5..fb0184e5e8d 100644
--- a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItems.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItems.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { isDefined } from 'twenty-shared/utils';
import { isUndefined } from '@sniptt/guards';
@@ -24,7 +25,6 @@ import { useAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useAtomC
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
import { type IconComponent } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
export type SingleRecordPickerMenuItemsProps = {
EmptyIcon?: IconComponent;
@@ -109,7 +109,7 @@ export const SingleRecordPickerMenuItems = ({
onMorphItemSelected();
}}
>
- <ListItem
+ <ListItemButton
onClick={() => {
setSingleRecordPickerSelectedId(undefined);
onMorphItemSelected();
@@ -122,7 +122,7 @@ export const SingleRecordPickerMenuItems = ({
startIcon={<SelectOptionIcon Icon={EmptyIcon} />}
>
{emptyLabel}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
)}
{singleRecordPickerShouldShowInitialLoading ? (
diff --git a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItemsWithSearch.tsx b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItemsWithSearch.tsx
index 93a32d9b293..5fd55067d20 100644
--- a/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItemsWithSearch.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-picker/single-record-picker/components/SingleRecordPickerMenuItemsWithSearch.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { type SingleRecordPickerMenuItemsWithSearchProps } from '@/object-record/record-picker/single-record-picker/types/SingleRecordPickerMenuItemsWithSearchProps';
import { ToastOnQueryErrorEffect } from '@/apollo/components/ToastOnQueryErrorEffect';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
@@ -90,10 +90,10 @@ export const SingleRecordPickerMenuItemsWithSearch = ({
{isDefined(onCreate) && canCreateRecords && (
<>
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
onClick={handleCreateNew}
startIcon={<IconPlus />}
- >{t`Add New`}</ListItem>
+ >{t`Add New`}</ListItemButton>
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
</>
@@ -138,10 +138,10 @@ export const SingleRecordPickerMenuItemsWithSearch = ({
<>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
onClick={handleCreateNew}
startIcon={<IconPlus />}
- >{t`Add New`}</ListItem>
+ >{t`Add New`}</ListItemButton>
</DropdownMenuItemsContainer>
</>
)}
diff --git a/packages/twenty-front/src/modules/object-record/select/components/MultipleSelectDropdown.tsx b/packages/twenty-front/src/modules/object-record/select/components/MultipleSelectDropdown.tsx
index fe7118c2e9a..aa3d11039cf 100644
--- a/packages/twenty-front/src/modules/object-record/select/components/MultipleSelectDropdown.tsx
+++ b/packages/twenty-front/src/modules/object-record/select/components/MultipleSelectDropdown.tsx
@@ -6,14 +6,12 @@ import { DropdownMenuSkeletonItem } from '@/ui/input/relation-picker/components/
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList';
-import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
+import { MultipleSelectDropdownItem } from '@/object-record/select/components/MultipleSelectDropdownItem';
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState';
import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
-import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
import { t } from '@lingui/core/macro';
-import { Avatar } from 'twenty-ui/primitives/data-display';
export const MultipleSelectDropdown = ({
selectableListId,
@@ -45,10 +43,9 @@ export const MultipleSelectDropdown = ({
selectableListId,
);
- const handleItemSelectChange = (
- itemToSelect: SelectableItem,
- newSelectedValue: boolean,
- ) => {
+ const handleItemSelectChange = (itemToSelect: SelectableItem) => {
+ const newSelectedValue = !itemToSelect.isSelected;
+ resetSelectedItem();
onChange(
{
...itemToSelect,
@@ -88,41 +85,14 @@ export const MultipleSelectDropdown = ({
focusId={focusId}
>
<DropdownMenuItemsContainer isMultiSelect hasMaxHeight>
- {itemsInDropdown?.map((item) => {
- return (
- <SelectableListItem
- itemId={item.id}
- onEnter={() => {
- resetSelectedItem();
- handleItemSelectChange(item, !item.isSelected);
- }}
- >
- <ListItem
- key={item.id}
- focused={item.id === selectedItemId}
- role="option"
- aria-selected={item.isSelected}
- selected={item.isSelected}
- indicator="checkbox"
- onClick={() => {
- resetSelectedItem();
- handleItemSelectChange(item, !item.isSelected);
- }}
- startIcon={
- <Avatar
- src={getAbsoluteImageUrl(item.avatarUrl)}
- colorSeed={item.id}
- name={item.name}
- size="md"
- shape={item.avatarShape}
- />
- }
- >
- {item.name}
- </ListItem>
- </SelectableListItem>
- );
- })}
+ {itemsInDropdown.map((item) => (
+ <MultipleSelectDropdownItem
+ key={item.id}
+ item={item}
+ focused={item.id === selectedItemId}
+ onSelect={handleItemSelectChange}
+ />
+ ))}
{showNoResult && <ListItem disabled>{t`No results`}</ListItem>}
{loadingItems && <DropdownMenuSkeletonItem />}
</DropdownMenuItemsContainer>
diff --git a/packages/twenty-front/src/modules/object-record/select/components/MultipleSelectDropdownItem.tsx b/packages/twenty-front/src/modules/object-record/select/components/MultipleSelectDropdownItem.tsx
new file mode 100644
index 00000000000..8422e864d39
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/select/components/MultipleSelectDropdownItem.tsx
@@ -0,0 +1,47 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { Avatar } from 'twenty-ui/primitives/data-display';
+
+import { type SelectableItem } from '@/object-record/select/types/SelectableItem';
+import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
+import { useSelectableListNativeItemRef } from '@/ui/layout/selectable-list/hooks/useSelectableListNativeItemRef';
+import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
+
+type MultipleSelectDropdownItemProps = {
+ item: SelectableItem;
+ focused: boolean;
+ onSelect: (item: SelectableItem) => void;
+};
+
+export const MultipleSelectDropdownItem = ({
+ item,
+ focused,
+ onSelect,
+}: MultipleSelectDropdownItemProps) => {
+ const nativeItemRef = useSelectableListNativeItemRef(item.id);
+ const handleSelect = () => onSelect(item);
+
+ return (
+ <SelectableListItem itemId={item.id} onEnter={handleSelect}>
+ <ListItemButton
+ ref={nativeItemRef}
+ focused={focused}
+ role="option"
+ aria-selected={item.isSelected}
+ selected={item.isSelected}
+ indicator="checkbox"
+ onClick={handleSelect}
+ startIcon={
+ <Avatar
+ src={getAbsoluteImageUrl(item.avatarUrl)}
+ colorSeed={item.id}
+ name={item.name}
+ size="md"
+ shape={item.avatarShape}
+ />
+ }
+ >
+ {item.name}
+ </ListItemButton>
+ </SelectableListItem>
+ );
+};
diff --git a/packages/twenty-front/src/modules/object-record/select/components/__tests__/MultipleSelectDropdown.test.tsx b/packages/twenty-front/src/modules/object-record/select/components/__tests__/MultipleSelectDropdown.test.tsx
new file mode 100644
index 00000000000..6de3f748a36
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/select/components/__tests__/MultipleSelectDropdown.test.tsx
@@ -0,0 +1,100 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { createStore, Provider } from 'jotai';
+
+import { MultipleSelectDropdown } from '@/object-record/select/components/MultipleSelectDropdown';
+import { focusStackState } from '@/ui/utilities/focus/states/focusStackState';
+import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';
+
+const FOCUS_ID = 'multiple-select-keyboard-test';
+
+const ITEMS = [
+ { id: 'alpha', name: 'Alpha', isSelected: false },
+ { id: 'beta', name: 'Beta', isSelected: false },
+];
+
+const renderDropdown = () => {
+ const store = createStore();
+ store.set(focusStackState.atom, [
+ {
+ focusId: FOCUS_ID,
+ componentInstance: {
+ componentType: FocusComponentType.DROPDOWN,
+ componentInstanceId: FOCUS_ID,
+ },
+ globalHotkeysConfig: {
+ enableGlobalHotkeysWithModifiers: true,
+ enableGlobalHotkeysConflictingWithKeyboard: true,
+ },
+ },
+ ]);
+ const onChange = jest.fn();
+
+ render(
+ <Provider store={store}>
+ <input aria-label="Search" autoFocus />
+ <MultipleSelectDropdown
+ selectableListId={FOCUS_ID}
+ focusId={FOCUS_ID}
+ itemsToSelect={ITEMS}
+ filteredSelectedItems={[]}
+ selectedItems={[]}
+ searchFilter=""
+ loadingItems={false}
+ onChange={onChange}
+ />
+ </Provider>,
+ );
+
+ return { onChange, user: userEvent.setup() };
+};
+
+describe('MultipleSelectDropdown keyboard navigation', () => {
+ it('activates the next item after pointer selection and arrow navigation', async () => {
+ const { user, onChange } = renderDropdown();
+
+ await user.click(screen.getByRole('option', { name: 'Alpha' }));
+ onChange.mockClear();
+ await user.keyboard('{ArrowDown}');
+ expect(screen.getByRole('option', { name: 'Beta' })).toHaveAttribute(
+ 'data-highlighted',
+ );
+ expect(screen.getByRole('option', { name: 'Beta' })).toHaveFocus();
+ await user.keyboard('{Enter}');
+
+ expect(onChange).toHaveBeenCalledTimes(1);
+ expect(onChange).toHaveBeenLastCalledWith(
+ { ...ITEMS[1], isSelected: true },
+ true,
+ );
+ expect(screen.getByRole('option', { name: 'Beta' })).toHaveFocus();
+ });
+
+ it('focuses the highlighted item when arrow navigation reaches a boundary', async () => {
+ const { user, onChange } = renderDropdown();
+
+ await user.click(screen.getByRole('option', { name: 'Beta' }));
+ onChange.mockClear();
+ await user.keyboard('{ArrowUp}{Enter}');
+
+ expect(onChange).toHaveBeenCalledTimes(1);
+ expect(onChange).toHaveBeenLastCalledWith(
+ { ...ITEMS[0], isSelected: true },
+ true,
+ );
+ expect(screen.getByRole('option', { name: 'Alpha' })).toHaveFocus();
+ });
+
+ it('keeps search focus while activating the highlighted item with Enter', async () => {
+ const { user, onChange } = renderDropdown();
+
+ await user.keyboard('{ArrowDown}{Enter}');
+
+ expect(onChange).toHaveBeenCalledTimes(1);
+ expect(onChange).toHaveBeenLastCalledWith(
+ { ...ITEMS[1], isSelected: true },
+ true,
+ );
+ expect(screen.getByRole('textbox', { name: 'Search' })).toHaveFocus();
+ });
+});
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/__stories__/SettingsAdminServerAdminAccess.stories.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/__stories__/SettingsAdminServerAdminAccess.stories.tsx
index d6e7d7a6414..59e5b4c1a02 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/__stories__/SettingsAdminServerAdminAccess.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/__stories__/SettingsAdminServerAdminAccess.stories.tsx
@@ -56,7 +56,7 @@ export const LastAdministratorProtection: Story = {
name: 'Revoke admin panel access',
});
- await expect(revokeAdminAccess).toHaveAttribute('aria-disabled', 'true');
+ await expect(revokeAdminAccess).toBeDisabled();
await userEvent.click(revokeAdminAccess);
await expect(canvas.queryByRole('dialog')).not.toBeInTheDocument();
await expect(canvas.getByRole('menu')).toBeVisible();
diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/address/components/__tests__/MultiSelectAddressFields.test.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/address/components/__tests__/MultiSelectAddressFields.test.tsx
index 928b1c25e29..b571f3d878e 100644
--- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/address/components/__tests__/MultiSelectAddressFields.test.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/address/components/__tests__/MultiSelectAddressFields.test.tsx
@@ -68,7 +68,7 @@ describe('MultiSelectAddressFields', () => {
await user.click(trigger);
expect(
screen.getByRole('button', { name: 'Reset to default' }),
- ).toHaveAttribute('aria-disabled', 'true');
+ ).toBeDisabled();
});
it('filters results, selects with the keyboard, and clears search after closing', async () => {
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartAggregateOperationSelectableListItem.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartAggregateOperationSelectableListItem.tsx
index 1412b216f07..9afd3cf4396 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartAggregateOperationSelectableListItem.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartAggregateOperationSelectableListItem.tsx
@@ -13,7 +13,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { isDefined } from 'twenty-shared/utils';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
const isExtendedAggregateOperation = (
operation: AggregateChartOperation,
@@ -81,7 +81,7 @@ export const ChartAggregateOperationSelectableListItem = ({
return (
<SelectableListItem itemId={operation} onEnter={handleClick}>
- <ListItem
+ <ListItemButton
focused={isFocused}
onClick={handleClick}
role="option"
@@ -90,7 +90,7 @@ export const ChartAggregateOperationSelectableListItem = ({
indicator="check"
>
{label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartAxisNameSelectionDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartAxisNameSelectionDropdownContent.tsx
index 0c29b994b3a..d4c9fbf2938 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartAxisNameSelectionDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartAxisNameSelectionDropdownContent.tsx
@@ -11,7 +11,7 @@ import { SelectableListItem } from '@/ui/layout/selectable-list/components/Selec
import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { AxisNameDisplay } from '~/generated-metadata/graphql';
export const ChartAxisNameSelectionDropdownContent = () => {
@@ -76,7 +76,7 @@ export const ChartAxisNameSelectionDropdownContent = () => {
handleSelectAxisNameOption(option);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === option}
onClick={() => {
handleSelectAxisNameOption(option);
@@ -87,7 +87,7 @@ export const ChartAxisNameSelectionDropdownContent = () => {
indicator="check"
>
{getChartAxisNameDisplayOptions(option)}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartColorGradientOption.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartColorGradientOption.tsx
index 71e6e72eec7..dd31c8231fc 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartColorGradientOption.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartColorGradientOption.tsx
@@ -4,7 +4,7 @@ import { generateGroupColor } from '@/page-layout/widgets/graph/utils/generateGr
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
import { styled } from '@linaria/react';
import { ColorSample } from 'twenty-ui/primitives/data-display';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useTheme, themeCssVariables, type ThemeColor } from 'twenty-ui/theme';
type ChartColorGradientOptionProps = {
@@ -63,7 +63,7 @@ export const ChartColorGradientOption = ({
onSelectColor(colorOption.colorName);
}}
>
- <ListItem
+ <ListItemButton
focused={
selectedItemId === colorOption.id || currentColor === colorOption.id
}
@@ -78,7 +78,7 @@ export const ChartColorGradientOption = ({
descriptionPlacement={'end'}
>
{colorOption.name}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartColorPaletteOption.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartColorPaletteOption.tsx
index d0babc3b6a2..7d8fad3d5f8 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartColorPaletteOption.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartColorPaletteOption.tsx
@@ -5,7 +5,7 @@ import { SelectableListItem } from '@/ui/layout/selectable-list/components/Selec
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { ColorSample } from 'twenty-ui/primitives/data-display';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { getMainColorNameFromPaletteColorName } from 'twenty-ui/utilities';
import { useTheme, themeCssVariables, type ThemeColor } from 'twenty-ui/theme';
@@ -63,7 +63,7 @@ export const ChartColorPaletteOption = ({
onSelectColor('auto');
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'auto' || currentColor === 'auto'}
onClick={() => {
onSelectColor('auto');
@@ -74,7 +74,7 @@ export const ChartColorPaletteOption = ({
indicator="check"
description={colorSamples}
descriptionPlacement={'end'}
- >{t`Default palette`}</ListItem>
+ >{t`Default palette`}</ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartDataSourceDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartDataSourceDropdownContent.tsx
index 0faff142d3f..5cf14a05704 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartDataSourceDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartDataSourceDropdownContent.tsx
@@ -23,7 +23,7 @@ import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/use
import { t } from '@lingui/core/macro';
import { useMemo, useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { filterBySearchQuery } from '~/utils/filterBySearchQuery';
export const ChartDataSourceDropdownContent = () => {
@@ -130,7 +130,7 @@ export const ChartDataSourceDropdownContent = () => {
handleSelectSource(objectMetadataItem.id);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === objectMetadataItem.id}
onClick={() => {
handleSelectSource(objectMetadataItem.id);
@@ -152,7 +152,7 @@ export const ChartDataSourceDropdownContent = () => {
}
>
{objectMetadataItem.labelPlural}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartDateGranularitySelectionDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartDateGranularitySelectionDropdownContent.tsx
index e6ca818ace7..221e8aad809 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartDateGranularitySelectionDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartDateGranularitySelectionDropdownContent.tsx
@@ -15,7 +15,7 @@ import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/com
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { ObjectRecordGroupByDateGranularity } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import {
type FieldsConfiguration,
type WidgetConfiguration,
@@ -160,7 +160,7 @@ export const ChartDateGranularitySelectionDropdownContent = ({
handleSelectDateGranularityOption(option);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === option}
onClick={() => {
handleSelectDateGranularityOption(option);
@@ -171,7 +171,7 @@ export const ChartDateGranularitySelectionDropdownContent = ({
indicator="check"
>
{getDateGranularityLabel(option)}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartFieldSelectionForAggregateOperationDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartFieldSelectionForAggregateOperationDropdownContent.tsx
index 1940a74faae..afe929b22ea 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartFieldSelectionForAggregateOperationDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartFieldSelectionForAggregateOperationDropdownContent.tsx
@@ -18,7 +18,7 @@ import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/use
import { t } from '@lingui/core/macro';
import { useState } from 'react';
import { useIcons } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { filterBySearchQuery } from '~/utils/filterBySearchQuery';
export const ChartFieldSelectionForAggregateOperationDropdownContent = () => {
@@ -111,7 +111,7 @@ export const ChartFieldSelectionForAggregateOperationDropdownContent = () => {
setSelectedFieldMetadataId(fieldMetadataItem.id);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === fieldMetadataItem.id}
onClick={() => {
setIsSubMenuOpen(true);
@@ -127,7 +127,7 @@ export const ChartFieldSelectionForAggregateOperationDropdownContent = () => {
}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionCompositeFieldView.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionCompositeFieldView.tsx
index 5d936afa5aa..8d15f73507e 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionCompositeFieldView.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionCompositeFieldView.tsx
@@ -14,7 +14,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { IconChevronLeft, useIcons } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { compositeTypeDefinitions } from 'twenty-shared/types';
import { isCompositePropertySupportedInGroupBy } from 'twenty-shared/utils';
@@ -83,7 +83,7 @@ export const ChartGroupByFieldSelectionCompositeFieldView = ({
onSelectSubField(subFieldName);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === subFieldName}
onClick={() => {
onSelectSubField(subFieldName);
@@ -102,7 +102,7 @@ export const ChartGroupByFieldSelectionCompositeFieldView = ({
}
>
{getCompositeSubFieldLabel(compositeFieldType, subFieldName)}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionDropdownContentBase.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionDropdownContentBase.tsx
index 3fbd25c87e6..04697af5e26 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionDropdownContentBase.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionDropdownContentBase.tsx
@@ -30,7 +30,7 @@ import {
isFieldMetadataSupportedInGroupBy,
} from 'twenty-shared/utils';
import { useIcons } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { RelationType } from '~/generated-metadata/graphql';
import { filterBySearchQuery } from '~/utils/filterBySearchQuery';
@@ -342,14 +342,14 @@ export const ChartGroupByFieldSelectionDropdownContentBase = <
>
{isSecondaryAxisGroupBy && (
<SelectableListItem itemId="none" onEnter={handleSelectNone}>
- <ListItem
+ <ListItemButton
focused={selectedItemId === 'none'}
onClick={handleSelectNone}
role="option"
aria-selected={!isDefined(currentGroupByFieldMetadataId)}
selected={!isDefined(currentGroupByFieldMetadataId)}
indicator="check"
- >{t`None`}</ListItem>
+ >{t`None`}</ListItemButton>
</SelectableListItem>
)}
@@ -361,7 +361,7 @@ export const ChartGroupByFieldSelectionDropdownContentBase = <
handleSelectField(fieldMetadataItem);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === fieldMetadataItem.id}
onClick={() => {
handleSelectField(fieldMetadataItem);
@@ -390,7 +390,7 @@ export const ChartGroupByFieldSelectionDropdownContentBase = <
}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionMorphRelationFieldView.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionMorphRelationFieldView.tsx
index 1980117792e..e2b1f0481db 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionMorphRelationFieldView.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionMorphRelationFieldView.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
@@ -146,7 +147,7 @@ export const ChartGroupByFieldSelectionMorphRelationFieldView = ({
setSelectedTarget(target);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === target.perTargetFieldId}
startIcon={
<SelectOptionIcon
@@ -163,7 +164,7 @@ export const ChartGroupByFieldSelectionMorphRelationFieldView = ({
}}
>
{target.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionTargetObjectFieldsView.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionTargetObjectFieldsView.tsx
index 1c967b3d5e3..f62daa6908a 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionTargetObjectFieldsView.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartGroupByFieldSelectionTargetObjectFieldsView.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
@@ -157,7 +158,7 @@ export const ChartGroupByFieldSelectionTargetObjectFieldsView = ({
itemId={RECORD_ITEM_ID}
onEnter={onSelectRecord}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === RECORD_ITEM_ID}
onClick={onSelectRecord}
role="option"
@@ -175,7 +176,7 @@ export const ChartGroupByFieldSelectionTargetObjectFieldsView = ({
}
>
{recordOptionLabel}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
)}
{availableFields.length === 0 && !isRecordOptionVisible ? (
@@ -189,7 +190,7 @@ export const ChartGroupByFieldSelectionTargetObjectFieldsView = ({
handleSelectField(fieldMetadataItem);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === fieldMetadataItem.id}
onClick={() => {
handleSelectField(fieldMetadataItem);
@@ -210,7 +211,7 @@ export const ChartGroupByFieldSelectionTargetObjectFieldsView = ({
}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))
)}
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartNumberFormatSelectionDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartNumberFormatSelectionDropdownContent.tsx
index f49f99de413..027dd907eea 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartNumberFormatSelectionDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartNumberFormatSelectionDropdownContent.tsx
@@ -12,7 +12,7 @@ import { SelectableListItem } from '@/ui/layout/selectable-list/components/Selec
import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ChartNumberFormat } from '~/generated-metadata/graphql';
export const ChartNumberFormatSelectionDropdownContent = () => {
@@ -82,7 +82,7 @@ export const ChartNumberFormatSelectionDropdownContent = () => {
handleSelectNumberFormatOption(option);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === option}
onClick={() => {
handleSelectNumberFormatOption(option);
@@ -93,7 +93,7 @@ export const ChartNumberFormatSelectionDropdownContent = () => {
indicator="check"
>
{getChartNumberFormatLabel(option)}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioAggregateOperationSelectableListItem.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioAggregateOperationSelectableListItem.tsx
index aba775d807b..e32584bdb8d 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioAggregateOperationSelectableListItem.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioAggregateOperationSelectableListItem.tsx
@@ -8,7 +8,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { isDefined } from 'twenty-shared/utils';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
export const ChartRatioAggregateOperationSelectableListItem = ({
label,
@@ -42,7 +42,7 @@ export const ChartRatioAggregateOperationSelectableListItem = ({
itemId={DASHBOARD_AGGREGATE_OPERATION_RATIO}
onEnter={onSelect}
>
- <ListItem
+ <ListItemButton
focused={isFocused}
onClick={onSelect}
role="option"
@@ -52,7 +52,7 @@ export const ChartRatioAggregateOperationSelectableListItem = ({
hasSubmenu={true}
>
{label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioOptionBooleanSelectableListItem.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioOptionBooleanSelectableListItem.tsx
index e5552e5c4ed..913b9b946ce 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioOptionBooleanSelectableListItem.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioOptionBooleanSelectableListItem.tsx
@@ -10,7 +10,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { IconCheck, IconX } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { AggregateOperations } from '~/generated-metadata/graphql';
export const ChartRatioOptionBooleanSelectableListItem = ({
@@ -63,7 +63,7 @@ export const ChartRatioOptionBooleanSelectableListItem = ({
return (
<SelectableListItem itemId={optionValue} onEnter={handleClick}>
- <ListItem
+ <ListItemButton
focused={isFocused}
onClick={handleClick}
role="option"
@@ -75,7 +75,7 @@ export const ChartRatioOptionBooleanSelectableListItem = ({
}
>
{label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioOptionSelectSelectableListItem.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioOptionSelectSelectableListItem.tsx
index d48dbfc2855..5fb06ef89eb 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioOptionSelectSelectableListItem.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartRatioOptionSelectSelectableListItem.tsx
@@ -9,7 +9,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { Tag } from 'twenty-ui/primitives/data-display';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { type ThemeColor } from 'twenty-ui/theme';
import { AggregateOperations } from '~/generated-metadata/graphql';
@@ -65,7 +65,7 @@ export const ChartRatioOptionSelectSelectableListItem = ({
return (
<SelectableListItem itemId={optionValue} onEnter={handleClick}>
- <ListItem
+ <ListItemButton
focused={isFocused}
onClick={handleClick}
role="option"
@@ -80,7 +80,7 @@ export const ChartRatioOptionSelectSelectableListItem = ({
>
{label}
</Tag>
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartSortByGroupByFieldDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartSortByGroupByFieldDropdownContent.tsx
index 6a9cb93d2a2..5019fac34c0 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartSortByGroupByFieldDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartSortByGroupByFieldDropdownContent.tsx
@@ -22,7 +22,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { isDefined } from 'twenty-shared/utils';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import {
GraphOrderBy,
type GraphOrderBy as GraphOrderByType,
@@ -137,7 +137,7 @@ export const ChartSortByGroupByFieldDropdownContent = () => {
handleSelectSortOption(sortOption.value);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === sortOption.value}
onClick={() => {
handleSelectSortOption(sortOption.value);
@@ -170,7 +170,7 @@ export const ChartSortByGroupByFieldDropdownContent = () => {
configuration.secondaryAxisGroupByFieldMetadataId ?? '',
})}
/>
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
})}
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartSortBySelectionDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartSortBySelectionDropdownContent.tsx
index 45512a8ae86..acb6bc925af 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartSortBySelectionDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartSortBySelectionDropdownContent.tsx
@@ -23,7 +23,7 @@ import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/com
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { type CompositeFieldSubFieldName } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import {
type BarChartConfiguration,
GraphOrderBy,
@@ -184,7 +184,7 @@ export const ChartSortBySelectionDropdownContent = () => {
handleSelect(sortOption.value);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === sortOption.value}
onClick={() => {
handleSelect(sortOption.value);
@@ -219,7 +219,7 @@ export const ChartSortBySelectionDropdownContent = () => {
configuration.aggregateOperation ?? undefined,
})}
/>
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
})}
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetFieldDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetFieldDropdownContent.tsx
index 73bd6839fbf..d9ba0377e78 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetFieldDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetFieldDropdownContent.tsx
@@ -35,7 +35,7 @@ import { t } from '@lingui/core/macro';
import { useMemo, useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { useIcons } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { FieldDisplayMode } from '~/generated-metadata/graphql';
import { filterBySearchQuery } from '~/utils/filterBySearchQuery';
@@ -325,7 +325,7 @@ export const FieldWidgetFieldDropdownContent = () => {
itemId={fieldMetadataItem.id}
onEnter={handleClick}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === fieldMetadataItem.id}
onClick={handleClick}
role="option"
@@ -350,7 +350,7 @@ export const FieldWidgetFieldDropdownContent = () => {
}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
})}
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetLayoutDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetLayoutDropdownContent.tsx
index e2cbe3c6ba1..c0c8c454292 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetLayoutDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetLayoutDropdownContent.tsx
@@ -40,7 +40,7 @@ import {
IconListDetails,
IconTable,
} from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { FieldDisplayMode } from '~/generated-metadata/graphql';
const DISPLAY_MODE_ICONS: Record<FieldDisplayMode, IconComponent> = {
@@ -256,7 +256,7 @@ export const FieldWidgetLayoutDropdownContent = () => {
handleSelectDisplayMode(displayMode);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === displayMode}
onClick={() => {
handleSelectDisplayMode(displayMode);
@@ -270,7 +270,7 @@ export const FieldWidgetLayoutDropdownContent = () => {
}
>
{displayModeLabels[displayMode]}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
{hasEmbeddedViewLayouts && (
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetNestedFieldDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetNestedFieldDropdownContent.tsx
index ad3684be562..a4859c2122a 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetNestedFieldDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/FieldWidgetNestedFieldDropdownContent.tsx
@@ -14,7 +14,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { IconChevronLeft, useIcons } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
type FieldWidgetNestedFieldDropdownContentProps = {
drillInFieldMetadataItem: FieldMetadataItem;
@@ -56,7 +56,7 @@ export const FieldWidgetNestedFieldDropdownContent = ({
itemId={fieldMetadataItem.id}
onEnter={onSelect}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === fieldMetadataItem.id}
onClick={onSelect}
role="option"
@@ -66,7 +66,7 @@ export const FieldWidgetNestedFieldDropdownContent = ({
startIcon={<SelectOptionIcon Icon={getIcon(fieldMetadataItem.icon)} />}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/MoveToTabDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/MoveToTabDropdownContent.tsx
index 6ba4648bf85..df1f10dcee4 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/MoveToTabDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/MoveToTabDropdownContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import { useMoveWidgetToTab } from '@/page-layout/hooks/useMoveWidgetToTab';
import { pageLayoutDraftComponentState } from '@/page-layout/states/pageLayoutDraftComponentState';
@@ -64,7 +65,7 @@ export const MoveToTabDropdownContent = () => {
return (
<DropdownMenuItemsContainer>
{eligibleTabs.map((tab) => (
- <ListItem
+ <ListItemButton
key={tab.id}
onClick={() => {
moveWidgetToTab(pageLayoutEditingWidgetId, tab.id);
@@ -72,7 +73,7 @@ export const MoveToTabDropdownContent = () => {
}}
>
{tab.title ?? ''}
- </ListItem>
+ </ListItemButton>
))}
</DropdownMenuItemsContainer>
);
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/WidgetVisibilityOptionsList.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/WidgetVisibilityOptionsList.tsx
index 2a6088d1cc4..7493b638448 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/WidgetVisibilityOptionsList.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/WidgetVisibilityOptionsList.tsx
@@ -7,7 +7,7 @@ import { SelectableListItem } from '@/ui/layout/selectable-list/components/Selec
import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
type WidgetVisibilityOptionsListProps = {
currentOptionId: string;
@@ -44,7 +44,7 @@ export const WidgetVisibilityOptionsList = ({
onSelectVisibility(option.id);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === option.id}
onClick={() => {
onSelectVisibility(option.id);
@@ -55,7 +55,7 @@ export const WidgetVisibilityOptionsList = ({
indicator="check"
>
{visibilityLabels[option.id]}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableCalendarFieldDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableCalendarFieldDropdownContent.tsx
index d3c7edcc718..4505b13a997 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableCalendarFieldDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableCalendarFieldDropdownContent.tsx
@@ -11,7 +11,7 @@ import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { useIcons } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
type RecordTableCalendarFieldDropdownContentProps = {
pageLayoutId: string;
@@ -72,7 +72,7 @@ export const RecordTableCalendarFieldDropdownContent = ({
closeDropdown();
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === fieldMetadataItem.id}
onClick={() => {
handleCalendarFieldChange(fieldMetadataItem);
@@ -89,7 +89,7 @@ export const RecordTableCalendarFieldDropdownContent = ({
}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableCalendarLayoutDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableCalendarLayoutDropdownContent.tsx
index d09ef5aa87f..361f556339c 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableCalendarLayoutDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableCalendarLayoutDropdownContent.tsx
@@ -14,7 +14,7 @@ import {
IconCalendarMonth,
IconCalendarWeek,
} from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ViewCalendarLayout } from '~/generated-metadata/graphql';
type RecordTableCalendarLayoutDropdownContentProps = {
@@ -72,7 +72,7 @@ export const RecordTableCalendarLayoutDropdownContent = ({
itemId={value}
onEnter={() => handleSelect(value)}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === value}
onClick={() => handleSelect(value)}
role="option"
@@ -82,7 +82,7 @@ export const RecordTableCalendarLayoutDropdownContent = ({
startIcon={<SelectOptionIcon Icon={Icon} />}
>
{label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableDataSourceDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableDataSourceDropdownContent.tsx
index 7b007576ce9..c382df03f97 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableDataSourceDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableDataSourceDropdownContent.tsx
@@ -22,7 +22,7 @@ import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/use
import { t } from '@lingui/core/macro';
import { useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { filterBySearchQuery } from '~/utils/filterBySearchQuery';
export const RecordTableDataSourceDropdownContent = () => {
@@ -139,7 +139,7 @@ export const RecordTableDataSourceDropdownContent = () => {
handleSelectSource(objectMetadataItem.id);
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === objectMetadataItem.id}
onClick={() => {
handleSelectSource(objectMetadataItem.id);
@@ -161,7 +161,7 @@ export const RecordTableDataSourceDropdownContent = () => {
}
>
{objectMetadataItem.labelPlural}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
index 5a752556cc4..bf95e7d809e 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
@@ -14,9 +14,11 @@ import { useAtomComponentSelectorValue } from '@/ui/utilities/state/jotai/hooks/
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
+import {
+ ListItemButton,
+ MenuItemDraggable,
+} from 'twenty-ui/components/navigation';
import { IconEyeOff, useIcons } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
import { sortByProperty } from '~/utils/array/sortByProperty';
type RecordTableFieldsDropdownVisibleFieldsContentProps = {
@@ -146,12 +148,11 @@ export const RecordTableFieldsDropdownVisibleFieldsContent = ({
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
onClick={onShowHiddenFields}
startIcon={<IconEyeOff />}
- render={<button type="button" />}
hasSubmenu
- >{t`Hidden Fields`}</ListItem>
+ >{t`Hidden Fields`}</ListItemButton>
</DropdownMenuItemsContainer>
</LegacyDropdownContent>
);
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableGroupByDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableGroupByDropdownContent.tsx
index a1ff36cc4bf..ce44ab9a0cf 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableGroupByDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableGroupByDropdownContent.tsx
@@ -16,7 +16,7 @@ import { t } from '@lingui/core/macro';
import { useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { useIcons } from 'twenty-ui/icon';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { filterBySearchQuery } from '~/utils/filterBySearchQuery';
const NO_GROUP_BY_ITEM_ID = 'no-group-by';
@@ -98,7 +98,7 @@ export const RecordTableGroupByDropdownContent = ({
closeDropdown();
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === NO_GROUP_BY_ITEM_ID}
onClick={() => {
handleGroupByFieldChange(null);
@@ -108,7 +108,7 @@ export const RecordTableGroupByDropdownContent = ({
aria-selected={!isDefined(currentMainGroupByFieldMetadataId)}
selected={!isDefined(currentMainGroupByFieldMetadataId)}
indicator="check"
- >{t`None`}</ListItem>
+ >{t`None`}</ListItemButton>
</SelectableListItem>
)}
{filteredFields.map((fieldMetadataItem) => (
@@ -120,7 +120,7 @@ export const RecordTableGroupByDropdownContent = ({
closeDropdown();
}}
>
- <ListItem
+ <ListItemButton
focused={selectedItemId === fieldMetadataItem.id}
onClick={() => {
handleGroupByFieldChange(fieldMetadataItem);
@@ -139,7 +139,7 @@ export const RecordTableGroupByDropdownContent = ({
}
>
{fieldMetadataItem.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
))}
</SelectableList>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableWidgetLayoutMenuItems.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableWidgetLayoutMenuItems.tsx
index b6a8f2a3285..2d6cf361091 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableWidgetLayoutMenuItems.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableWidgetLayoutMenuItems.tsx
@@ -4,7 +4,7 @@ import { type RecordTableWidgetLayoutPickerOption } from '@/page-layout/widgets/
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
import { useLingui } from '@lingui/react/macro';
import { isDefined } from 'twenty-shared/utils';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
type RecordTableWidgetLayoutMenuItemsProps = {
layoutOptions: RecordTableWidgetLayoutPickerOption[];
@@ -29,9 +29,9 @@ export const RecordTableWidgetLayoutMenuItems = ({
<SelectableListItem
key={viewType}
itemId={viewType}
- onEnter={() => onSelect(viewType)}
+ onEnter={isDisabled ? undefined : () => onSelect(viewType)}
>
- <ListItem
+ <ListItemButton
disabled={isDisabled}
focused={focusedItemId === viewType}
onClick={() => onSelect(viewType)}
@@ -46,7 +46,7 @@ export const RecordTableWidgetLayoutMenuItems = ({
startIcon={<SelectOptionIcon Icon={Icon} />}
>
{t(label)}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
),
)}
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/__tests__/RecordTableLayoutDropdownContent.test.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/__tests__/RecordTableLayoutDropdownContent.test.tsx
index 7ff1347c1d2..b90a7064009 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/__tests__/RecordTableLayoutDropdownContent.test.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/__tests__/RecordTableLayoutDropdownContent.test.tsx
@@ -67,8 +67,8 @@ jest.mock(
useAtomComponentStateValue: jest.fn(() => null),
}),
);
-jest.mock('twenty-ui/primitives/navigation', () => ({
- ListItem: ({
+jest.mock('twenty-ui/components/navigation', () => ({
+ ListItemButton: ({
description,
disabled,
onClick,
diff --git a/packages/twenty-front/src/modules/ui/input/components/__stories__/OptionPickers.stories.tsx b/packages/twenty-front/src/modules/ui/input/components/__stories__/OptionPickers.stories.tsx
index 3bb52c233a8..8d9cc3a0a29 100644
--- a/packages/twenty-front/src/modules/ui/input/components/__stories__/OptionPickers.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/__stories__/OptionPickers.stories.tsx
@@ -88,7 +88,7 @@ export const InnerSelectSkipsDisabled: Story = {
expect(await body.findByRole('dialog', { name: 'Position' })).toBeVisible();
expect(
await body.findByRole('button', { name: 'Disabled' }),
- ).toHaveAttribute('aria-disabled', 'true');
+ ).toBeDisabled();
await userEvent.keyboard('{ArrowDown}{Enter}');
await waitFor(() =>
expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
diff --git a/packages/twenty-front/src/modules/ui/input/components/__stories__/Select.stories.tsx b/packages/twenty-front/src/modules/ui/input/components/__stories__/Select.stories.tsx
index 47a823f8515..6e6dfdaf8d1 100644
--- a/packages/twenty-front/src/modules/ui/input/components/__stories__/Select.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/__stories__/Select.stories.tsx
@@ -129,7 +129,7 @@ export const SearchWithPinnedDisabledAndAction: Story = {
'Add option',
]);
const disabled = within(popup).getByRole('button', { name: 'Option B' });
- expect(disabled).toHaveAttribute('aria-disabled', 'true');
+ expect(disabled).toBeDisabled();
await userEvent.click(disabled);
expect(args.onChange).not.toHaveBeenCalled();
await userEvent.click(
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownContent.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownContent.tsx
index b6779b69f02..808cdc4185b 100644
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownContent.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownContent.tsx
@@ -15,6 +15,7 @@ type DropdownContentProps = Pick<
| 'collisionPadding'
| 'width'
| 'onKeyDown'
+ | 'onClick'
| 'initialFocus'
| 'finalFocus'
| 'className'
@@ -32,6 +33,7 @@ export const DropdownContent = ({
collisionPadding,
width,
onKeyDown,
+ onClick,
initialFocus,
finalFocus,
className,
@@ -52,6 +54,7 @@ export const DropdownContent = ({
collisionPadding={collisionPadding}
width={width}
onKeyDown={onKeyDown}
+ onClick={onClick}
initialFocus={initialFocus}
finalFocus={finalFocus}
className={className}
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableList.tsx b/packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableList.tsx
index 1d5e23a64df..6c646242082 100644
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableList.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableList.tsx
@@ -1,7 +1,8 @@
-import { type ReactNode } from 'react';
+import { type ReactNode, useCallback, useState } from 'react';
import { useSelectableListHotKeys } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys';
import { useSyncSelectableListItems } from '@/ui/layout/selectable-list/hooks/internal/useSyncSelectableListItems';
+import { SelectableListNativeItemRefsContext } from '@/ui/layout/selectable-list/states/contexts/SelectableListNativeItemRefsContext';
import { SelectableListComponentInstanceContext } from '@/ui/layout/selectable-list/states/contexts/SelectableListComponentInstanceContext';
import { SelectableListContextProvider } from '@/ui/layout/selectable-list/states/contexts/SelectableListContext';
@@ -24,7 +25,28 @@ export const SelectableList = ({
focusId,
shouldPreselectFirstItem = true,
}: SelectableListProps) => {
- useSelectableListHotKeys(selectableListInstanceId, focusId, onSelect);
+ const [nativeItemRefs] = useState(() => new Map<string, HTMLElement>());
+
+ const focusNativeItem = useCallback(
+ (itemId: string) => {
+ for (const nativeItem of nativeItemRefs.values()) {
+ if (nativeItem !== document.activeElement) {
+ continue;
+ }
+
+ nativeItemRefs.get(itemId)?.focus();
+ break;
+ }
+ },
+ [nativeItemRefs],
+ );
+
+ useSelectableListHotKeys({
+ instanceId: selectableListInstanceId,
+ focusId,
+ onSelect,
+ onNavigate: focusNativeItem,
+ });
useSyncSelectableListItems({
selectableListInstanceId,
@@ -39,9 +61,11 @@ export const SelectableList = ({
instanceId: selectableListInstanceId,
}}
>
- <SelectableListContextProvider value={{ focusId }}>
- {children}
- </SelectableListContextProvider>
+ <SelectableListNativeItemRefsContext.Provider value={nativeItemRefs}>
+ <SelectableListContextProvider value={{ focusId }}>
+ {children}
+ </SelectableListContextProvider>
+ </SelectableListNativeItemRefsContext.Provider>
</SelectableListComponentInstanceContext.Provider>
);
};
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/components/__stories__/SelectableList.stories.tsx b/packages/twenty-front/src/modules/ui/layout/selectable-list/components/__stories__/SelectableList.stories.tsx
index 19fef0ad337..d0d1aff7040 100644
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/components/__stories__/SelectableList.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/components/__stories__/SelectableList.stories.tsx
@@ -1,12 +1,13 @@
import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList';
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
+import { useSelectableListNativeItemRef } from '@/ui/layout/selectable-list/hooks/useSelectableListNativeItemRef';
import { usePushFocusItemToFocusStack } from '@/ui/utilities/focus/hooks/usePushFocusItemToFocusStack';
import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';
import { isNonEmptyString } from '@sniptt/guards';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { useEffect, useState } from 'react';
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { ComponentDecorator } from 'twenty-ui/testing';
const ITEM_LABELS = [
@@ -23,6 +24,26 @@ type RenderProps = {
shouldPreselectFirstItem?: boolean;
};
+type NativeSelectableItemProps = {
+ itemLabel: string;
+ onEnter: () => void;
+};
+
+const NativeSelectableItem = ({
+ itemLabel,
+ onEnter,
+}: NativeSelectableItemProps) => {
+ const nativeItemRef = useSelectableListNativeItemRef(itemLabel);
+
+ return (
+ <SelectableListItem itemId={itemLabel} onEnter={onEnter}>
+ <ListItemButton ref={nativeItemRef} onClick={onEnter}>
+ {itemLabel}
+ </ListItemButton>
+ </SelectableListItem>
+ );
+};
+
const Render = ({ onEnter, shouldPreselectFirstItem }: RenderProps) => {
const [searchFilter, setSearchFilter] = useState('');
@@ -58,13 +79,11 @@ const Render = ({ onEnter, shouldPreselectFirstItem }: RenderProps) => {
autoFocus
/>
{filteredItemLabels.map((itemLabel) => (
- <SelectableListItem
+ <NativeSelectableItem
key={itemLabel}
- itemId={itemLabel}
+ itemLabel={itemLabel}
onEnter={() => onEnter(itemLabel)}
- >
- <ListItem>{itemLabel}</ListItem>
- </SelectableListItem>
+ />
))}
</SelectableList>
);
@@ -163,3 +182,24 @@ export const SelectsNothingWithoutPreselection: Story = {
expect(args.onEnter).not.toHaveBeenCalled();
},
};
+
+export const NavigatesNativeOwnersAfterPointerSelection: Story = {
+ args: {
+ shouldPreselectFirstItem: true,
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.click(
+ await canvas.findByRole('button', { name: 'Content Marketing' }),
+ );
+ await userEvent.keyboard('{ArrowDown}{Enter}');
+
+ await waitFor(() => {
+ expect(args.onEnter).toHaveBeenLastCalledWith('Growth Hacking');
+ expect(
+ canvas.getByRole('button', { name: 'Growth Hacking' }),
+ ).toHaveFocus();
+ });
+ },
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/components/__tests__/SelectableList.test.tsx b/packages/twenty-front/src/modules/ui/layout/selectable-list/components/__tests__/SelectableList.test.tsx
index ab361f737fc..99e9eed0274 100644
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/components/__tests__/SelectableList.test.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/components/__tests__/SelectableList.test.tsx
@@ -2,9 +2,11 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { createStore, Provider } from 'jotai';
import { StrictMode, useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList';
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
+import { useSelectableListNativeItemRef } from '@/ui/layout/selectable-list/hooks/useSelectableListNativeItemRef';
import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
import { focusStackState } from '@/ui/utilities/focus/states/focusStackState';
import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';
@@ -15,17 +17,32 @@ const FOCUS_ID = 'menu-preselection-test';
const TestItem = ({
label,
onEnter,
+ onAction,
}: {
label: string;
onEnter: () => void;
+ onAction?: () => void;
}) => {
+ const nativeItemRef = useSelectableListNativeItemRef(label);
const isSelectedItemId = useAtomComponentFamilyStateValue(
isSelectedItemIdComponentFamilyState,
label,
);
return (
<SelectableListItem itemId={label} onEnter={onEnter}>
- <button aria-pressed={isSelectedItemId}>{label}</button>
+ <button
+ ref={nativeItemRef}
+ type="button"
+ aria-pressed={isSelectedItemId}
+ onClick={onEnter}
+ >
+ {label}
+ </button>
+ {isDefined(onAction) && (
+ <button type="button" onClick={onAction}>
+ {label} action
+ </button>
+ )}
</SelectableListItem>
);
};
@@ -33,9 +50,11 @@ const TestItem = ({
const TestMenu = ({
onEnter,
preselect,
+ onAction,
}: {
onEnter: (label: string) => void;
preselect?: boolean;
+ onAction?: (label: string) => void;
}) => {
const [search, setSearch] = useState('');
const items = ['Alpha', 'Beta'].filter((label) =>
@@ -55,13 +74,24 @@ const TestMenu = ({
onChange={(event) => setSearch(event.target.value)}
/>
{items.map((label) => (
- <TestItem key={label} label={label} onEnter={() => onEnter(label)} />
+ <TestItem
+ key={label}
+ label={label}
+ onEnter={() => onEnter(label)}
+ onAction={isDefined(onAction) ? () => onAction(label) : undefined}
+ />
))}
</SelectableList>
);
};
-const renderMenu = (preselect?: boolean) => {
+const renderMenu = ({
+ preselect,
+ onAction,
+}: {
+ preselect?: boolean;
+ onAction?: (label: string) => void;
+} = {}) => {
const store = createStore();
store.set(focusStackState.atom, [
{
@@ -80,7 +110,7 @@ const renderMenu = (preselect?: boolean) => {
const renderResult = render(
<StrictMode>
<Provider store={store}>
- <TestMenu onEnter={onEnter} preselect={preselect} />
+ <TestMenu onEnter={onEnter} preselect={preselect} onAction={onAction} />
</Provider>
</StrictMode>,
);
@@ -99,6 +129,35 @@ describe('SelectableList preselection', () => {
expect(onEnter).toHaveBeenLastCalledWith('Beta');
});
+ it('lets the focused native button handle Enter and Space while another item is selected', async () => {
+ const { user, onEnter } = renderMenu();
+ const secondButton = screen.getByRole('button', { name: 'Beta' });
+
+ secondButton.focus();
+ await user.keyboard('{Enter}');
+ expect(onEnter).toHaveBeenCalledTimes(1);
+ expect(onEnter).toHaveBeenLastCalledWith('Beta');
+
+ await user.keyboard(' ');
+ expect(onEnter).toHaveBeenCalledTimes(2);
+ expect(onEnter).toHaveBeenLastCalledWith('Beta');
+ });
+
+ it('keeps a focused nested action native while another row is highlighted', async () => {
+ const onAction = jest.fn();
+ const { user, onEnter } = renderMenu({ onAction });
+
+ await user.keyboard('{ArrowDown}');
+ await user.click(screen.getByRole('button', { name: 'Alpha action' }));
+ onAction.mockClear();
+ await user.keyboard('{ArrowUp}{ArrowDown}{Enter}');
+
+ expect(onAction).toHaveBeenCalledTimes(1);
+ expect(onAction).toHaveBeenCalledWith('Alpha');
+ expect(onEnter).not.toHaveBeenCalled();
+ expect(screen.getByRole('button', { name: 'Alpha action' })).toHaveFocus();
+ });
+
it('selects the first remaining result and clears selection for empty results', async () => {
const { user, onEnter } = renderMenu();
await user.type(screen.getByRole('textbox', { name: 'Search' }), 'be');
@@ -134,7 +193,7 @@ describe('SelectableList preselection', () => {
});
it('supports opting out of preselection', async () => {
- const { user, onEnter } = renderMenu(false);
+ const { user, onEnter } = renderMenu({ preselect: false });
await user.keyboard('{Enter}');
expect(onEnter).not.toHaveBeenCalled();
await user.keyboard('{ArrowDown}{Enter}');
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.ts
index 4bad752347c..895bffb1b9a 100644
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.ts
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.ts
@@ -10,11 +10,17 @@ import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotke
type Direction = 'up' | 'down' | 'left' | 'right';
-export const useSelectableListHotKeys = (
- instanceId: string,
- focusId: string,
- onSelect?: (itemId: string) => void,
-) => {
+export const useSelectableListHotKeys = ({
+ instanceId,
+ focusId,
+ onSelect,
+ onNavigate,
+}: {
+ instanceId: string;
+ focusId: string;
+ onSelect?: (itemId: string) => void;
+ onNavigate?: (itemId: string) => void;
+}) => {
const store = useStore();
const findPosition = (
@@ -104,6 +110,10 @@ export const useSelectableListHotKeys = (
const nextId = computeNextId(direction);
+ if (isNonEmptyString(nextId)) {
+ onNavigate?.(nextId);
+ }
+
if (selectedItemId !== nextId) {
if (isNonEmptyString(nextId)) {
store.set(
@@ -133,7 +143,7 @@ export const useSelectableListHotKeys = (
}
}
},
- [store, instanceId, onSelect],
+ [store, instanceId, onSelect, onNavigate],
);
useHotkeysOnFocusedElement({
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListListenToEnterHotkeyOnItem.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListListenToEnterHotkeyOnItem.ts
index f6d5f3e2f6b..50ea62bef25 100644
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListListenToEnterHotkeyOnItem.ts
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListListenToEnterHotkeyOnItem.ts
@@ -1,6 +1,7 @@
import { SelectableListComponentInstanceContext } from '@/ui/layout/selectable-list/states/contexts/SelectableListComponentInstanceContext';
import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState';
import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement';
+import { isKeyboardEventTargetActivatedByEnter } from '@/ui/utilities/hotkey/utils/isKeyboardEventTargetActivatedByEnter';
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
import { isNonEmptyString } from '@sniptt/guards';
import { useCallback } from 'react';
@@ -39,5 +40,8 @@ export const useSelectableListListenToEnterHotkeyOnItem = ({
callback: handleEnterKey,
focusId,
dependencies: [handleEnterKey],
+ options: {
+ ignoreEventWhen: isKeyboardEventTargetActivatedByEnter,
+ },
});
};
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListNativeItemRef.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListNativeItemRef.ts
new file mode 100644
index 00000000000..8730531b4c1
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableListNativeItemRef.ts
@@ -0,0 +1,24 @@
+import { useCallback, useContext } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+
+import { SelectableListNativeItemRefsContext } from '@/ui/layout/selectable-list/states/contexts/SelectableListNativeItemRefsContext';
+
+export const useSelectableListNativeItemRef = (itemId: string) => {
+ const nativeItemRefs = useContext(SelectableListNativeItemRefsContext);
+
+ if (!isDefined(nativeItemRefs)) {
+ throw new Error('SelectableList native item refs are not available');
+ }
+
+ return useCallback(
+ (element: HTMLElement | null) => {
+ if (!isDefined(element)) {
+ nativeItemRefs.delete(itemId);
+ return;
+ }
+
+ nativeItemRefs.set(itemId, element);
+ },
+ [itemId, nativeItemRefs],
+ );
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/contexts/SelectableListNativeItemRefsContext.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/contexts/SelectableListNativeItemRefsContext.ts
new file mode 100644
index 00000000000..6c2b262ac08
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/contexts/SelectableListNativeItemRefsContext.ts
@@ -0,0 +1,5 @@
+import { createContext } from 'react';
+
+export const SelectableListNativeItemRefsContext = createContext<
+ Map<string, HTMLElement> | undefined
+>(undefined);
diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx
index f31bf95743b..1039463ade2 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx
@@ -123,19 +123,20 @@ export const Overflow: Story = {
await userEvent.click(moreButton);
const popup = await body.findByRole('dialog', { name: /More/ });
const sales = await body.findByRole('button', { name: 'Sales' });
- expect(sales).toHaveAttribute('aria-disabled', 'true');
+ expect(sales).toBeDisabled();
await userEvent.click(sales);
expect(sales).toHaveAttribute('aria-pressed', 'false');
expect(popup).toBeVisible();
sales.focus();
- await userEvent.keyboard('{Enter}[Space]');
+ expect(sales).not.toHaveFocus();
expect(sales).toHaveAttribute('aria-pressed', 'false');
expect(canvas.getByRole('tab', { name: 'General' })).toHaveAttribute(
'aria-selected',
'true',
);
expect(popup).toBeVisible();
- await userEvent.click(body.getByRole('button', { name: 'Favorites' }));
+ body.getByRole('button', { name: 'Favorites' }).focus();
+ await userEvent.keyboard('{Enter}');
await waitFor(() =>
expect(
body.queryByRole('dialog', { name: /More/ }),
diff --git a/packages/twenty-front/src/modules/ui/navigation/menu-item/components/MenuItemWithOptionDropdown.tsx b/packages/twenty-front/src/modules/ui/navigation/menu-item/components/MenuItemWithOptionDropdown.tsx
index 1fc1240200b..7fc9e3c55e5 100644
--- a/packages/twenty-front/src/modules/ui/navigation/menu-item/components/MenuItemWithOptionDropdown.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/menu-item/components/MenuItemWithOptionDropdown.tsx
@@ -2,6 +2,7 @@ import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent
import { DropdownRoot } from '@/ui/layout/dropdown/components/DropdownRoot';
import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
+import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { type MouseEvent } from 'react';
import { isDefined } from 'twenty-shared/utils';
@@ -9,9 +10,53 @@ import { LightIconButton } from 'twenty-ui/components/input';
import { Dropdown } from 'twenty-ui/components/navigation';
import { IconDotsVertical } from 'twenty-ui/icon';
import { ListItem } from 'twenty-ui/primitives/navigation';
-import { useTheme } from 'twenty-ui/theme';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
import { type MenuItemWithOptionDropdownProps } from './types/MenuItemWithOptionDropdownProps';
+const StyledMenuItemContainer = styled.div<{
+ focused: boolean;
+ showActions: boolean;
+}>`
+ align-items: center;
+ background: ${({ focused }) =>
+ focused ? themeCssVariables.background.transparent.light : 'transparent'};
+ border-radius: calc(
+ ${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}
+ );
+ box-sizing: border-box;
+ display: flex;
+ gap: ${themeCssVariables.spacing[2]};
+ min-width: 0;
+ padding-inline: ${themeCssVariables.spacing[1]};
+ width: 100%;
+
+ &:hover {
+ background: ${themeCssVariables.background.transparent.light};
+ }
+
+ .hoverable-buttons {
+ display: flex;
+ }
+
+ @media (hover: hover) and (pointer: fine) {
+ .hoverable-buttons {
+ opacity: ${({ showActions }) => (showActions ? 1 : 0)};
+ }
+
+ &:hover .hoverable-buttons,
+ &:focus-within .hoverable-buttons {
+ opacity: 1;
+ }
+ }
+`;
+
+const StyledPrimaryListItem = styled(ListItem)`
+ background: transparent;
+ flex: 1;
+ min-width: 0;
+ padding-inline: 0;
+`;
+
export const MenuItemWithOptionDropdown = ({
accent = 'default',
className,
@@ -35,53 +80,59 @@ export const MenuItemWithOptionDropdown = ({
isDropdownOpenComponentState,
dropdownId,
);
- const handleMenuItemClick = (event: MouseEvent<HTMLDivElement>) => {
- if (!isDefined(onClick)) {
- return;
- }
-
+ const handleMenuItemClick = (event: MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
event.stopPropagation();
-
- onClick(event);
+ onClick?.(event);
};
return (
- <ListItem
+ <StyledMenuItemContainer
data-testid={testId ?? undefined}
- onClick={handleMenuItemClick}
className={className}
- color={accent === 'danger' ? 'danger' : 'neutral'}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
focused={selected}
- startIcon={isDefined(LeftIcon) && <LeftIcon size={theme.icon.size.md} />}
- hasSubmenu={hasSubMenu}
- actionsVisibility={
- isIconDisplayedOnHoverOnly && !isDropdownOpen ? 'hover' : 'always'
- }
- actions={
- <div className="hoverable-buttons">
- <DropdownRoot dropdownId={dropdownId} type="menu">
- <Dropdown.Trigger
- render={
- <LightIconButton
- size="sm"
- emphasis="subtle"
- aria-label={t`More options`}
- >
- {isDefined(RightIcon) ? <RightIcon /> : <IconDotsVertical />}
- </LightIconButton>
- }
- />
- <DropdownContent side={dropdownSide} align={dropdownAlign}>
- {dropdownContent}
- </DropdownContent>
- </DropdownRoot>
- </div>
- }
+ showActions={!isIconDisplayedOnHoverOnly || isDropdownOpen}
>
- {text}
- </ListItem>
+ <StyledPrimaryListItem
+ render={
+ isDefined(onClick) ? (
+ <button type="button" onClick={handleMenuItemClick} />
+ ) : undefined
+ }
+ color={accent === 'danger' ? 'danger' : 'neutral'}
+ focused={selected}
+ startIcon={
+ isDefined(LeftIcon) && <LeftIcon size={theme.icon.size.md} />
+ }
+ hasSubmenu={hasSubMenu}
+ >
+ {text}
+ </StyledPrimaryListItem>
+ <div className="hoverable-buttons">
+ <DropdownRoot dropdownId={dropdownId} type="menu">
+ <Dropdown.Trigger
+ onClick={(event) => event.stopPropagation()}
+ render={
+ <LightIconButton
+ size="sm"
+ emphasis="subtle"
+ aria-label={t`More options`}
+ >
+ {isDefined(RightIcon) ? <RightIcon /> : <IconDotsVertical />}
+ </LightIconButton>
+ }
+ />
+ <DropdownContent
+ side={dropdownSide}
+ align={dropdownAlign}
+ onClick={(event) => event.stopPropagation()}
+ >
+ {dropdownContent}
+ </DropdownContent>
+ </DropdownRoot>
+ </div>
+ </StyledMenuItemContainer>
);
};
diff --git a/packages/twenty-front/src/modules/ui/navigation/menu-item/components/__tests__/MenuItemWithOptionDropdown.test.tsx b/packages/twenty-front/src/modules/ui/navigation/menu-item/components/__tests__/MenuItemWithOptionDropdown.test.tsx
new file mode 100644
index 00000000000..7d9aa17784c
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/menu-item/components/__tests__/MenuItemWithOptionDropdown.test.tsx
@@ -0,0 +1,96 @@
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { createStore, Provider } from 'jotai';
+import { type MouseEvent } from 'react';
+import { Dropdown } from 'twenty-ui/components/navigation';
+
+import { MenuItemWithOptionDropdown } from '@/ui/navigation/menu-item/components/MenuItemWithOptionDropdown';
+
+describe('MenuItemWithOptionDropdown', () => {
+ it('activates the main native button with Enter and Space and preserves its explicit event boundary', async () => {
+ const user = userEvent.setup();
+ const onParentClick = jest.fn();
+ const onClick = jest.fn((event: MouseEvent<HTMLButtonElement>) => ({
+ tagName: event.currentTarget.tagName,
+ defaultPrevented: event.defaultPrevented,
+ }));
+
+ render(
+ <Provider store={createStore()}>
+ <div onClick={onParentClick}>
+ <MenuItemWithOptionDropdown
+ dropdownId="main-action-options"
+ text="Current view"
+ onClick={onClick}
+ dropdownContent={<Dropdown.ActionItem>Rename</Dropdown.ActionItem>}
+ />
+ </div>
+ </Provider>,
+ );
+
+ const mainButton = screen.getByRole('button', { name: 'Current view' });
+
+ mainButton.focus();
+ await user.keyboard('{Enter}');
+ await user.keyboard(' ');
+
+ expect(onClick).toHaveBeenCalledTimes(2);
+ expect(onClick).toHaveLastReturnedWith({
+ tagName: 'BUTTON',
+ defaultPrevented: true,
+ });
+ expect(onParentClick).not.toHaveBeenCalled();
+ });
+
+ it('opens the trailing menu and activates its item without activating the main button or its ancestor', async () => {
+ const user = userEvent.setup();
+ const onClick = jest.fn();
+ const onRename = jest.fn();
+ const onParentClick = jest.fn();
+
+ render(
+ <Provider store={createStore()}>
+ <div onClick={onParentClick}>
+ <MenuItemWithOptionDropdown
+ dropdownId="trailing-action-options"
+ text="Current view"
+ onClick={onClick}
+ dropdownContent={
+ <Dropdown.ActionItem onClick={onRename}>
+ Rename
+ </Dropdown.ActionItem>
+ }
+ />
+ </div>
+ </Provider>,
+ );
+
+ await user.click(screen.getByRole('button', { name: 'More options' }));
+ await user.click(await screen.findByRole('menuitem', { name: 'Rename' }));
+
+ expect(onRename).toHaveBeenCalledTimes(1);
+ expect(onClick).not.toHaveBeenCalled();
+ expect(onParentClick).not.toHaveBeenCalled();
+ await waitFor(() =>
+ expect(screen.queryByRole('menu')).not.toBeInTheDocument(),
+ );
+ });
+
+ it('keeps caller-provided links as explicit content when there is no main action', () => {
+ render(
+ <Provider store={createStore()}>
+ <MenuItemWithOptionDropdown
+ dropdownId="link-options"
+ text={<a href="https://twenty.com">Documentation</a>}
+ dropdownContent={<Dropdown.ActionItem>Copy</Dropdown.ActionItem>}
+ />
+ </Provider>,
+ );
+
+ const link = screen.getByRole('link', { name: 'Documentation' });
+
+ expect(link).toHaveAttribute('href', 'https://twenty.com');
+ expect(link.closest('button')).toBeNull();
+ expect(screen.getAllByRole('button')).toHaveLength(1);
+ });
+});
diff --git a/packages/twenty-front/src/modules/ui/navigation/menu-item/components/types/MenuItemWithOptionDropdownProps.ts b/packages/twenty-front/src/modules/ui/navigation/menu-item/components/types/MenuItemWithOptionDropdownProps.ts
index 0b17cfae116..2bdc50de7e7 100644
--- a/packages/twenty-front/src/modules/ui/navigation/menu-item/components/types/MenuItemWithOptionDropdownProps.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/menu-item/components/types/MenuItemWithOptionDropdownProps.ts
@@ -14,7 +14,7 @@ export type MenuItemWithOptionDropdownProps = {
isTooltipOpen?: boolean;
LeftIcon?: IconComponent | null;
RightIcon?: IconComponent | null;
- onClick?: (event: MouseEvent<HTMLDivElement>) => void;
+ onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void;
onMouseLeave?: (event: MouseEvent<HTMLDivElement>) => void;
testId?: string;
diff --git a/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAdvancedFilterButton.tsx b/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAdvancedFilterButton.tsx
index 3fe27a640f4..6954c95f026 100644
--- a/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAdvancedFilterButton.tsx
+++ b/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAdvancedFilterButton.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
import { availableFieldMetadataItemsForFilterFamilySelector } from '@/object-metadata/states/availableFieldMetadataItemsForFilterFamilySelector';
import { useUpsertRecordFilterGroup } from '@/object-record/record-filter-group/hooks/useUpsertRecordFilterGroup';
@@ -149,7 +149,7 @@ export const ViewBarFilterDropdownAdvancedFilterButton = () => {
itemId={VIEW_BAR_FILTER_BOTTOM_MENU_ITEM_IDS.ADVANCED_FILTER}
onEnter={handleClick}
>
- <ListItem
+ <ListItemButton
onClick={handleClick}
startIcon={<IconFilter />}
focused={isSelectedItemId}
@@ -160,7 +160,7 @@ export const ViewBarFilterDropdownAdvancedFilterButton = () => {
</StyledPillContainer>
) : undefined
}
- >{t`Advanced filter`}</ListItem>
+ >{t`Advanced filter`}</ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAnyFieldSearchButtonMenuItem.tsx b/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAnyFieldSearchButtonMenuItem.tsx
index 8889b20c23c..6dd488df0f4 100644
--- a/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAnyFieldSearchButtonMenuItem.tsx
+++ b/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownAnyFieldSearchButtonMenuItem.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
@@ -33,12 +33,12 @@ export const ViewBarFilterDropdownAnyFieldSearchButtonMenuItem = ({
itemId={VIEW_BAR_FILTER_BOTTOM_MENU_ITEM_IDS.SEARCH}
onEnter={onClick}
>
- <ListItem
+ <ListItemButton
focused={isSelectedItemId}
onClick={onClick}
startIcon={<IconSearch />}
description={objectFilterDropdownSearchInput}
- >{t`Search any field`}</ListItem>
+ >{t`Search any field`}</ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownFieldSelectMenuItem.tsx b/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownFieldSelectMenuItem.tsx
index 7f55858674c..82ef6c4f15f 100644
--- a/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownFieldSelectMenuItem.tsx
+++ b/packages/twenty-front/src/modules/views/components/ViewBarFilterDropdownFieldSelectMenuItem.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { SelectOptionIcon } from '@/ui/input/components/SelectOptionIcon';
import { type FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
@@ -42,13 +42,13 @@ export const ViewBarFilterDropdownFieldSelectMenuItem = ({
itemId={fieldMetadataItemToSelect.id}
onEnter={handleClick}
>
- <ListItem
+ <ListItemButton
focused={isSelectedItemId}
onClick={handleClick}
startIcon={<SelectOptionIcon Icon={Icon} />}
>
{fieldMetadataItemToSelect.label}
- </ListItem>
+ </ListItemButton>
</SelectableListItem>
);
};
diff --git a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx
index 3a408c76136..70e7be3c3bf 100644
--- a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx
+++ b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { styled } from '@linaria/react';
import { type DraggableListDropResult } from '@/ui/layout/draggable-list/types/DraggableListDropResult';
import { type MouseEvent, useCallback } from 'react';
@@ -219,10 +219,10 @@ export const ViewPickerListContent = () => {
<DropdownMenuSeparator />
<StyledBoldDropdownMenuItemsContainerWrapper>
<DropdownMenuItemsContainer scrollable={false}>
- <ListItem
+ <ListItemButton
onClick={handleAddViewButtonClick}
startIcon={<IconPlus />}
- >{t`Add view`}</ListItem>
+ >{t`Add view`}</ListItemButton>
</DropdownMenuItemsContainer>
</StyledBoldDropdownMenuItemsContainerWrapper>
</LegacyDropdownContent>
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramRightClickCommandMenu.tsx b/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramRightClickCommandMenu.tsx
index 051793ba2f8..ae780673c51 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramRightClickCommandMenu.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramRightClickCommandMenu.tsx
@@ -1,4 +1,4 @@
-import { ListItem } from 'twenty-ui/primitives/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { useCloseRightClickMenu } from '@/workflow/workflow-diagram/hooks/useCloseRightClickMenu';
import { useStartNodeCreation } from '@/workflow/workflow-diagram/hooks/useStartNodeCreation';
@@ -71,14 +71,14 @@ export const WorkflowDiagramRightClickCommandMenu = () => {
x={workflowDiagramRightClickMenuPosition.x}
y={workflowDiagramRightClickMenuPosition.y}
>
- <ListItem
+ <ListItemButton
startIcon={<IconPlus />}
onClick={addNode}
- >{t`Add node`}</ListItem>
- <ListItem
+ >{t`Add node`}</ListItemButton>
+ <ListItemButton
startIcon={<IconReorder />}
onClick={handleReorderWorkflowDiagram}
- >{t`Tidy up workflow`}</ListItem>
+ >{t`Tidy up workflow`}</ListItemButton>
</StyledContainer>
<WorkflowDiagramRightClickCommandMenuClickOutsideEffect
rightClickCommandMenuRef={rightClickCommandMenuRef}
diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.ts
index 647571c0cab..cac46fa3b4b 100644
--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts
+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts
@@ -163,6 +163,8 @@ export const DOCUMENTATION_PATHS = {
'/ui/components/layout/overflowing-list',
UI_COMPONENTS_LAYOUT_SECTION: '/ui/components/layout/section',
UI_COMPONENTS_NAVIGATION_DROPDOWN: '/ui/components/navigation/dropdown',
+ UI_COMPONENTS_NAVIGATION_LIST_ITEM_BUTTON:
+ '/ui/components/navigation/list-item-button',
UI_COMPONENTS_NAVIGATION_MENU_ITEMS: '/ui/components/navigation/menu-items',
UI_COMPONENTS_NAVIGATION_MENU_PICKER: '/ui/components/navigation/menu-picker',
UI_COMPONENTS_NAVIGATION_TAB_BUTTON: '/ui/components/navigation/tab-button',
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index b1ffa280531..558c27436bc 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -424,6 +424,15 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/primitives/navigation',
slug: 'navigation/list-item',
propDescriptions: {
+ ref: 'Ref to the actual DOM root, including a composed native button or link.',
+ selected:
+ 'Applies selected styling and the configured decorative indicator. Selection state and accessible semantics belong to the owner.',
+ focused:
+ 'Applies highlighted styling without moving DOM focus or handling keyboard navigation.',
+ disabled:
+ 'Applies disabled styling only. Set native disabled behavior and accessible semantics on the button, link, or popup item owner.',
+ render:
+ 'Composes the row with an element or render callback. The owner supplies interaction semantics, native attributes, and behavior.',
shortcutJoinLabel:
'Text between sequential shortcut steps. Defaults to `then`; pass an empty string to omit it.',
actionsVisibility:
@@ -736,6 +745,27 @@ export const DOCUMENTED_COMPONENTS = [
slug: 'components/code-editor/code-editor-header',
propDescriptions: CODE_EDITOR_HEADER_PROP_DESCRIPTIONS,
},
+ {
+ name: 'ListItemButton',
+ source: 'components/navigation/ListItemButton/ListItemButton.tsx',
+ entryPoint: 'twenty-ui/components/navigation',
+ slug: 'components/navigation/list-item-button',
+ propDescriptions: {
+ ref: 'Ref to the native HTMLButtonElement.',
+ disabled: 'Disables activation and applies the matching row appearance.',
+ focusableWhenDisabled:
+ 'Keeps a disabled button focusable with aria-disabled while preventing activation.',
+ selected:
+ 'Applies selected styling and a decorative indicator. The caller supplies selection state and accessible semantics.',
+ focused: 'Highlights the row without moving DOM focus.',
+ shortcut:
+ 'Displays decorative shortcut hints. The caller registers the shortcuts.',
+ shortcutJoinLabel:
+ 'Text between sequential shortcut steps. Defaults to `then`; pass an empty string to omit it.',
+ hasSubmenu: 'Displays a decorative submenu indicator.',
+ },
+ propDefaults: { type: 'button', disabled: 'false' },
+ },
{
name: 'TabButton',
source: 'components/navigation/TabButton/TabButton.tsx',
diff --git a/packages/twenty-ui/docs/label-ownership.md b/packages/twenty-ui/docs/label-ownership.md
index c2188d4b796..168593499af 100644
--- a/packages/twenty-ui/docs/label-ownership.md
+++ b/packages/twenty-ui/docs/label-ownership.md
@@ -6,6 +6,7 @@ This covers production exports under components, primitives, and icons, includin
| --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Callout | `title`, `description`, `icon`, and `action` nodes, plus `closeLabel` (default `Close`). The optional `onDismiss` requests caller-owned visibility changes. |
| ListItem and Menu item parts | Children, description, action slots, native accessible attributes, and `shortcutJoinLabel` (default `then`). |
+| ListItemButton | Children, description, native accessible attributes, and `shortcutJoinLabel` (default `then`). Independent actions remain sibling controls. |
| Dropdown | Children name actions, options, titles, sections, empty states, and loading states. `Back` children default to `Back`. Search accepts native placeholder and accessible attributes. Close requires a caller-supplied accessible label and accepts native `aria-labelledby`. Item parts pass `shortcutJoinLabel` to ListItem. |
| CurrencyPicker | `searchLabel` defaults to `Search` and supplies the search placeholder and accessible name. `emptyLabel` defaults to `No results`. Currency names and codes are caller data; trigger and dropdown accessible names belong to the host. |
| Legacy menu compositions | MenuItem exposes `text`, contextual slots, and `shortcutJoinLabel` (default `then`). Avatar, draggable, suggestion, and picker presets receive their text from callers; they add no English fallback. Keep this additive option until their separate migration removes the exports. |
diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.json
index 499d487f317..529041dad8e 100644
--- a/packages/twenty-ui/docs/module-ownership.json
+++ b/packages/twenty-ui/docs/module-ownership.json
@@ -61,6 +61,7 @@
"JsonTree",
"LightButton",
"LightIconButton",
+ "ListItemButton",
"MainButton",
"MenuItem",
"MenuItemAvatar",
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index a6b1f4ecc8f..038c90661cf 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -132,6 +132,7 @@
"values": {
"DEFAULT_COLOR_LABELS": "components/navigation/MenuItem/constants/DefaultColorLabels",
"Dropdown": "components/navigation/Dropdown/Dropdown",
+ "ListItemButton": "components/navigation/ListItemButton/ListItemButton",
"MenuItem": "components/navigation/MenuItem/MenuItem",
"MenuItemAvatar": "components/navigation/MenuItemAvatar/MenuItemAvatar",
"MenuItemDraggable": "components/navigation/MenuItemDraggable/MenuItemDraggable",
@@ -157,6 +158,7 @@
"DropdownTitleProps": "components/navigation/Dropdown/types/DropdownTitleProps",
"DropdownTriggerProps": "components/navigation/Dropdown/types/DropdownTriggerProps",
"DropdownType": "components/navigation/Dropdown/types/DropdownType",
+ "ListItemButtonProps": "components/navigation/ListItemButton/types/ListItemButtonProps",
"MenuItemAccent": "components/navigation/MenuItem/types/MenuItemAccent",
"MenuItemAvatarProps": "components/navigation/MenuItemAvatar/types/MenuItemAvatarProps",
"MenuItemDraggableGripMode": "components/navigation/MenuItem/types/MenuItemDraggableGripMode",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 3e632df3cd4..cf5e9e82e18 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -5263,7 +5263,7 @@
"type": "boolean",
"required": false,
"defaultValue": "false",
- "description": "Prevents clicks and applies the disabled style."
+ "description": "Applies disabled styling only. Set native disabled behavior and accessible semantics on the button, link, or popup item owner."
},
{
"name": "endIcon",
@@ -5277,7 +5277,7 @@
"type": "boolean",
"required": false,
"defaultValue": "false",
- "description": "Applies the highlighted style, for example to the focused item of a list."
+ "description": "Applies highlighted styling without moving DOM focus or handling keyboard navigation."
},
{
"name": "hasSubmenu",
@@ -5293,19 +5293,26 @@
"defaultValue": "none",
"description": "Selection indicator: a check icon after the content or a checkbox before\nit."
},
+ {
+ "name": "ref",
+ "type": "Ref<HTMLElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the actual DOM root, including a composed native button or link."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ListItemState>",
"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."
+ "description": "Composes the row with an element or render callback. The owner supplies interaction semantics, native attributes, and behavior."
},
{
"name": "selected",
"type": "boolean",
"required": false,
"defaultValue": "false",
- "description": "Whether the item is selected. Shows the check or checkbox indicator when\n`indicator` is set."
+ "description": "Applies selected styling and the configured decorative indicator. Selection state and accessible semantics belong to the owner."
},
{
"name": "shortcut",
@@ -11329,6 +11336,111 @@
}
]
},
+ {
+ "name": "ListItemButton",
+ "entryPoint": "twenty-ui/components/navigation",
+ "slug": "components/navigation/list-item-button",
+ "props": [
+ {
+ "name": "color",
+ "type": "\"danger\" | \"neutral\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Color of the text and icons. `danger` marks a destructive action."
+ },
+ {
+ "name": "description",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Supporting text, placed according to `descriptionPlacement`."
+ },
+ {
+ "name": "descriptionPlacement",
+ "type": "\"end\" | \"inline\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Where the description renders: inline after the content or at the end of\nthe row."
+ },
+ {
+ "name": "disabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Disables activation and applies the matching row appearance."
+ },
+ {
+ "name": "endIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Icon rendered after the content."
+ },
+ {
+ "name": "focusableWhenDisabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Keeps a disabled button focusable with aria-disabled while preventing activation."
+ },
+ {
+ "name": "focused",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Highlights the row without moving DOM focus."
+ },
+ {
+ "name": "hasSubmenu",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Displays a decorative submenu indicator."
+ },
+ {
+ "name": "indicator",
+ "type": "\"check\" | \"checkbox\" | \"none\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Selection indicator: a check icon after the content or a checkbox before\nit."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLButtonElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the native HTMLButtonElement."
+ },
+ {
+ "name": "selected",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Applies selected styling and a decorative indicator. The caller supplies selection state and accessible semantics."
+ },
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Displays decorative shortcut hints. The caller registers the shortcuts."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`; pass an empty string to omit it."
+ },
+ {
+ "name": "startIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Icon rendered before the content."
+ }
+ ]
+ },
{
"name": "TabButton",
"entryPoint": "twenty-ui/components/navigation",
diff --git a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.interactions.stories.tsx b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.interactions.stories.tsx
index b513e5753fa..2b74e081ebf 100644
--- a/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.interactions.stories.tsx
+++ b/packages/twenty-ui/src/components/input/CurrencyPicker/__stories__/CurrencyPicker.interactions.stories.tsx
@@ -165,7 +165,7 @@ export const DisabledCurrency: Story = {
name: 'British Pound (GBP)',
});
- await expect(disabledCurrency).toHaveAttribute('aria-disabled', 'true');
+ await expect(disabledCurrency).toBeDisabled();
await userEvent.click(disabledCurrency);
await expect(args.onValueChange).not.toHaveBeenCalled();
await userEvent.type(search, 'pound');
@@ -217,7 +217,7 @@ export const DisabledOptions: Story = {
await waitFor(() => expect(dialog).toBeVisible());
await expect(within(dialog).getByRole('searchbox')).toBeDisabled();
for (const option of within(dialog).getAllByRole('button')) {
- await expect(option).toHaveAttribute('aria-disabled', 'true');
+ await expect(option).toBeDisabled();
}
await userEvent.click(
within(dialog).getByRole('button', { name: 'Euro (EUR)' }),
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.grid.stories.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.grid.stories.tsx
index a993462a7cc..cb3964c92f7 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.grid.stories.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.grid.stories.tsx
@@ -62,6 +62,9 @@ export const IconGrid: Story = {
await waitFor(() => expect(search).toHaveFocus());
expect(group).toHaveStyle({ display: 'grid' });
+ await expect(
+ within(popup).getByRole('button', { name: 'Calendar 5' }),
+ ).toBeDisabled();
await waitFor(() =>
expect(
within(popup)
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.menu.stories.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.menu.stories.tsx
index 6f366721b99..371d6edace6 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.menu.stories.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.menu.stories.tsx
@@ -12,6 +12,7 @@ import { DROPDOWN_STORY_A11Y_PARAMETERS } from './dropdownStoryA11yParameters';
const TYPEAHEAD_PAUSE_IN_MS = 600;
const onArchive = fn();
+const onItemRef = fn<(element: HTMLElement | null) => void>();
const onDuplicate = fn();
const onContactSupport = fn();
const onExportRecords = fn();
@@ -103,6 +104,7 @@ const meta: Meta = {
beforeEach: () => {
for (const spy of [
onArchive,
+ onItemRef,
onDuplicate,
onContactSupport,
onExportRecords,
@@ -190,9 +192,18 @@ export const InitialFocusEdge: Story = {
export const DisabledCommand: Story = {
render: () => (
<RecordActionsMenu>
- <Dropdown.ActionItem disabled onClick={onArchive}>
+ <Dropdown.ActionItem ref={onItemRef} disabled onClick={onArchive}>
Archive
</Dropdown.ActionItem>
+ <Dropdown.ActionItem
+ ref={onItemRef}
+ disabled
+ nativeButton
+ render={<Button />}
+ onClick={onArchive}
+ >
+ Export
+ </Dropdown.ActionItem>
<Dropdown.ActionItem onClick={onDuplicate}>Duplicate</Dropdown.ActionItem>
</RecordActionsMenu>
),
@@ -200,7 +211,16 @@ export const DisabledCommand: Story = {
const body = within(canvasElement.ownerDocument.body);
const menu = await openRecordActions(canvasElement);
- await userEvent.click(body.getByRole('menuitem', { name: 'Archive' }));
+ const archive = body.getByRole('menuitem', { name: 'Archive' });
+
+ const exportCommand = body.getByRole('menuitem', { name: 'Export' });
+
+ await expect(archive).toBeDisabled();
+ await expect(exportCommand).toBeDisabled();
+ await expect(onItemRef).toHaveBeenCalledWith(archive);
+ await expect(onItemRef).toHaveBeenCalledWith(exportCommand);
+ await userEvent.click(archive);
+ await userEvent.click(exportCommand);
expect(onArchive).not.toHaveBeenCalled();
expect(menu).toBeVisible();
await userEvent.click(body.getByRole('menuitem', { name: 'Duplicate' }));
@@ -211,6 +231,36 @@ export const DisabledCommand: Story = {
},
};
+export const FocusableDisabledCommand: Story = {
+ render: () => (
+ <RecordActionsMenu>
+ <Dropdown.ActionItem disabled focusableWhenDisabled onClick={onArchive}>
+ Archive
+ </Dropdown.ActionItem>
+ <Dropdown.ActionItem onClick={onDuplicate}>Duplicate</Dropdown.ActionItem>
+ </RecordActionsMenu>
+ ),
+ play: async ({ canvasElement }) => {
+ const body = within(canvasElement.ownerDocument.body);
+ const menu = await openRecordActions(canvasElement);
+ const archive = body.getByRole('menuitem', { name: 'Archive' });
+
+ await expect(archive).toHaveAttribute('aria-disabled', 'true');
+ await expect(archive).not.toBeDisabled();
+ archive.focus();
+ await expect(archive).toHaveFocus();
+ await userEvent.keyboard('{Enter} ');
+ await userEvent.click(archive);
+ await expect(onArchive).not.toHaveBeenCalled();
+ await expect(menu).toBeVisible();
+ await userEvent.click(body.getByRole('menuitem', { name: 'Duplicate' }));
+ await expect(onDuplicate).toHaveBeenCalledOnce();
+ await waitFor(() =>
+ expect(body.queryByRole('menu')).not.toBeInTheDocument(),
+ );
+ },
+};
+
export const OptionWithoutSelectionState: Story = {
render: () => (
<RecordActionsMenu>
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.picker.stories.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.picker.stories.tsx
index 501c25fb6e6..fcbe81339bf 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.picker.stories.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.picker.stories.tsx
@@ -544,6 +544,62 @@ export const LinkOptionsMarkCurrent: Story = {
},
};
+export const DisabledLinkOption: Story = {
+ render: () => (
+ <Dropdown.Root type="picker">
+ <Dropdown.Trigger>Workspaces</Dropdown.Trigger>
+ <Dropdown.Content aria-label="Switch workspace">
+ <Dropdown.OptionItem
+ ref={onItemRef}
+ disabled
+ selected={false}
+ render={
+ <a
+ href="#unavailable-workspace"
+ aria-label="Unavailable workspace"
+ />
+ }
+ onSelect={onSelectDisabledOption}
+ >
+ Unavailable workspace
+ </Dropdown.OptionItem>
+ <Dropdown.OptionItem selected={false}>
+ Current workspace
+ </Dropdown.OptionItem>
+ </Dropdown.Content>
+ </Dropdown.Root>
+ ),
+ play: async ({ canvasElement }) => {
+ const document = canvasElement.ownerDocument;
+ const body = within(document.body);
+ const initialLocation = document.URL;
+
+ await userEvent.click(
+ within(canvasElement).getByRole('button', { name: 'Workspaces' }),
+ );
+ const link = await body.findByRole('link', {
+ name: 'Unavailable workspace',
+ });
+ const currentWorkspace = body.getByRole('button', {
+ name: 'Current workspace',
+ });
+
+ await expect(link).toHaveAttribute('aria-disabled', 'true');
+ await expect(link).not.toHaveAttribute('disabled');
+ await expect(link).toHaveAttribute('tabindex', '-1');
+ await expect(onItemRef).toHaveBeenCalledWith(link);
+ await waitFor(() => expect(currentWorkspace).toHaveFocus());
+ await userEvent.click(link);
+ await expect(onSelectDisabledOption).not.toHaveBeenCalled();
+ await expect(document.URL).toBe(initialLocation);
+ await expect(body.getByRole('dialog')).toBeVisible();
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ },
+};
+
export const LoadingStatus: Story = {
render: () => (
<Dropdown.Root type="picker">
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.submenu.stories.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.submenu.stories.tsx
index af3ef22127c..021a17a5a8b 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.submenu.stories.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.submenu.stories.tsx
@@ -1,6 +1,7 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { Button } from '@ui/primitives/input/Button/Button';
import { DirectionProvider } from '@ui/primitives/layout/DirectionProvider/DirectionProvider';
import { ComponentDecorator } from '@ui/testing';
@@ -84,3 +85,91 @@ export const HoverThenEscape: Story = {
dismissKey: '{Escape}',
}),
};
+
+export const DisabledSubmenuOwners: Story = {
+ render: () => (
+ <Dropdown.Root type="menu">
+ <Dropdown.Trigger>Record actions</Dropdown.Trigger>
+ <Dropdown.Content aria-label="Record actions">
+ <Dropdown.ActionItem>Duplicate</Dropdown.ActionItem>
+ <Dropdown.Submenu>
+ <Dropdown.SubmenuTrigger disabled delay={0}>
+ Export
+ </Dropdown.SubmenuTrigger>
+ <Dropdown.Content aria-label="Export formats">
+ <Dropdown.ActionItem>CSV</Dropdown.ActionItem>
+ </Dropdown.Content>
+ </Dropdown.Submenu>
+ <Dropdown.Submenu>
+ <Dropdown.SubmenuTrigger
+ disabled
+ nativeButton
+ render={<Button />}
+ delay={0}
+ >
+ Import
+ </Dropdown.SubmenuTrigger>
+ <Dropdown.Content aria-label="Import formats">
+ <Dropdown.ActionItem>CSV</Dropdown.ActionItem>
+ </Dropdown.Content>
+ </Dropdown.Submenu>
+ <Dropdown.Submenu>
+ <Dropdown.SubmenuTrigger delay={0}>Sort</Dropdown.SubmenuTrigger>
+ <Dropdown.Content aria-label="Sorting directions">
+ <Dropdown.ActionItem>Ascending</Dropdown.ActionItem>
+ </Dropdown.Content>
+ </Dropdown.Submenu>
+ </Dropdown.Content>
+ </Dropdown.Root>
+ ),
+ play: async ({ canvasElement }) => {
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.click(
+ within(canvasElement).getByRole('button', { name: 'Record actions' }),
+ );
+ const duplicate = await body.findByRole('menuitem', {
+ name: 'Duplicate',
+ });
+ const sort = body.getByRole('menuitem', { name: 'Sort' });
+
+ await waitFor(() => expect(duplicate).toHaveFocus());
+ for (const name of ['Export', 'Import']) {
+ const trigger = body.getByRole('menuitem', { name });
+
+ await expect(trigger).toBeDisabled();
+ trigger.focus();
+ await expect(duplicate).toHaveFocus();
+ await userEvent.hover(trigger);
+ await userEvent.click(trigger);
+ await expect(trigger).toHaveAttribute('aria-expanded', 'false');
+ }
+ await userEvent.keyboard('{ArrowDown}');
+ await expect(sort).toHaveFocus();
+ await userEvent.keyboard('{ArrowUp}');
+ await expect(duplicate).toHaveFocus();
+ await userEvent.hover(sort);
+ const submenu = await body.findByRole('menu', {
+ name: 'Sorting directions',
+ });
+
+ await waitFor(() => expect(submenu).toBeVisible());
+ await expect(
+ body.queryByRole('menu', { name: 'Export formats' }),
+ ).not.toBeInTheDocument();
+ await expect(
+ body.queryByRole('menu', { name: 'Import formats' }),
+ ).not.toBeInTheDocument();
+ sort.focus();
+ await userEvent.keyboard('{ArrowRight}');
+ await waitFor(() =>
+ expect(body.getByRole('menuitem', { name: 'Ascending' })).toHaveFocus(),
+ );
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(submenu).not.toBeInTheDocument());
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('menu')).not.toBeInTheDocument(),
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/__tests__/Dropdown.disabledSubmenu.test.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/__tests__/Dropdown.disabledSubmenu.test.tsx
new file mode 100644
index 00000000000..392d318c173
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/__tests__/Dropdown.disabledSubmenu.test.tsx
@@ -0,0 +1,52 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { type ReactElement } from 'react';
+
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { Dropdown } from '../Dropdown';
+
+const renderDisabledSubmenu = (owner?: ReactElement) => {
+ const onOpenChange = vi.fn();
+ const onClick = vi.fn();
+ const onTriggerRef = vi.fn();
+
+ render(
+ <Dropdown.Root type="menu">
+ <Dropdown.Submenu onOpenChange={onOpenChange}>
+ <Dropdown.SubmenuTrigger
+ disabled
+ nativeButton
+ render={owner}
+ ref={onTriggerRef}
+ onClick={onClick}
+ >
+ Unavailable actions
+ </Dropdown.SubmenuTrigger>
+ </Dropdown.Submenu>
+ </Dropdown.Root>,
+ );
+
+ return { onClick, onOpenChange, onTriggerRef };
+};
+
+describe('disabled Dropdown submenu owners', () => {
+ it.each([
+ { name: 'default button', owner: undefined },
+ { name: 'custom native button', owner: <Button /> },
+ ])('keeps $name disabled and forwards its native ref', async ({ owner }) => {
+ const user = userEvent.setup();
+ const { onClick, onOpenChange, onTriggerRef } =
+ renderDisabledSubmenu(owner);
+ const trigger = screen.getByRole('menuitem', {
+ name: 'Unavailable actions',
+ });
+
+ expect(trigger).toBeDisabled();
+ expect(onTriggerRef).toHaveBeenCalledWith(trigger);
+ await user.click(trigger);
+ await user.hover(trigger);
+ expect(onClick).not.toHaveBeenCalled();
+ expect(onOpenChange).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownActionItem.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownActionItem.tsx
index d96ca50a423..3393128f687 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownActionItem.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownActionItem.tsx
@@ -7,6 +7,8 @@ import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';
import { isDefined } from '@ui/utilities/utils/isDefined';
import styles from '../Dropdown.module.scss';
+import { DropdownItemOwner } from './DropdownItemOwner';
+import { getNativeDisabled } from './getNativeDisabled';
import { DropdownItemWithActions } from './DropdownItemWithActions';
import { type DropdownActionItemProps } from '../types/DropdownActionItemProps';
import { getDropdownItemLabel } from './getDropdownItemLabel';
@@ -92,28 +94,37 @@ export const DropdownActionItem = ({
closeTree();
}
}}
- render={(renderProps) => (
- <ListItem
- {...renderProps}
- render={render ?? <button type="button" />}
- className={clsx(
- renderProps.className,
- hasActions && styles.itemWithActionsPrimary,
- )}
- disabled={disabled}
- color={color}
- startIcon={startIcon}
- endIcon={endIcon}
- actionsVisibility={actionsVisibility}
- description={description}
- descriptionPlacement={descriptionPlacement}
- shortcut={shortcut}
- shortcutJoinLabel={shortcutJoinLabel}
- hasSubmenu={!hasActions && resolvedHasSubmenu}
- >
- {children}
- </ListItem>
- )}
+ render={(renderProps) => {
+ const nativeDisabled = getNativeDisabled({
+ nativeButton,
+ renderProps,
+ });
+
+ return (
+ <ListItem
+ {...renderProps}
+ render={
+ <DropdownItemOwner render={render} disabled={nativeDisabled} />
+ }
+ className={clsx(
+ renderProps.className,
+ hasActions && styles.itemWithActionsPrimary,
+ )}
+ disabled={disabled}
+ color={color}
+ startIcon={startIcon}
+ endIcon={endIcon}
+ actionsVisibility={actionsVisibility}
+ description={description}
+ descriptionPlacement={descriptionPlacement}
+ shortcut={shortcut}
+ shortcutJoinLabel={shortcutJoinLabel}
+ hasSubmenu={!hasActions && resolvedHasSubmenu}
+ >
+ {children}
+ </ListItem>
+ );
+ }}
/>
);
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownItemOwner.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownItemOwner.tsx
new file mode 100644
index 00000000000..57b12ecbb4a
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownItemOwner.tsx
@@ -0,0 +1,16 @@
+import { useRender } from '@base-ui/react/use-render';
+
+type DropdownItemOwnerProps = useRender.ComponentProps<'button'>;
+
+export const DropdownItemOwner = ({
+ render,
+ ref,
+ disabled,
+ ...props
+}: DropdownItemOwnerProps) =>
+ useRender({
+ render,
+ ref,
+ defaultTagName: 'button',
+ props: { ...props, disabled },
+ });
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownOptionItem.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownOptionItem.tsx
index 6bcd6e86401..77ce8434384 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownOptionItem.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownOptionItem.tsx
@@ -7,6 +7,8 @@ import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';
import { isDefined } from '@ui/utilities/utils/isDefined';
import styles from '../Dropdown.module.scss';
+import { DropdownItemOwner } from './DropdownItemOwner';
+import { getNativeDisabled } from './getNativeDisabled';
import { DropdownItemWithActions } from './DropdownItemWithActions';
import { type DropdownOptionItemProps } from '../types/DropdownOptionItemProps';
import { useDropdownContext } from './useDropdownContext';
@@ -93,31 +95,42 @@ export const DropdownOptionItem = ({
closeTree();
}
}}
- render={(renderProps) => (
- <ListItem
- {...renderProps}
- render={render ?? <button type="button" />}
- className={clsx(
- renderProps.className,
- hasActions && styles.itemWithActionsPrimary,
- )}
- disabled={disabled}
- selected={selected}
- focused={isFocused}
- indicator={isCheckIndicatorRenderedByRow ? 'none' : resolvedIndicator}
- color={color}
- startIcon={startIcon}
- endIcon={endIcon}
- actionsVisibility={actionsVisibility}
- description={description}
- descriptionPlacement={descriptionPlacement}
- shortcut={shortcut}
- shortcutJoinLabel={shortcutJoinLabel}
- hasSubmenu={!hasActions && hasSubmenu}
- >
- {children}
- </ListItem>
- )}
+ render={(renderProps) => {
+ const nativeDisabled = getNativeDisabled({
+ nativeButton,
+ renderProps,
+ });
+
+ return (
+ <ListItem
+ {...renderProps}
+ render={
+ <DropdownItemOwner render={render} disabled={nativeDisabled} />
+ }
+ className={clsx(
+ renderProps.className,
+ hasActions && styles.itemWithActionsPrimary,
+ )}
+ disabled={disabled}
+ selected={selected}
+ focused={isFocused}
+ indicator={
+ isCheckIndicatorRenderedByRow ? 'none' : resolvedIndicator
+ }
+ color={color}
+ startIcon={startIcon}
+ endIcon={endIcon}
+ actionsVisibility={actionsVisibility}
+ description={description}
+ descriptionPlacement={descriptionPlacement}
+ shortcut={shortcut}
+ shortcutJoinLabel={shortcutJoinLabel}
+ hasSubmenu={!hasActions && hasSubmenu}
+ >
+ {children}
+ </ListItem>
+ );
+ }}
/>
);
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownSubmenuTrigger.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownSubmenuTrigger.tsx
index 017a34dd4d7..483b0fe0031 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownSubmenuTrigger.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownSubmenuTrigger.tsx
@@ -7,6 +7,8 @@ import { Popover } from '@ui/primitives/surfaces/Popover/Popover';
import { isDefined } from '@ui/utilities/utils/isDefined';
import { type DropdownSubmenuTriggerProps } from '../types/DropdownSubmenuTriggerProps';
+import { DropdownItemOwner } from './DropdownItemOwner';
+import { getNativeDisabled } from './getNativeDisabled';
import { getDropdownFocusTarget } from './getDropdownFocusTarget';
import { useDropdownContext } from './useDropdownContext';
import { useDropdownItemFocus } from './useDropdownItemFocus';
@@ -97,23 +99,32 @@ export const DropdownSubmenuTrigger = ({
setOpen(true);
}
}}
- render={(renderProps) => (
- <ListItem
- {...renderProps}
- render={render ?? <button type="button" />}
- disabled={disabled}
- color={color}
- startIcon={startIcon}
- endIcon={endIcon}
- description={description}
- descriptionPlacement={descriptionPlacement}
- shortcut={shortcut}
- shortcutJoinLabel={shortcutJoinLabel}
- hasSubmenu={hasSubmenu}
- >
- {children}
- </ListItem>
- )}
+ render={(renderProps) => {
+ const nativeDisabled = getNativeDisabled({
+ nativeButton,
+ renderProps,
+ });
+
+ return (
+ <ListItem
+ {...renderProps}
+ render={
+ <DropdownItemOwner render={render} disabled={nativeDisabled} />
+ }
+ disabled={disabled}
+ color={color}
+ startIcon={startIcon}
+ endIcon={endIcon}
+ description={description}
+ descriptionPlacement={descriptionPlacement}
+ shortcut={shortcut}
+ shortcutJoinLabel={shortcutJoinLabel}
+ hasSubmenu={hasSubmenu}
+ >
+ {children}
+ </ListItem>
+ );
+ }}
/>
);
};
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/getNativeDisabled.ts b/packages/twenty-ui/src/components/navigation/Dropdown/internal/getNativeDisabled.ts
new file mode 100644
index 00000000000..5eee08c24fd
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/getNativeDisabled.ts
@@ -0,0 +1,12 @@
+import { isBoolean } from '@sniptt/guards';
+
+export const getNativeDisabled = ({
+ nativeButton,
+ renderProps,
+}: {
+ nativeButton: boolean;
+ renderProps: object;
+}) =>
+ nativeButton && 'disabled' in renderProps && isBoolean(renderProps.disabled)
+ ? renderProps.disabled
+ : undefined;
diff --git a/packages/twenty-ui/src/components/navigation/ListItemButton/ListItemButton.tsx b/packages/twenty-ui/src/components/navigation/ListItemButton/ListItemButton.tsx
new file mode 100644
index 00000000000..a2852755441
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/ListItemButton/ListItemButton.tsx
@@ -0,0 +1,48 @@
+import { Button as ButtonPrimitive } from '@base-ui/react/button';
+
+import { ListItem } from '@ui/primitives/navigation/ListItem/ListItem';
+
+import { type ListItemButtonProps } from './types/ListItemButtonProps';
+
+export const ListItemButton = ({
+ color,
+ selected,
+ focused,
+ indicator,
+ startIcon,
+ endIcon,
+ description,
+ descriptionPlacement,
+ shortcut,
+ shortcutJoinLabel,
+ hasSubmenu,
+ disabled = false,
+ type = 'button',
+ children,
+ ...buttonProps
+}: ListItemButtonProps) => (
+ <ListItem
+ color={color}
+ selected={selected}
+ focused={focused}
+ indicator={indicator}
+ startIcon={startIcon}
+ endIcon={endIcon}
+ description={description}
+ descriptionPlacement={descriptionPlacement}
+ shortcut={shortcut}
+ shortcutJoinLabel={shortcutJoinLabel}
+ hasSubmenu={hasSubmenu}
+ disabled={disabled}
+ render={
+ <ButtonPrimitive
+ {...buttonProps}
+ nativeButton
+ type={type}
+ disabled={disabled}
+ />
+ }
+ >
+ {children}
+ </ListItem>
+);
diff --git a/packages/twenty-ui/src/components/navigation/ListItemButton/__stories__/ListItemButton.stories.tsx b/packages/twenty-ui/src/components/navigation/ListItemButton/__stories__/ListItemButton.stories.tsx
new file mode 100644
index 00000000000..3c1d56a7f4a
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/ListItemButton/__stories__/ListItemButton.stories.tsx
@@ -0,0 +1,61 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { ListItemButton } from '@ui/components/navigation/ListItemButton/ListItemButton';
+import { IconCopy, IconUser } from '@ui/icon';
+import { Button } from '@ui/primitives/input/Button/Button';
+import { ComponentDecorator } from '@ui/testing';
+
+const ROW_STYLE = { width: 280 };
+const SIBLING_STYLE = { display: 'flex', alignItems: 'center', gap: 8 };
+
+const meta: Meta<typeof ListItemButton> = {
+ id: 'ui-components-listitembutton',
+ title: 'UI/Components/Navigation/ListItemButton',
+ component: ListItemButton,
+ decorators: [ComponentDecorator],
+ args: {
+ children: 'Duplicate',
+ startIcon: <IconCopy />,
+ description: 'Create a copy',
+ style: ROW_STYLE,
+ },
+ argTypes: {
+ startIcon: { control: false },
+ endIcon: { control: false },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof ListItemButton>;
+
+export const Default: Story = {};
+
+export const Disabled: Story = {
+ args: { disabled: true },
+};
+
+export const Selected: Story = {
+ args: {
+ children: 'Show archived records',
+ description: undefined,
+ startIcon: undefined,
+ selected: true,
+ 'aria-pressed': true,
+ indicator: 'check',
+ },
+};
+
+export const IndependentAction: Story = {
+ args: {
+ children: 'Alex Morgan',
+ startIcon: <IconUser />,
+ description: 'Account owner',
+ },
+ render: (args) => (
+ <div style={SIBLING_STYLE}>
+ <ListItemButton {...args} />
+ <Button size="sm" variant="ghost" aria-label="Open Alex Morgan's details">
+ Details
+ </Button>
+ </div>
+ ),
+};
diff --git a/packages/twenty-ui/src/components/navigation/ListItemButton/__stories__/ListItemButtonInteractions.stories.tsx b/packages/twenty-ui/src/components/navigation/ListItemButton/__stories__/ListItemButtonInteractions.stories.tsx
new file mode 100644
index 00000000000..c86be26d4f5
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/ListItemButton/__stories__/ListItemButtonInteractions.stories.tsx
@@ -0,0 +1,116 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { ListItemButton } from '@ui/components/navigation/ListItemButton/ListItemButton';
+import { Button } from '@ui/primitives/input/Button/Button';
+import { ComponentDecorator } from '@ui/testing';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+import { expect, fn, userEvent, within } from 'storybook/test';
+
+const bubbledClicks = fn();
+const detailClicks = fn();
+const ROW_STYLE = { width: 280 };
+const SIBLING_STYLE = { display: 'flex', alignItems: 'center', gap: 8 };
+
+const meta: Meta<typeof ListItemButton> = {
+ id: 'ui-components-listitembutton-interactions',
+ title: 'UI/Components/Navigation/ListItemButton/Interactions',
+ component: ListItemButton,
+ decorators: [ComponentDecorator],
+ tags: ['!autodocs'],
+ args: { children: 'Open record', onClick: fn(), style: ROW_STYLE },
+};
+
+export default meta;
+type Story = StoryObj<typeof ListItemButton>;
+
+export const NativeActivation: Story = {
+ render: (args) => (
+ <div role="presentation" onClick={bubbledClicks}>
+ <ListItemButton
+ {...args}
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ onClick={(event) => {
+ event.currentTarget.dataset.clickTarget = event.currentTarget.tagName;
+ args.onClick?.(event);
+ }}
+ onFocus={(event) => {
+ event.currentTarget.dataset.focusTarget = event.currentTarget.tagName;
+ }}
+ />
+ </div>
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const button = canvas.getByRole('button', { name: 'Open record' });
+ bubbledClicks.mockClear();
+
+ expect(button.tagName).toBe('BUTTON');
+ expect(button).toHaveAttribute('type', 'button');
+ expect(button).toHaveAttribute('data-ref-tag', 'BUTTON');
+ await userEvent.click(button);
+ expect(button).toHaveFocus();
+ expect(button).toHaveAttribute('data-click-target', 'BUTTON');
+ expect(button).toHaveAttribute('data-focus-target', 'BUTTON');
+ await userEvent.keyboard('{Enter} ');
+ expect(args.onClick).toHaveBeenCalledTimes(3);
+ expect(bubbledClicks).toHaveBeenCalledTimes(3);
+ },
+};
+
+export const DisabledBehavior: Story = {
+ render: (args) => (
+ <>
+ <ListItemButton {...args} disabled>
+ Unavailable record
+ </ListItemButton>
+ <ListItemButton {...args} disabled focusableWhenDisabled>
+ Focusable unavailable record
+ </ListItemButton>
+ <Button>Next action</Button>
+ </>
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const disabled = canvas.getByRole('button', { name: 'Unavailable record' });
+ const focusable = canvas.getByRole('button', {
+ name: 'Focusable unavailable record',
+ });
+
+ expect(disabled).toBeDisabled();
+ disabled.focus();
+ expect(disabled).not.toHaveFocus();
+ await userEvent.click(disabled);
+ expect(focusable).not.toBeDisabled();
+ expect(focusable).toHaveAttribute('aria-disabled', 'true');
+ focusable.focus();
+ expect(focusable).toHaveFocus();
+ await userEvent.keyboard('{Enter} ');
+ await userEvent.click(focusable);
+ expect(args.onClick).not.toHaveBeenCalled();
+ },
+};
+
+export const IndependentAction: Story = {
+ render: (args) => (
+ <div style={SIBLING_STYLE}>
+ <ListItemButton {...args} />
+ <Button onClick={detailClicks}>Details</Button>
+ </div>
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const row = canvas.getByRole('button', { name: 'Open record' });
+ const details = canvas.getByRole('button', { name: 'Details' });
+ detailClicks.mockClear();
+
+ expect(row.contains(details)).toBe(false);
+ await userEvent.click(details);
+ await userEvent.keyboard('{Enter} ');
+ expect(details).toHaveFocus();
+ expect(detailClicks).toHaveBeenCalledTimes(3);
+ expect(args.onClick).not.toHaveBeenCalled();
+ },
+};
diff --git a/packages/twenty-ui/src/components/navigation/ListItemButton/__tests__/ListItemButton.test.tsx b/packages/twenty-ui/src/components/navigation/ListItemButton/__tests__/ListItemButton.test.tsx
new file mode 100644
index 00000000000..7b12b7fa9ae
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/ListItemButton/__tests__/ListItemButton.test.tsx
@@ -0,0 +1,111 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { createRef } from 'react';
+
+import { ListItemButton } from '../ListItemButton';
+
+describe('ListItemButton', () => {
+ it('activates with pointer, Enter and Space without submitting its form', async () => {
+ const user = userEvent.setup();
+ const onClick = vi.fn();
+ const onSubmit = vi.fn();
+
+ render(
+ <form
+ onSubmit={(event) => {
+ event.preventDefault();
+ onSubmit();
+ }}
+ >
+ <ListItemButton onClick={onClick}>Duplicate</ListItemButton>
+ </form>,
+ );
+
+ await user.click(screen.getByRole('button', { name: 'Duplicate' }));
+ await user.keyboard('{Enter} ');
+
+ expect(onClick).toHaveBeenCalledTimes(3);
+ expect(onSubmit).not.toHaveBeenCalled();
+ });
+
+ it('disables interaction and skips the row in the tab order', async () => {
+ const user = userEvent.setup();
+ const onClick = vi.fn();
+
+ render(
+ <>
+ <ListItemButton disabled onClick={onClick}>
+ Unavailable action
+ </ListItemButton>
+ <ListItemButton>Available action</ListItemButton>
+ </>,
+ );
+
+ const unavailable = screen.getByRole('button', {
+ name: 'Unavailable action',
+ });
+
+ expect(unavailable).toBeDisabled();
+ expect(unavailable).toHaveAttribute('data-disabled');
+ await user.click(unavailable);
+ await user.tab();
+ expect(
+ screen.getByRole('button', { name: 'Available action' }),
+ ).toHaveFocus();
+ expect(onClick).not.toHaveBeenCalled();
+ });
+
+ it('forwards the button ref and native events while preserving bubbling', async () => {
+ const user = userEvent.setup();
+ const buttonRef = createRef<HTMLButtonElement>();
+ const onParentClick = vi.fn();
+ const onClick = vi.fn();
+
+ const { container } = render(
+ <ListItemButton
+ ref={buttonRef}
+ name="duplicate"
+ onClick={(event) => {
+ expect(event.currentTarget).toBe(buttonRef.current);
+ expect(event.defaultPrevented).toBe(false);
+ onClick();
+ }}
+ >
+ Duplicate
+ </ListItemButton>,
+ );
+ container.addEventListener('click', onParentClick);
+
+ const button = screen.getByRole('button', { name: 'Duplicate' });
+
+ expect(buttonRef.current).toBe(button);
+ expect(button).toHaveAttribute('name', 'duplicate');
+ await user.click(button);
+ expect(onClick).toHaveBeenCalledOnce();
+ expect(onParentClick).toHaveBeenCalledOnce();
+ });
+
+ it('keeps focusable disabled rows reachable without activating them', async () => {
+ const user = userEvent.setup();
+ const onClick = vi.fn();
+
+ render(
+ <ListItemButton disabled focusableWhenDisabled onClick={onClick}>
+ Unavailable action
+ </ListItemButton>,
+ );
+
+ const button = screen.getByRole('button', {
+ name: 'Unavailable action',
+ });
+
+ expect(button).not.toBeDisabled();
+ expect(button).toHaveAttribute('aria-disabled', 'true');
+ expect(button).toHaveAttribute('data-disabled');
+ await user.tab();
+ expect(button).toHaveFocus();
+ await user.keyboard('{Enter} ');
+ await user.click(button);
+ expect(onClick).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/twenty-ui/src/components/navigation/ListItemButton/types/ListItemButtonProps.ts b/packages/twenty-ui/src/components/navigation/ListItemButton/types/ListItemButtonProps.ts
new file mode 100644
index 00000000000..4801ea3c9cb
--- /dev/null
+++ b/packages/twenty-ui/src/components/navigation/ListItemButton/types/ListItemButtonProps.ts
@@ -0,0 +1,24 @@
+import { type Button as ButtonPrimitive } from '@base-ui/react/button';
+import { type ComponentPropsWithRef } from 'react';
+
+import { type ListItemProps } from '@ui/primitives/navigation/ListItem/types/ListItemProps';
+
+export type ListItemButtonProps = Omit<
+ ComponentPropsWithRef<'button'>,
+ 'color'
+> &
+ Pick<ButtonPrimitive.Props, 'focusableWhenDisabled'> &
+ Pick<
+ ListItemProps,
+ | 'color'
+ | 'selected'
+ | 'focused'
+ | 'indicator'
+ | 'startIcon'
+ | 'endIcon'
+ | 'description'
+ | 'descriptionPlacement'
+ | 'shortcut'
+ | 'shortcutJoinLabel'
+ | 'hasSubmenu'
+ >;
diff --git a/packages/twenty-ui/src/components/navigation/index.ts b/packages/twenty-ui/src/components/navigation/index.ts
index 0be1b55759e..7aad557b232 100644
--- a/packages/twenty-ui/src/components/navigation/index.ts
+++ b/packages/twenty-ui/src/components/navigation/index.ts
@@ -24,6 +24,8 @@ export type { DropdownSubmenuTriggerProps } from './Dropdown/types/DropdownSubme
export type { DropdownTitleProps } from './Dropdown/types/DropdownTitleProps';
export type { DropdownTriggerProps } from './Dropdown/types/DropdownTriggerProps';
export type { DropdownType } from './Dropdown/types/DropdownType';
+export { ListItemButton } from './ListItemButton/ListItemButton';
+export type { ListItemButtonProps } from './ListItemButton/types/ListItemButtonProps';
export { DEFAULT_COLOR_LABELS } from './MenuItem/constants/DefaultColorLabels';
export { MenuItem } from './MenuItem/MenuItem';
export type { ColorLabels } from './MenuItem/types/ColorLabels';
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
index d38741f7111..61104bb9c76 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.module.scss
@@ -1,5 +1,6 @@
.root {
--tw-list-item-color: var(--t-font-color-secondary);
+ --tw-list-item-description-color: var(--t-font-color-secondary);
--tw-list-item-background: transparent;
--tw-list-item-hover-background: var(--t-background-transparent-light);
@@ -46,6 +47,7 @@
&[data-disabled] {
--tw-list-item-color: var(--t-font-color-tertiary);
+ --tw-list-item-description-color: var(--t-font-color-light);
--tw-list-item-hover-background: transparent;
cursor: default;
@@ -95,7 +97,7 @@
}
.description {
- color: var(--t-font-color-light);
+ color: var(--tw-list-item-description-color);
min-inline-size: 0;
overflow: hidden;
text-overflow: ellipsis;
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
index 664954c3ebd..f5353e6b994 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
@@ -1,7 +1,6 @@
import { useRender } from '@base-ui/react/use-render';
import { isString } from '@sniptt/guards';
import { clsx } from 'clsx';
-import { type MouseEvent } from 'react';
import { IconCheck, IconChevronRight } from '@ui/icon';
import { Shortcut } from '@ui/primitives/typography/Shortcut/Shortcut';
@@ -32,25 +31,10 @@ export const ListItem = ({
children,
render,
ref,
- onClick,
...props
}: ListItemProps) => {
const hasDescription = isRenderableSlot(description);
- const handleClick = (event: MouseEvent<HTMLDivElement>) => {
- if (disabled) {
- event.preventDefault();
- return;
- }
-
- if (!isDefined(onClick)) {
- return;
- }
-
- event.stopPropagation();
- onClick(event);
- };
-
return useRender({
render,
ref,
@@ -59,8 +43,6 @@ export const ListItem = ({
...props,
'data-actions-visibility': actionsVisibility,
className: clsx(styles.root, className),
- 'aria-disabled': disabled || undefined,
- onClick: handleClick,
children: (
<>
{indicator === 'checkbox' && (
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItem.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItem.stories.tsx
index ac935e930b8..fcf0bc6be50 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItem.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItem.stories.tsx
@@ -1,6 +1,5 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { action } from 'storybook/actions';
-import { expect, userEvent, within } from 'storybook/test';
import {
A11Y_DEFER_COLOR_CONTRAST,
@@ -10,12 +9,20 @@ import {
} from '@ui/testing';
import { Button } from '@ui/primitives/input/Button/Button';
-import { IconBell, IconEdit, IconSettings, IconTrash } from '@ui/icon';
+import {
+ IconBell,
+ IconCopy,
+ IconEdit,
+ IconSettings,
+ IconTrash,
+} from '@ui/icon';
import { ListItem } from '@ui/primitives/navigation/ListItem/ListItem';
import { type ListItemColor } from '@ui/primitives/navigation/ListItem/types/ListItemColor';
import { type ListItemIndicator } from '@ui/primitives/navigation/ListItem/types/ListItemIndicator';
import { type ListItemProps } from '@ui/primitives/navigation/ListItem/types/ListItemProps';
+import { ListItemMenuExample } from './ListItemMenuExample';
+
const meta: Meta<typeof ListItem> = {
title: 'UI/Navigation/ListItem',
component: ListItem,
@@ -57,17 +64,6 @@ export const OverflowingLabel: Story = {
decorators: [ComponentDecorator],
parameters: { container: { width: 160 } },
args: { children: 'A workspace preference with a long label' },
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
- const page = within(canvasElement.ownerDocument.body);
- const label = canvas.getByText('A workspace preference with a long label');
-
- await userEvent.hover(label);
-
- expect(await page.findByRole('tooltip')).toHaveTextContent(
- 'A workspace preference with a long label',
- );
- },
};
export const WithDescription: Story = {
@@ -88,14 +84,44 @@ export const WithActions: Story = {
export const WithPersistentActions: Story = {
...WithActions,
args: { ...WithActions.args, actionsVisibility: 'always' },
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
+};
- expect(canvas.getByRole('button', { name: 'Edit' })).toBeVisible();
- expect(canvas.getByRole('button', { name: 'Delete' })).toBeVisible();
+export const ButtonOwner: Story = {
+ ...Default,
+ args: {
+ children: 'Duplicate record',
+ render: <button type="button" />,
+ startIcon: <IconCopy />,
},
};
+export const LinkOwner: Story = {
+ ...Default,
+ args: {
+ children: 'Typography documentation',
+ render: (renderProps) => (
+ <a {...renderProps} href="https://twenty.com/developers">
+ {renderProps.children}
+ </a>
+ ),
+ },
+};
+
+export const ExplicitLinkContent: Story = {
+ ...Default,
+ parameters: { ...Default.parameters, a11y: A11Y_DEFER_COLOR_CONTRAST },
+ args: {
+ children: <a href="https://twenty.com/developers">Read documentation</a>,
+ description: 'Resource',
+ },
+};
+
+export const MenuOwner: Story = {
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 240, height: 200 } },
+ render: () => <ListItemMenuExample />,
+};
+
export const WithCheckbox: Story = {
decorators: [ComponentDecorator],
parameters: { container: { width: 240 } },
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemInteractions.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemInteractions.stories.tsx
index 2b9cf8c9a4c..8b720172579 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemInteractions.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemInteractions.stories.tsx
@@ -1,13 +1,17 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { useState } from 'react';
-import { expect, fn, userEvent, within } from 'storybook/test';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import { IconEdit, IconTrash } from '@ui/icon';
+import { Button } from '@ui/primitives/input/Button/Button';
import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
import { ListItem } from '../ListItem';
import styles from '../ListItem.module.scss';
import { type ListItemProps } from '../types/ListItemProps';
+import { ListItemMenuExample } from './ListItemMenuExample';
+
const SelectableListItemExample = (props: ListItemProps) => {
const [selected, setSelected] = useState(false);
@@ -19,7 +23,12 @@ const SelectableListItemExample = (props: ListItemProps) => {
color={selected ? 'danger' : 'neutral'}
onClick={() => setSelected(!selected)}
render={(renderProps, state) => (
- <div {...renderProps} data-render-highlighted={state.highlighted} />
+ <button
+ {...renderProps}
+ type="button"
+ aria-pressed={selected}
+ data-render-highlighted={state.highlighted}
+ />
)}
/>
);
@@ -31,10 +40,11 @@ const ActionListItemExample = (props: ListItemProps) => {
return (
<ListItem
{...props}
+ data-testid="list-item"
actions={
- <button type="button" onClick={() => setDeleted(true)}>
+ <Button variant="ghost" size="sm" onClick={() => setDeleted(true)}>
Delete
- </button>
+ </Button>
}
>
{deleted ? 'Deleted' : 'Item'}
@@ -46,87 +56,116 @@ const meta: Meta<typeof ListItem> = {
title: 'UI/Navigation/ListItem/Interactions',
component: ListItem,
tags: ['!autodocs'],
- decorators: [
- ComponentDecorator,
- (Story) => (
- <div role="list">
- <Story />
- </div>
- ),
- ],
+ decorators: [ComponentDecorator],
parameters: { container: { width: 320 } },
args: {
children: 'Item',
onClick: fn(),
- role: 'listitem',
- 'aria-label': 'Item',
},
+ render: (args) => <ListItem {...args} data-testid="list-item" />,
};
export default meta;
type Story = StoryObj<typeof ListItem>;
+export const PresentationalRow: Story = {
+ args: { selected: true, focused: true },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const item = canvas.getByTestId('list-item');
+
+ await expect(item.tagName).toBe('DIV');
+ await expect(item).not.toHaveAttribute('role');
+ await expect(item).not.toHaveAttribute('tabindex');
+ await expect(item).toHaveAttribute('data-selected');
+ await expect(item).toHaveAttribute('data-highlighted');
+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();
+ await userEvent.tab();
+ await expect(item).not.toHaveFocus();
+ },
+};
+
export const ClickPropagation: Story = {
+ args: { ref: fn(), onPointerDown: fn() },
play: async ({ canvasElement, args }) => {
+ const item = within(canvasElement).getByTestId('list-item');
const onAncestorClick = fn();
- canvasElement.addEventListener('click', onAncestorClick);
+ const ancestor = canvasElement.ownerDocument.body;
+ ancestor.addEventListener('click', onAncestorClick);
try {
- await userEvent.click(
- within(canvasElement).getByRole('listitem', { name: 'Item' }),
- );
+ await userEvent.click(item);
- await expect(args.onClick).toHaveBeenCalledTimes(1);
+ await expect(args.ref).toHaveBeenCalledWith(item);
+ await expect(args.onPointerDown).toHaveBeenCalledWith(
+ expect.objectContaining({ type: 'pointerdown', pointerType: 'mouse' }),
+ );
await expect(args.onClick).toHaveBeenCalledWith(
- expect.objectContaining({ defaultPrevented: false }),
+ expect.objectContaining({
+ type: 'click',
+ bubbles: true,
+ defaultPrevented: false,
+ target: item,
+ }),
);
await expect(onAncestorClick).toHaveBeenCalledTimes(1);
} finally {
- canvasElement.removeEventListener('click', onAncestorClick);
+ ancestor.removeEventListener('click', onAncestorClick);
}
},
};
-export const Disabled: Story = {
+export const CallerPropagationPolicy: Story = {
+ args: {
+ onClick: fn<NonNullable<ListItemProps['onClick']>>((event) =>
+ event.stopPropagation(),
+ ),
+ },
+ play: async ({ canvasElement, args }) => {
+ const onAncestorClick = fn();
+ const ancestor = canvasElement.ownerDocument.body;
+ ancestor.addEventListener('click', onAncestorClick);
+
+ try {
+ await userEvent.click(within(canvasElement).getByTestId('list-item'));
+
+ await expect(args.onClick).toHaveBeenCalledTimes(1);
+ await expect(onAncestorClick).not.toHaveBeenCalled();
+ } finally {
+ ancestor.removeEventListener('click', onAncestorClick);
+ }
+ },
+};
+
+export const DisabledAppearance: Story = {
+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
args: { disabled: true },
play: async ({ canvasElement, args }) => {
- const item = within(canvasElement).getByRole('listitem', { name: 'Item' });
+ const item = within(canvasElement).getByTestId('list-item');
await userEvent.click(item);
- await expect(args.onClick).not.toHaveBeenCalled();
- await expect(item).toHaveAttribute('aria-disabled', 'true');
+ await expect(args.onClick).toHaveBeenCalledTimes(1);
+ await expect(item).not.toHaveAttribute('aria-disabled');
await expect(item).toHaveAttribute('data-disabled');
},
};
-export const DisabledLink: Story = {
+export const DisabledButtonOwner: Story = {
args: {
disabled: true,
- role: 'link',
- render: <a href="#target" aria-label="Item link" />,
- },
- render: (args) => (
- <div role="listitem">
- <ListItem {...args} />
- </div>
- ),
+ render: <button type="button" disabled />,
+ ref: fn(),
+ },
play: async ({ canvasElement, args }) => {
- const item = within(canvasElement).getByRole('link');
- const onAncestorClick = fn();
- canvasElement.addEventListener('click', onAncestorClick);
-
- try {
- await userEvent.click(item);
+ const item = within(canvasElement).getByRole('button', { name: 'Item' });
- await expect(item).toHaveAttribute('href', '#target');
- await expect(args.onClick).not.toHaveBeenCalled();
- await expect(onAncestorClick).toHaveBeenCalledWith(
- expect.objectContaining({ defaultPrevented: true }),
- );
- } finally {
- canvasElement.removeEventListener('click', onAncestorClick);
- }
+ await expect(args.ref).toHaveBeenCalledWith(item);
+ await expect(item).toBeDisabled();
+ await userEvent.click(item);
+ await userEvent.tab();
+ await expect(item).not.toHaveFocus();
+ await expect(args.onClick).not.toHaveBeenCalled();
},
};
@@ -134,9 +173,9 @@ export const ActionPropagation: Story = {
render: (args) => <ActionListItemExample {...args} />,
play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);
- const action = canvas.getByRole('button', { name: 'Delete', hidden: true });
+ const action = canvas.getByRole('button', { name: 'Delete' });
- await userEvent.hover(canvas.getByRole('listitem', { name: 'Item' }));
+ await userEvent.hover(canvas.getByTestId('list-item'));
await userEvent.click(action);
await expect(canvas.getByText('Deleted')).toBeVisible();
@@ -149,7 +188,7 @@ export const SelectionAndRenderState: Story = {
args: { indicator: 'check' },
render: (args) => <SelectableListItemExample {...args} />,
play: async ({ canvasElement }) => {
- const item = within(canvasElement).getByRole('listitem', { name: 'Item' });
+ const item = within(canvasElement).getByRole('button', { name: 'Item' });
await expect(item).not.toHaveAttribute('data-selected');
await expect(item).not.toHaveAttribute('data-highlighted');
@@ -160,6 +199,7 @@ export const SelectionAndRenderState: Story = {
await userEvent.click(item);
+ await expect(item).toHaveAttribute('aria-pressed', 'true');
await expect(item).toHaveAttribute('data-selected');
await expect(item).toHaveAttribute('data-highlighted');
await expect(item).toHaveAttribute('data-render-highlighted', 'true');
@@ -174,25 +214,26 @@ export const DecorativeCheckbox: Story = {
render: (args) => <SelectableListItemExample {...args} />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const item = canvas.getByRole('listitem', { name: 'Item' });
+ const item = canvas.getByRole('button', { name: 'Item' });
await expect(canvas.queryByRole('checkbox')).toBeNull();
await expect(item.querySelector('[data-checked]')).toBeNull();
await userEvent.click(item);
+ await expect(item).toHaveAttribute('aria-pressed', 'true');
await expect(canvas.queryByRole('checkbox')).toBeNull();
await expect(item.querySelector('[data-checked]')).not.toBeNull();
},
};
-export const NavigationRow: Story = {
- args: { role: 'button', hasSubmenu: true },
- render: (args) => (
- <div role="listitem">
- <ListItem {...args} render={<button type="button" />} />
- </div>
- ),
+export const ButtonOwner: Story = {
+ args: {
+ hasSubmenu: true,
+ ref: fn(),
+ onFocus: fn(),
+ render: <button type="button" />,
+ },
play: async ({ canvasElement, args }) => {
const row = within(canvasElement).getByRole('button', { name: 'Item' });
@@ -200,8 +241,154 @@ export const NavigationRow: Story = {
await userEvent.keyboard('{Enter}');
await userEvent.keyboard(' ');
+ await expect(args.ref).toHaveBeenCalledWith(row);
+ await expect(args.onFocus).toHaveBeenCalledOnce();
await expect(args.onClick).toHaveBeenCalledTimes(2);
await expect(row).toHaveFocus();
await expect(row.getBoundingClientRect().height).toBe(32);
},
};
+
+export const LinkOwner: Story = {
+ args: {
+ children: 'https://twenty.com/developers',
+ render: (renderProps) => (
+ <a {...renderProps} href="#list-item-destination">
+ {renderProps.children}
+ </a>
+ ),
+ ref: fn(),
+ onClick: fn<NonNullable<ListItemProps['onClick']>>((event) =>
+ event.preventDefault(),
+ ),
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const link = canvas.getByRole('link', {
+ name: 'https://twenty.com/developers',
+ });
+
+ await expect(canvas.getAllByRole('link')).toHaveLength(1);
+ await expect(link.tagName).toBe('A');
+ await expect(link).toHaveAttribute('href', '#list-item-destination');
+ await expect(args.ref).toHaveBeenCalledWith(link);
+ link.focus();
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onClick).toHaveBeenCalledWith(
+ expect.objectContaining({ type: 'click', defaultPrevented: true }),
+ );
+ await expect(link).toHaveFocus();
+ },
+};
+
+export const PlainUrlLabel: Story = {
+ args: { children: 'https://twenty.com/developers' },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(
+ canvas.getByText('https://twenty.com/developers'),
+ ).toBeVisible();
+ await expect(canvas.queryByRole('link')).not.toBeInTheDocument();
+ },
+};
+
+export const ExplicitLinkContent: Story = {
+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
+ args: {
+ children: <a href="#list-item-resource">Read documentation</a>,
+ description: 'Resource',
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(canvas.getAllByRole('link')).toHaveLength(1);
+ await expect(
+ canvas.getByRole('link', { name: 'Read documentation' }),
+ ).toHaveAttribute('href', '#list-item-resource');
+ await expect(canvas.getByText('Resource')).toBeVisible();
+ },
+};
+
+export const OverflowingLabel: Story = {
+ parameters: { container: { width: 160 } },
+ args: { children: 'A workspace preference with a long label' },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ const label = canvas.getByText('A workspace preference with a long label');
+
+ await userEvent.hover(label);
+
+ await expect(await page.findByRole('tooltip')).toHaveTextContent(
+ 'A workspace preference with a long label',
+ );
+ },
+};
+
+export const PersistentActions: Story = {
+ args: {
+ actionsVisibility: 'always',
+ actions: (
+ <>
+ <Button
+ aria-label="Edit"
+ variant="ghost"
+ size="sm"
+ startIcon={<IconEdit />}
+ />
+ <Button
+ aria-label="Delete"
+ variant="ghost"
+ size="sm"
+ startIcon={<IconTrash />}
+ />
+ </>
+ ),
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(canvas.getByRole('button', { name: 'Edit' })).toBeVisible();
+ await expect(canvas.getByRole('button', { name: 'Delete' })).toBeVisible();
+ },
+};
+
+export const MenuOwner: Story = {
+ parameters: { container: { width: 240, height: 200 } },
+ render: (args) => <ListItemMenuExample onClick={args.onClick} />,
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ const trigger = canvas.getByRole('button', { name: 'Record actions' });
+
+ await userEvent.click(trigger);
+ const menu = await page.findByRole('menu', { name: 'Record actions' });
+ await waitFor(() => expect(menu).toBeVisible());
+ const duplicate = within(menu).getByRole('menuitem', {
+ name: 'Duplicate record',
+ });
+ const unavailable = within(menu).getByRole('menuitem', {
+ name: 'Unavailable action',
+ });
+ const exported = within(menu).getByRole('menuitem', {
+ name: 'Export record',
+ });
+
+ await expect(unavailable).toHaveAttribute('aria-disabled', 'true');
+ duplicate.focus();
+ await userEvent.keyboard('{ArrowDown}');
+ await expect(unavailable).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onClick).not.toHaveBeenCalled();
+ await expect(menu).toBeVisible();
+ await userEvent.keyboard('{ArrowDown}');
+ await expect(exported).toHaveFocus();
+ await userEvent.keyboard('{ArrowUp}{ArrowUp}{Enter}');
+ await expect(args.onClick).toHaveBeenCalledOnce();
+ await waitFor(() =>
+ expect(page.queryByRole('menu')).not.toBeInTheDocument(),
+ );
+ await expect(trigger).toHaveFocus();
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMenuExample.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMenuExample.tsx
new file mode 100644
index 00000000000..c8f2f0a05ba
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMenuExample.tsx
@@ -0,0 +1,20 @@
+import { Button } from '@ui/primitives/input/Button/Button';
+import { type ListItemProps } from '@ui/primitives/navigation/ListItem/types/ListItemProps';
+import { Menu } from '@ui/primitives/surfaces/Menu/Menu';
+
+type ListItemMenuExampleProps = {
+ onClick?: ListItemProps['onClick'];
+};
+
+export const ListItemMenuExample = ({ onClick }: ListItemMenuExampleProps) => (
+ <Menu.Root>
+ <Menu.Trigger render={<Button>Record actions</Button>} />
+ <Menu.Popup>
+ <Menu.Item onClick={onClick}>Duplicate record</Menu.Item>
+ <Menu.Item disabled onClick={onClick}>
+ Unavailable action
+ </Menu.Item>
+ <Menu.Item>Export record</Menu.Item>
+ </Menu.Popup>
+ </Menu.Root>
+);
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__tests__/ListItem.test.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__tests__/ListItem.test.tsx
index ce07d6f9adc..c2dd85964c0 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__tests__/ListItem.test.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__tests__/ListItem.test.tsx
@@ -1,5 +1,6 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
+import { createRef, type FormEvent, type MouseEvent } from 'react';
import { describe, expect, it, vi } from 'vitest';
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
@@ -14,56 +15,193 @@ runComponentConformance({
ownClassName: styles.root,
});
-describe('ListItem clicks', () => {
- it('consumes the click when the row owns an action', async () => {
+describe('ListItem interaction ownership', () => {
+ it('forwards the native click and lets the caller choose propagation', async () => {
const user = userEvent.setup();
const onParentClick = vi.fn();
const onAction = vi.fn();
+ let receivedTarget: EventTarget | null = null;
+ let receivedEvent: MouseEvent<HTMLElement> | undefined;
render(
- <a href="#parent" onClick={onParentClick}>
- <ListItem onClick={onAction}>Archive</ListItem>
- </a>,
+ <button type="button" onClick={onParentClick}>
+ <ListItem
+ render={<span />}
+ onClick={(event) => {
+ receivedTarget = event.currentTarget;
+ receivedEvent = event;
+ onAction();
+ }}
+ >
+ Archive
+ </ListItem>
+ <ListItem
+ render={<span />}
+ onClick={(event) => event.stopPropagation()}
+ >
+ Local action
+ </ListItem>
+ </button>,
);
- await user.click(screen.getByText('Archive'));
+ const archive = screen.getByText('Archive');
+ await user.click(archive);
expect(onAction).toHaveBeenCalledTimes(1);
- expect(onParentClick).not.toHaveBeenCalled();
+ expect(onParentClick).toHaveBeenCalledTimes(1);
+ expect(receivedTarget).toContainElement(archive);
+ expect(receivedEvent?.nativeEvent).toBeInstanceOf(window.MouseEvent);
+ expect(receivedEvent?.defaultPrevented).toBe(false);
+ expect(receivedEvent?.isPropagationStopped()).toBe(false);
+
+ await user.click(screen.getByText('Local action'));
+
+ expect(onParentClick).toHaveBeenCalledTimes(1);
});
- it('lets a row without an action activate its containing trigger', async () => {
+ it('keeps visual state independent of interaction and accessibility semantics', async () => {
const user = userEvent.setup();
- const onTriggerClick = vi.fn();
+ const onAction = vi.fn();
+ const ref = createRef<HTMLDivElement>();
render(
- <a href="#parent" onClick={onTriggerClick}>
- <ListItem>Open menu</ListItem>
- </a>,
+ <ListItem
+ disabled
+ focused
+ selected
+ indicator="checkbox"
+ ref={ref}
+ onClick={onAction}
+ >
+ Delete
+ </ListItem>,
);
- await user.click(screen.getByText('Open menu'));
+ expect(ref.current).not.toHaveAttribute('role');
+ expect(ref.current).not.toHaveAttribute('tabindex');
+ expect(ref.current).not.toHaveAttribute('aria-disabled');
+ expect(ref.current).not.toHaveAttribute('aria-selected');
+ expect(ref.current).toHaveAttribute('data-disabled');
+ expect(ref.current).toHaveAttribute('data-highlighted');
+ expect(ref.current).toHaveAttribute('data-selected');
+ expect(screen.queryByRole('checkbox')).not.toBeInTheDocument();
- expect(onTriggerClick).toHaveBeenCalledTimes(1);
+ await user.click(screen.getByText('Delete'));
+ expect(onAction).toHaveBeenCalledTimes(1);
+
+ await user.tab();
+ expect(ref.current).not.toHaveFocus();
});
- it('keeps disabled rows inactive without consuming the click', async () => {
+ it('targets the native button owner and retains form, focus and keyboard events', async () => {
const user = userEvent.setup();
- const onParentClick = vi.fn();
+ const ref = createRef<HTMLButtonElement>();
+ const ownerRef = createRef<HTMLButtonElement>();
const onAction = vi.fn();
+ const onOwnerClick = vi.fn();
+ const onFocus = vi.fn();
+ const onKeyDown = vi.fn();
+ const onSubmit = vi.fn((event: FormEvent<HTMLFormElement>) =>
+ event.preventDefault(),
+ );
render(
- <a href="#parent" onClick={onParentClick}>
- <ListItem disabled onClick={onAction}>
+ <form onSubmit={onSubmit}>
+ <ListItem
+ render={
+ <button
+ type="submit"
+ name="action"
+ value="archive"
+ ref={ownerRef}
+ onClick={onOwnerClick}
+ />
+ }
+ ref={ref}
+ onClick={onAction}
+ onFocus={onFocus}
+ onKeyDown={onKeyDown}
+ >
+ Archive
+ </ListItem>
+ <ListItem
+ disabled
+ render={<button type="button" disabled />}
+ onClick={onAction}
+ >
Delete
</ListItem>
- </a>,
+ </form>,
);
- await user.click(screen.getByText('Delete'));
+ const button = screen.getByRole('button', { name: 'Archive' });
+ expect(ref.current).toBe(button);
+ expect(ownerRef.current).toBe(button);
+ expect(button).toHaveAttribute('name', 'action');
+ expect(button).toHaveAttribute('value', 'archive');
+
+ await user.tab();
+ expect(button).toHaveFocus();
+ expect(onFocus).toHaveBeenCalledTimes(1);
+ await user.keyboard('{Enter}');
+ await user.keyboard(' ');
+ expect(onAction).toHaveBeenCalledTimes(2);
+ expect(onOwnerClick).toHaveBeenCalledTimes(2);
+ expect(onSubmit).toHaveBeenCalledTimes(2);
+ expect(onKeyDown).toHaveBeenCalledTimes(2);
+
+ await user.click(screen.getByRole('button', { name: 'Delete' }));
+ expect(onAction).toHaveBeenCalledTimes(2);
+ });
- expect(onAction).not.toHaveBeenCalled();
- expect(onParentClick).toHaveBeenCalledTimes(1);
+ it('retains explicit native links while URL labels stay plain text', async () => {
+ const user = userEvent.setup();
+ const ref = createRef<HTMLAnchorElement>();
+ const onLinkClick = vi.fn((event: MouseEvent<HTMLElement>) =>
+ event.preventDefault(),
+ );
+
+ render(
+ <>
+ <ListItem>https://twenty.com/plain</ListItem>
+ <ListItem
+ render={(renderProps) => (
+ <a
+ {...renderProps}
+ href="https://twenty.com/docs"
+ target="_blank"
+ rel="noreferrer"
+ >
+ {renderProps.children}
+ </a>
+ )}
+ ref={ref}
+ onClick={onLinkClick}
+ >
+ Documentation
+ </ListItem>
+ <ListItem>
+ <a href="https://twenty.com/help">Help</a>
+ </ListItem>
+ </>,
+ );
+
+ const link = screen.getByRole('link', { name: 'Documentation' });
+ expect(ref.current).toBe(link);
+ expect(link).toHaveAttribute('href', 'https://twenty.com/docs');
+ expect(link).toHaveAttribute('target', '_blank');
+ expect(screen.getAllByRole('link')).toHaveLength(2);
+ expect(
+ screen.getByText('https://twenty.com/plain').closest('a'),
+ ).toBeNull();
+ expect(
+ screen.getByRole('link', { name: 'Help' }).querySelector('a'),
+ ).toBeNull();
+
+ await user.tab();
+ expect(link).toHaveFocus();
+ await user.keyboard('{Enter}');
+ expect(onLinkClick).toHaveBeenCalledTimes(1);
});
});
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts b/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
index 2e4df944e13..cefbdef5c68 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
@@ -1,6 +1,6 @@
import { type ShortcutDefinition } from '@ui/primitives/typography/Shortcut/types/ShortcutDefinition';
import { type useRender } from '@base-ui/react/use-render';
-import { type ReactNode } from 'react';
+import { type DOMAttributes, type ReactNode, type Ref } from 'react';
import { type ListItemColor } from './ListItemColor';
import { type ListItemDescriptionPlacement } from './ListItemDescriptionPlacement';
@@ -9,44 +9,45 @@ import { type ListItemState } from './ListItemState';
export type ListItemProps = Omit<
useRender.ComponentProps<'div', ListItemState>,
- 'color'
-> & {
- /** Color of the text and icons. `danger` marks a destructive action. */
- color?: ListItemColor;
- /**
- * Whether the item is selected. Shows the check or checkbox indicator when
- * `indicator` is set.
- */
- selected?: boolean;
- /** Applies the highlighted style, for example to the focused item of a list. */
- focused?: boolean;
- /** Prevents clicks and applies the disabled style. */
- disabled?: boolean;
- /**
- * Selection indicator: a check icon after the content or a checkbox before
- * it.
- */
- indicator?: ListItemIndicator;
- /** Icon rendered before the content. */
- startIcon?: ReactNode;
- /** Icon rendered after the content. */
- endIcon?: ReactNode;
- /** Supporting text, placed according to `descriptionPlacement`. */
- description?: ReactNode;
- /**
- * Where the description renders: inline after the content or at the end of
- * the row.
- */
- descriptionPlacement?: ListItemDescriptionPlacement;
- /** Trailing content, such as buttons, rendered after the content. */
- actions?: ReactNode;
- actionsVisibility?: 'hover' | 'always';
- /**
- * Keyboard shortcut keys displayed at the end of the row. Registering the
- * shortcut is up to the application.
- */
- shortcut?: ShortcutDefinition;
- shortcutJoinLabel?: string;
- /** Shows a chevron indicating that the item opens a submenu. */
- hasSubmenu?: boolean;
-};
+ 'color' | 'ref' | keyof DOMAttributes<HTMLDivElement>
+> &
+ DOMAttributes<HTMLElement> & {
+ ref?: Ref<HTMLElement>;
+ /** Color of the text and icons. `danger` marks a destructive action. */
+ color?: ListItemColor;
+ /**
+ * Whether the item is selected. Shows the check or checkbox indicator when
+ * `indicator` is set.
+ */
+ selected?: boolean;
+ /** Applies the highlighted style, for example to the focused item of a list. */
+ focused?: boolean;
+ disabled?: boolean;
+ /**
+ * Selection indicator: a check icon after the content or a checkbox before
+ * it.
+ */
+ indicator?: ListItemIndicator;
+ /** Icon rendered before the content. */
+ startIcon?: ReactNode;
+ /** Icon rendered after the content. */
+ endIcon?: ReactNode;
+ /** Supporting text, placed according to `descriptionPlacement`. */
+ description?: ReactNode;
+ /**
+ * Where the description renders: inline after the content or at the end of
+ * the row.
+ */
+ descriptionPlacement?: ListItemDescriptionPlacement;
+ /** Trailing content, such as buttons, rendered after the content. */
+ actions?: ReactNode;
+ actionsVisibility?: 'hover' | 'always';
+ /**
+ * Keyboard shortcut keys displayed at the end of the row. Registering the
+ * shortcut is up to the application.
+ */
+ shortcut?: ShortcutDefinition;
+ shortcutJoinLabel?: string;
+ /** Shows a chevron indicating that the item opens a submenu. */
+ hasSubmenu?: boolean;
+ };