Skip to content

The open alternative to Salesforce, designed for AI.

Retire MenuItem and MenuItemAvatar (#28285)

Raphaël Bosi1b5cc2358fc5
diff --git a/packages/twenty-companion/src/renderer/components/MeetingRow.tsx b/packages/twenty-companion/src/renderer/components/MeetingRow.tsx
index 17953e3b0e4..5342fec17c0 100644
--- a/packages/twenty-companion/src/renderer/components/MeetingRow.tsx
+++ b/packages/twenty-companion/src/renderer/components/MeetingRow.tsx
@@ -1,7 +1,7 @@
import { Menu } from '@base-ui/react/menu';
import { i18n } from '@lingui/core';
import { IconButton } from 'twenty-ui/components/input';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
import { Button } from 'twenty-ui/primitives/input';
import {
IconArrowUpRight,
@@ -85,6 +85,14 @@ export const MeetingRow = ({
>
<Menu.Popup className={styles.popup}>
<Menu.Item
+ render={
+ <ListItem
+ disabled={isPending('skip', 'unskip')}
+ startIcon={
+ skipped ? <IconCalendarEvent /> : <IconCalendarX />
+ }
+ />
+ }
disabled={isPending('skip', 'unskip')}
onClick={() =>
void command({
@@ -93,15 +101,9 @@ export const MeetingRow = ({
})
}
>
- <MenuItem
- disabled={isPending('skip', 'unskip')}
- LeftIcon={skipped ? IconCalendarEvent : IconCalendarX}
- text={
- skipped
- ? i18n._('Restore auto-join')
- : i18n._('Skip auto-join')
- }
- />
+ {skipped
+ ? i18n._('Restore auto-join')
+ : i18n._('Skip auto-join')}
</Menu.Item>
</Menu.Popup>
</Menu.Positioner>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx
deleted file mode 100644
index 519d19316fa..00000000000
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx
+++ /dev/null
@@ -1,64 +0,0 @@
-{/*
- * _____ _
- *|_ _|_ _____ _ __ | |_ _ _
- * | | \ \ /\ / / _ \ '_ \| __| | | | 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="accent" type="&quot;danger&quot; | &quot;default&quot; | &quot;placeholder&quot;" default="default">
- Default, danger, or placeholder row styling.
-</ParamField>
-
-<ParamField body="avatar" type="Pick&lt;AvatarProps, &quot;name&quot; | &quot;size&quot; | &quot;src&quot; | &quot;shape&quot; | &quot;colorSeed&quot;&gt; | null">
- Avatar name, source, color seed, size, and shape. Omit to hide the avatar.
-</ParamField>
-
-<ParamField body="className" type="string">
- Class applied to the row.
-</ParamField>
-
-<ParamField body="contextualText" type="ReactNode">
- Supporting text beside the main label.
-</ParamField>
-
-<ParamField body="hasSubMenu" type="boolean" default="false">
- Shows a submenu chevron; does not create a submenu.
-</ParamField>
-
-<ParamField body="iconButtons" type="ReactNode">
- Trailing action elements.
-</ParamField>
-
-<ParamField body="isIconDisplayedOnHoverOnly" type="boolean" default="true">
- Reveals trailing action elements only on hover.
-</ParamField>
-
-<ParamField body="isTooltipOpen" type="boolean">
- Accepted for compatibility; currently has no effect.
-</ParamField>
-
-<ParamField body="onClick" type="((event: MouseEvent&lt;HTMLDivElement, MouseEvent&gt;) =&gt; void)">
- Pointer activation callback. The row itself does not add keyboard or menu semantics.
-</ParamField>
-
-<ParamField body="onMouseEnter" type="((event: MouseEvent&lt;HTMLDivElement, MouseEvent&gt;) =&gt; void)">
- Pointer-entry callback on the row.
-</ParamField>
-
-<ParamField body="onMouseLeave" type="((event: MouseEvent&lt;HTMLDivElement, MouseEvent&gt;) =&gt; void)">
- Pointer-exit callback on the row.
-</ParamField>
-
-<ParamField body="testId" type="string">
- Value of the row’s data-testid attribute.
-</ParamField>
-
-<ParamField body="text" type="string" required>
- Main row label.
-</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item.mdx
deleted file mode 100644
index c4c45383a4d..00000000000
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item.mdx
+++ /dev/null
@@ -1,116 +0,0 @@
-{/*
- * _____ _
- *|_ _|_ _____ _ __ | |_ _ _
- * | | \ \ /\ / / _ \ '_ \| __| | | | 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="accent" type="&quot;danger&quot; | &quot;default&quot; | &quot;placeholder&quot;" default="default">
- Default, danger, or placeholder row styling.
-</ParamField>
-
-<ParamField body="className" type="string">
- Class applied to the row.
-</ParamField>
-
-<ParamField body="contextualText" type="ReactNode">
- Supporting text beside the main label.
-</ParamField>
-
-<ParamField body="contextualTextPosition" type="&quot;left&quot; | &quot;right&quot;" default="left">
- Position of the supporting text.
-</ParamField>
-
-<ParamField body="disabled" type="boolean" default="false">
- Disables activation and applies disabled styling.
-</ParamField>
-
-<ParamField body="focused" type="boolean" default="false">
- Applies focused appearance without moving DOM focus.
-</ParamField>
-
-<ParamField body="hasSubMenu" type="boolean" default="false">
- Shows a submenu chevron; does not create a submenu.
-</ParamField>
-
-<ParamField body="iconButtons" type="ReactNode">
- Trailing action elements.
-</ParamField>
-
-<ParamField body="iconThemeColor" type="ThemeColor | null">
- Theme color for the leading icon.
-</ParamField>
-
-<ParamField body="isIconDisplayedOnHoverOnly" type="boolean" default="true">
- Reveals trailing action elements only on hover.
-</ParamField>
-
-<ParamField body="isSubMenuOpened" type="boolean" default="false">
- Applies the open treatment to the submenu chevron.
-</ParamField>
-
-<ParamField body="isTooltipOpen" type="boolean">
- Accepted for compatibility; currently has no effect.
-</ParamField>
-
-<ParamField body="LeftComponent" type="ReactNode">
- Custom leading content.
-</ParamField>
-
-<ParamField body="LeftIcon" type="IconComponent | null">
- Leading icon component.
-</ParamField>
-
-<ParamField body="onClick" type="((event: MouseEvent&lt;HTMLDivElement, MouseEvent&gt;) =&gt; void)">
- Pointer activation callback. The row itself does not add keyboard or menu semantics.
-</ParamField>
-
-<ParamField body="onMouseEnter" type="((event: MouseEvent&lt;HTMLDivElement, MouseEvent&gt;) =&gt; void)">
- Pointer-entry callback on the row.
-</ParamField>
-
-<ParamField body="onMouseLeave" type="((event: MouseEvent&lt;HTMLDivElement, MouseEvent&gt;) =&gt; void)">
- Pointer-exit callback on the row.
-</ParamField>
-
-<ParamField body="RightComponent" type="ReactNode">
- Custom trailing content.
-</ParamField>
-
-<ParamField body="RightIcon" type="IconComponent | null">
- Trailing icon component.
-</ParamField>
-
-<ParamField body="selected" type="boolean" default="false">
- Applies selected appearance without owning selection state.
-</ParamField>
-
-<ParamField body="shortcut" type="ShortcutDefinition">
- Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Register handlers in the application.
-</ParamField>
-
-<ParamField body="shortcutJoinLabel" type="string">
- Text between sequential shortcut steps. Defaults to `then`.
-</ParamField>
-
-<ParamField body="testId" type="string">
- Value of the row’s data-testid attribute.
-</ParamField>
-
-<ParamField body="text" type="ReactNode" required>
- Main row label.
-</ParamField>
-
-<ParamField body="withIconContainer" type="boolean" default="false">
- Places leading content in an icon container.
-</ParamField>
-
-<ParamField body="withIconContainerBackground" type="boolean" default="true">
- Adds a background to the leading icon container.
-</ParamField>
diff --git a/packages/twenty-docs/ui/components/input/light-icon-button.mdx b/packages/twenty-docs/ui/components/input/light-icon-button.mdx
index e2637a63303..191a0756689 100644
--- a/packages/twenty-docs/ui/components/input/light-icon-button.mdx
+++ b/packages/twenty-docs/ui/components/input/light-icon-button.mdx
@@ -51,20 +51,19 @@ Import `LightIconButton` from `twenty-ui/components`. Replace `Icon={IconPlus}`
Replace `LightIconButtonGroup` with [ButtonGroup](/ui/primitives/input/button-group) using `attached={false}` and explicit children. Set `disabled` on unavailable actions, including actions without a click handler. Wrappers and tooltip triggers can remain around each child.
-## Menu item icon buttons
+## Row actions
-`MenuItem`, `MenuItemDraggable`, and `MenuItemAvatar` accept JSX through `iconButtons`. Pass one `LightIconButton` directly, or use `ButtonGroup` for multiple buttons. The menu controls their placement and hover visibility; each button owns its accessible name, click handler, and disabled state. Wrap dropdown triggers directly around the button.
+Use a passive [ListItem](/ui/primitives/navigation/list-item) with an `actions` slot for independent controls. Pass one `LightIconButton` directly, or use `ButtonGroup` for multiple buttons. Each button owns its accessible name, click handler, and disabled state. Wrap dropdown triggers directly around the button.
```tsx
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItem } from 'twenty-ui/components/navigation';
import { IconEyeOff, IconTrash } from 'twenty-ui/icon';
import { ButtonGroup } from 'twenty-ui/primitives/input';
+import { ListItem } from 'twenty-ui/primitives/navigation';
-export const RecordMenuItem = () => (
- <MenuItem
- text="Record"
- iconButtons={
+export const RecordActions = () => (
+ <ListItem
+ actions={
<ButtonGroup attached={false}>
<LightIconButton aria-label="Hide record">
<IconEyeOff />
@@ -74,11 +73,13 @@ export const RecordMenuItem = () => (
</LightIconButton>
</ButtonGroup>
}
- />
+ >
+ Record
+ </ListItem>
);
```
-Replace descriptor arrays with these elements and remove `MenuItemIconButton` types. A button without an `onClick` handler can remain enabled when a surrounding dropdown owns its interaction. Set `disabled` explicitly for unavailable buttons.
+A button without an `onClick` handler can remain enabled when a surrounding dropdown owns its interaction. Set `disabled` explicitly for unavailable buttons. Keep independent controls beside an actionable [ListItemButton](/ui/components/navigation/list-item-button) so each retains its own focus and activation.
## Props
diff --git a/packages/twenty-docs/ui/components/navigation/menu-items.mdx b/packages/twenty-docs/ui/components/navigation/menu-items.mdx
index b4fb4e12a13..bf3de7a9884 100644
--- a/packages/twenty-docs/ui/components/navigation/menu-items.mdx
+++ b/packages/twenty-docs/ui/components/navigation/menu-items.mdx
@@ -1,61 +1,15 @@
---
title: Menu rows
-description: MenuItem, MenuItemAvatar, MenuItemDraggable, and MenuItemSuggestion presentation presets.
+description: MenuItemDraggable and MenuItemSuggestion presentation presets.
---
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
-import MenuItemReference from '/snippets/ui/generated/components/navigation/menu-item.mdx';
-import MenuItemAvatarReference from '/snippets/ui/generated/components/navigation/menu-item-avatar.mdx';
import MenuItemDraggableReference from '/snippets/ui/generated/components/navigation/menu-item-draggable.mdx';
import MenuItemSuggestionReference from '/snippets/ui/generated/components/navigation/menu-item-suggestion.mdx';
These components provide row presentation. For complete menu semantics, keyboard navigation, and dismissal, use [Dropdown](/ui/components/navigation/dropdown).
-<StoryEmbed
- storyId="ui-navigation-menu-menuitem-menuitem--display"
- title="Menu row with an icon and shortcut"
- height={110}
-/>
-
-## Usage
-
-`MenuItem` accepts a main `text` label, leading and trailing content, supporting text, shortcut hints, and submenu indicators. `focused` and `selected` change its appearance; the application owns actual focus and selection.
-
-```tsx
-import { MenuItem } from 'twenty-ui/components/navigation';
-import { IconCopy } from 'twenty-ui/icon';
-
-export const CopyRowPreview = () => (
- <MenuItem text="Copy record" LeftIcon={IconCopy} shortcut={['Mod', 'C']} />
-);
-```
-
-The root is a div. `onClick` alone does not provide keyboard activation or menu semantics. Native attributes and refs are not exposed by this preset. Use `Dropdown.ActionItem` for accessible commands. Shortcut hints and `hasSubMenu` are visual; they do not register handlers or create a submenu. `isTooltipOpen` is currently accepted but unused.
-
-## MenuItemAvatar
-
-<StoryEmbed
- storyId="ui-components-navigation-menuitemavatar--display"
- title="Person row with an avatar"
- height={110}
-/>
-
-`MenuItemAvatar` places an [Avatar](/ui/primitives/data-display/avatar) before a text label. Its `avatar` accepts `name`, `src`, `colorSeed`, `size`, and `shape`. Omit it to render no avatar.
-
-```tsx
-import { MenuItemAvatar } from 'twenty-ui/components/navigation';
-
-export const PersonRowPreview = () => (
- <MenuItemAvatar
- text="Ada Lovelace"
- avatar={{ name: 'Ada Lovelace', shape: 'circle' }}
- />
-);
-```
-
-It shares MenuItem's pointer and keyboard limitations. For a selectable person, compose an Avatar inside `Dropdown.OptionItem` instead.
-
## MenuItemDraggable
<StoryEmbed
@@ -104,14 +58,6 @@ Supplying `onClick` gives the row button semantics, a tab stop, and Enter/Space
## Props
-### MenuItem
-
-<MenuItemReference />
-
-### MenuItemAvatar
-
-<MenuItemAvatarReference />
-
### MenuItemDraggable
<MenuItemDraggableReference />
diff --git a/packages/twenty-docs/ui/components/overview.mdx b/packages/twenty-docs/ui/components/overview.mdx
index bbd05b4ba2a..8ac1c66b3aa 100644
--- a/packages/twenty-docs/ui/components/overview.mdx
+++ b/packages/twenty-docs/ui/components/overview.mdx
@@ -23,19 +23,19 @@ Import from `twenty-ui/components/input`.
| [CountrySelect](/ui/components/input/country-select) | Searchable country choices, flags, and an explicit empty selection. |
| [CurrencyPicker](/ui/components/input/currency-picker) | Searchable currency choices with explicit formatting. |
| [ImageInput](/ui/components/input/image-input) | Image selection and preview with caller-owned uploads. |
-| [SegmentedControl](/ui/components/input/segmented-control) | Compact radio choice with joined text or icon options. |
+| [SegmentedControl](/ui/components/input/segmented-control) | Compact radio choice with joined text or icon options. |
## Navigation
Import from `twenty-ui/components/navigation`.
-| 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. |
+| 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) | MenuItemDraggable and MenuItemSuggestion. |
+| [MenuPicker](/ui/components/navigation/menu-picker) | Compact icon toggles with tooltips. |
## Data display
diff --git a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
index 47379d99192..43b1dc4451c 100644
--- a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
+++ b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
@@ -313,7 +313,7 @@ export const ContactRow = ({ onOpen }: ContactRowProps) => (
## Labels
-Use `shortcutJoinLabel` to customize the text between sequential shortcut steps. It defaults to `then`; an empty string removes the join text. The same prop is available on `Dropdown` item parts. The legacy `MenuItem` composition uses `shortcutJoinLabel` alongside `shortcut`.
+Use `shortcutJoinLabel` to customize the text between sequential shortcut steps. It defaults to `then`; an empty string removes the join text. The same prop is available on `Dropdown` item parts.
## Props
diff --git a/packages/twenty-docs/ui/primitives/typography/shortcut.mdx b/packages/twenty-docs/ui/primitives/typography/shortcut.mdx
index 15c227dce08..f20648503cc 100644
--- a/packages/twenty-docs/ui/primitives/typography/shortcut.mdx
+++ b/packages/twenty-docs/ui/primitives/typography/shortcut.mdx
@@ -67,12 +67,12 @@ Use `keys` for individual keycaps, `text` for an inline hint, or `button` for th
## Migration
-| Previous prop | Replacement |
-| ----------------------------------------------------- | -------------------------------------------------------------------- |
-| Button `hotkeys={['⌘', 'K']}` | `shortcut={['Mod', 'K']}` |
-| ListItem or MenuItem sequential `hotkeys` / `hotKeys` | `shortcut={[['G'], ['P']]}` |
-| `hotkeysJoinLabel` / `hotKeysJoinLabel` | `shortcutJoinLabel` on Button, ListItem, MenuItem and Dropdown parts |
-| Manual tooltip key concatenation | `formatShortcut({ shortcut: ['Mod', 'Enter'] })` |
+| Previous prop | Replacement |
+| ----------------------------------------- | ---------------------------------------------------------- |
+| Button `hotkeys={['⌘', 'K']}` | `shortcut={['Mod', 'K']}` |
+| ListItem sequential `hotkeys` / `hotKeys` | `shortcut={[['G'], ['P']]}` |
+| `hotkeysJoinLabel` / `hotKeysJoinLabel` | `shortcutJoinLabel` on Button, ListItem and Dropdown parts |
+| Manual tooltip key concatenation | `formatShortcut({ shortcut: ['Mod', 'Enter'] })` |
Flat stored arrays that represent successive key presses need nesting before being passed to `shortcut`: `hotKeys.map((key) => [key])`. Arrays that represent simultaneous keys can be passed directly. Key strings remain literal tokens, so `['Mod', '+']` contains a plus key and `['Space']` contains the Space key; no shortcut-string parsing is required.
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
index ee02423df19..4252a27c29c 100644
--- 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
@@ -2,6 +2,7 @@ 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 { Avatar } from 'twenty-ui/primitives/data-display';
import { Text } from 'twenty-ui/primitives/typography';
const SPACE_KEY = ' ';
@@ -29,6 +30,14 @@ export const ListItemButtonExample = () => {
onClick={() => setBubbledClicks((count) => count + 1)}
>
<ListItemButton
+ startIcon={
+ <Avatar
+ name="Alex Morgan"
+ colorSeed="alex"
+ shape="rounded-square"
+ size="md"
+ />
+ }
selected={selected}
aria-pressed={selected}
indicator="check"
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-controls.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-controls.front-component.tsx
index 33e0940da71..fd75a2c3a24 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-controls.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-controls.front-component.tsx
@@ -7,9 +7,10 @@ import {
MainButton,
} from 'twenty-ui/components/input';
import { AnimatedIconCrossfade } from 'twenty-ui/components/layout';
-import { MenuItem, MenuItemDraggable } from 'twenty-ui/components/navigation';
+import { MenuItemDraggable } from 'twenty-ui/components/navigation';
import { IconPencil, IconPlus, IconX } from 'twenty-ui/icon';
import { Button, ButtonGroup } from 'twenty-ui/primitives/input';
+import { ListItem } from 'twenty-ui/primitives/navigation';
import 'twenty-ui/style.css';
import { ThemeProvider } from 'twenty-ui/theme';
@@ -87,10 +88,9 @@ const ButtonControls = () => {
>
<IconPlus />
</IconButton>
- <MenuItem
- text="Record"
- isIconDisplayedOnHoverOnly={false}
- iconButtons={
+ <ListItem
+ actionsVisibility="always"
+ actions={
<ButtonGroup attached={false}>
<LightIconButton aria-label="Add to record" onClick={handleClick}>
<IconPlus />
@@ -106,7 +106,9 @@ const ButtonControls = () => {
</span>
</ButtonGroup>
}
- />
+ >
+ Record
+ </ListItem>
<MenuItemDraggable
text="Draggable record"
isIconDisplayedOnHoverOnly={false}
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-label-overrides.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-label-overrides.front-component.tsx
index be3510fc115..40a21a3482d 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-label-overrides.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-label-overrides.front-component.tsx
@@ -1,7 +1,6 @@
import { useState } from 'react';
import { defineFrontComponent } from 'twenty-sdk/define';
import { Callout } from 'twenty-ui/components/feedback';
-import { MenuItem } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';
@@ -23,11 +22,9 @@ const LabelOverrides = () => {
<ListItem shortcut={[['G'], ['S']]} shortcutJoinLabel="followed by">
Supplied shortcut
</ListItem>
- <MenuItem
- text="Legacy shortcut"
- shortcut={[['G'], ['L']]}
- shortcutJoinLabel="next"
- />
+ <ListItem shortcut={[['G'], ['L']]} shortcutJoinLabel="next">
+ Sequential shortcut
+ </ListItem>
</TwentyUiGalleryCard>
);
};
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 97dfa0b8118..a4666f6a2d2 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
@@ -1,15 +1,13 @@
import { defineFrontComponent } from 'twenty-sdk/define';
import {
DEFAULT_COLOR_LABELS,
- MenuItem,
- MenuItemAvatar,
MenuItemDraggable,
MenuItemSuggestion,
MenuPicker,
} from 'twenty-ui/components/navigation';
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
import { IconHome, IconUser } from 'twenty-ui/icon';
-import { ColorSample, Tag } from 'twenty-ui/primitives/data-display';
+import { Avatar, ColorSample, Tag } from 'twenty-ui/primitives/data-display';
import { Breadcrumb, ListItem } from 'twenty-ui/primitives/navigation';
import { ThemeProvider } from 'twenty-ui/theme';
import {
@@ -31,12 +29,20 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
),
},
{
- name: 'MenuItem',
- node: <MenuItem text="Menu item" LeftIcon={IconUser} />,
+ name: 'ListItem icon row',
+ node: <ListItem startIcon={<IconUser />}>Menu item</ListItem>,
},
{
- name: 'MenuItemAvatar',
- node: <MenuItemAvatar text="Avatar item" />,
+ name: 'ListItem avatar row',
+ node: (
+ <ListItem
+ startIcon={
+ <Avatar name="Avatar item" size="md" shape="rounded-square" />
+ }
+ >
+ Avatar item
+ </ListItem>
+ ),
},
{
name: 'MenuItemDraggable',
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
index f672c36e6b4..9c60f4d0919 100644
--- 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
@@ -14,6 +14,7 @@ export const listItemButtonTest: TwentyUiGalleryPlayFunction = async ({
expect(summary.tagName).toBe('BUTTON');
expect(summary).toHaveAttribute('type', 'button');
expect(summary).toHaveAttribute('data-ref-tag', 'HTML-BUTTON');
+ expect(within(summary).getByText('A')).toBeVisible();
await user.click(summary);
await waitFor(() =>
expect(canvas.getByLabelText('Summary state')).toHaveTextContent('enabled'),
@@ -27,6 +28,8 @@ export const listItemButtonTest: TwentyUiGalleryPlayFunction = async ({
);
expect(summary).toHaveFocus();
await user.keyboard('{Enter} ');
+ expect(getComputedStyle(summary).outlineStyle).toBe('solid');
+ expect(getComputedStyle(summary).outlineWidth).toBe('2px');
await waitFor(() =>
expect(canvas.getByLabelText('Summary activations')).toHaveTextContent('3'),
);
diff --git a/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientChipMenuContent.tsx b/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientChipMenuContent.tsx
index 69b32d2d052..756ef38bb98 100644
--- a/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientChipMenuContent.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/recipients/components/EmailRecipientChipMenuContent.tsx
@@ -6,7 +6,9 @@ import { isNonEmptyString } from '@sniptt/guards';
import { CoreObjectNameSingular } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { useToast } from 'twenty-ui/components/feedback';
-import { Dropdown, MenuItemAvatar } from 'twenty-ui/components/navigation';
+import { Dropdown } from 'twenty-ui/components/navigation';
+import { Avatar } from 'twenty-ui/primitives/data-display';
+import { ListItem } from 'twenty-ui/primitives/navigation';
import { IconCopy, IconPencil, IconTrash, IconUserPlus } from 'twenty-ui/icon';
import { useCopyToClipboard } from '~/hooks/useCopyToClipboard';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
@@ -72,41 +74,47 @@ export const EmailRecipientChipMenuContent = ({
<>
<Dropdown.Section>
{isDefined(workspaceMember) ? (
- <MenuItemAvatar
- avatar={{
- src: getAbsoluteImageUrl(workspaceMember.avatarUrl),
- name: isNonEmptyString(workspaceMemberFullName)
- ? workspaceMemberFullName
- : recipient.address,
- colorSeed: workspaceMember.id,
- size: 'md',
- shape: 'circle',
- }}
- text={
- isNonEmptyString(workspaceMemberFullName)
- ? workspaceMemberFullName
- : recipient.address
+ <ListItem
+ startIcon={
+ <Avatar
+ src={getAbsoluteImageUrl(workspaceMember.avatarUrl)}
+ name={
+ isNonEmptyString(workspaceMemberFullName)
+ ? workspaceMemberFullName
+ : recipient.address
+ }
+ colorSeed={workspaceMember.id}
+ size="md"
+ shape="circle"
+ />
}
- contextualText={t`Team member`}
- />
+ description={t`Team member`}
+ >
+ {isNonEmptyString(workspaceMemberFullName)
+ ? workspaceMemberFullName
+ : recipient.address}
+ </ListItem>
) : isDefined(person) ? (
- <MenuItemAvatar
- avatar={{
- src: getAbsoluteImageUrl(person.avatarUrl),
- name: isNonEmptyString(personFullName)
- ? personFullName
- : recipient.address,
- colorSeed: person.id,
- size: 'md',
- shape: 'circle',
- }}
- text={
- isNonEmptyString(personFullName)
- ? personFullName
- : recipient.address
+ <ListItem
+ startIcon={
+ <Avatar
+ src={getAbsoluteImageUrl(person.avatarUrl)}
+ name={
+ isNonEmptyString(personFullName)
+ ? personFullName
+ : recipient.address
+ }
+ colorSeed={person.id}
+ size="md"
+ shape="circle"
+ />
}
- contextualText={recipient.address}
- />
+ description={recipient.address}
+ >
+ {isNonEmptyString(personFullName)
+ ? personFullName
+ : recipient.address}
+ </ListItem>
) : (
<Dropdown.ActionItem
startIcon={<IconUserPlus />}
diff --git a/packages/twenty-front/src/modules/command-menu-item/edit/components/SidePanelCommandMenuItemEditPage.tsx b/packages/twenty-front/src/modules/command-menu-item/edit/components/SidePanelCommandMenuItemEditPage.tsx
index f5900c07370..e1162957d7c 100644
--- a/packages/twenty-front/src/modules/command-menu-item/edit/components/SidePanelCommandMenuItemEditPage.tsx
+++ b/packages/twenty-front/src/modules/command-menu-item/edit/components/SidePanelCommandMenuItemEditPage.tsx
@@ -24,7 +24,8 @@ import { interpolateMessagePlaceholders } from 'twenty-shared/i18n';
import { ContextStorePageType } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItem, MenuItemDraggable } from 'twenty-ui/components/navigation';
+import { MenuItemDraggable } from 'twenty-ui/components/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
import {
IconDotsVertical,
IconPin,
@@ -111,7 +112,13 @@ export const SidePanelCommandMenuItemEditPage = () => {
...displayedOtherItems.map((item) => item.id),
];
- const handleTogglePin = (itemId: string, currentlyPinned: boolean) => {
+ const handleTogglePin = ({
+ itemId,
+ currentlyPinned,
+ }: {
+ itemId: string;
+ currentlyPinned: boolean;
+ }) => {
if (currentlyPinned) {
const nextOtherPosition =
allOtherItems.length === 0
@@ -221,7 +228,12 @@ export const SidePanelCommandMenuItemEditPage = () => {
itemComponent={
<SelectableListItem
itemId={item.id}
- onEnter={() => handleTogglePin(item.id, true)}
+ onEnter={() =>
+ handleTogglePin({
+ itemId: item.id,
+ currentlyPinned: true,
+ })
+ }
>
<MenuItemDraggable
withIconContainer
@@ -256,7 +268,10 @@ export const SidePanelCommandMenuItemEditPage = () => {
aria-label={t`Unpin`}
onClick={(event) => {
event.stopPropagation();
- handleTogglePin(item.id, true);
+ handleTogglePin({
+ itemId: item.id,
+ currentlyPinned: true,
+ });
}}
>
<IconPinnedOff />
@@ -282,29 +297,34 @@ export const SidePanelCommandMenuItemEditPage = () => {
<SelectableListItem
key={item.id}
itemId={item.id}
- onEnter={() => handleTogglePin(item.id, false)}
+ onEnter={() =>
+ handleTogglePin({ itemId: item.id, currentlyPinned: false })
+ }
>
- <MenuItem
- LeftComponent={
+ <ListItem
+ actionsVisibility="always"
+ startIcon={
<AppMenuItemIcon
Icon={ItemIcon}
applicationId={item.applicationId}
/>
}
- text={getDisplayLabel(item)}
- isIconDisplayedOnHoverOnly={false}
- iconButtons={
+ actions={
<LightIconButton
aria-label={t`Pin`}
- onClick={(event) => {
- event.stopPropagation();
- handleTogglePin(item.id, false);
- }}
+ onClick={() =>
+ handleTogglePin({
+ itemId: item.id,
+ currentlyPinned: false,
+ })
+ }
>
<IconPin />
</LightIconButton>
}
- />
+ >
+ {getDisplayLabel(item)}
+ </ListItem>
</SelectableListItem>
);
})}
diff --git a/packages/twenty-front/src/modules/command-menu-item/edit/components/__stories__/SidePanelCommandMenuItemEditPage.stories.tsx b/packages/twenty-front/src/modules/command-menu-item/edit/components/__stories__/SidePanelCommandMenuItemEditPage.stories.tsx
index 6d4cb25e6c2..933b20d7191 100644
--- a/packages/twenty-front/src/modules/command-menu-item/edit/components/__stories__/SidePanelCommandMenuItemEditPage.stories.tsx
+++ b/packages/twenty-front/src/modules/command-menu-item/edit/components/__stories__/SidePanelCommandMenuItemEditPage.stories.tsx
@@ -251,3 +251,22 @@ export const CommandMenuItemOptions: Story = {
);
},
};
+
+export const PinsFromTheIndependentAction: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const pin = await canvas.findByRole('button', { name: 'Pin' });
+
+ expect(pin.closest('button')).toBe(pin);
+ pin.focus();
+ await userEvent.keyboard('{Enter}');
+
+ await waitFor(() => {
+ expect(
+ jotaiStore
+ .get(commandMenuItemsDraftState.atom)
+ ?.find((item) => item.id === OTHER_COMMAND_MENU_ITEM.id)?.isPinned,
+ ).toBe(true);
+ });
+ },
+};
diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx
index 6f33fdbc259..114d33ccf3f 100644
--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx
@@ -1,14 +1,33 @@
+import { getCommandMenuItemStartIcon } from '@/command-menu/utils/getCommandMenuItemStartIcon';
import { type CommandMenuItemProps } from '@/command-menu/types/CommandMenuItemProps';
import { useLingui } from '@lingui/react/macro';
import { isNonEmptyString } from '@sniptt/guards';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
+import { styled } from '@linaria/react';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
import { IconArrowUpRight } from 'twenty-ui/icon';
+import { useSidePanelListItemFocus } from '@/side-panel/hooks/useSidePanelListItemFocus';
import { useCommandMenuOnItemClick } from '@/command-menu/hooks/useCommandMenuOnItemClick';
-import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
-import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
+import { ListItemSubmenuIndicator } from '@/ui/navigation/list-item/components/ListItemSubmenuIndicator';
import { isDefined } from 'twenty-shared/utils';
+const StyledActionRow = styled.div`
+ align-items: center;
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ min-width: 0;
+`;
+
+const StyledTrailingContent = styled.div`
+ align-items: center;
+ display: flex;
+ flex: none;
+ gap: ${themeCssVariables.spacing[2]};
+ padding-inline: ${themeCssVariables.spacing[1]};
+`;
+
export const CommandMenuItem = ({
label,
description,
@@ -23,43 +42,88 @@ export const CommandMenuItem = ({
hasSubMenu = false,
isSubMenuOpened = false,
disabled = false,
+ 'aria-controls': ariaControls,
}: CommandMenuItemProps) => {
const { t } = useLingui();
+ const theme = useTheme();
const { onItemClick } = useCommandMenuOnItemClick();
- if (isNonEmptyString(to) && !Icon) {
+ if (isNonEmptyString(to) && !isDefined(Icon)) {
Icon = IconArrowUpRight;
}
- const isSelectedItemId = useAtomComponentFamilyStateValue(
- isSelectedItemIdComponentFamilyState,
- id,
+ const { nativeItemRef, isSelectedItemId, handleFocus } =
+ useSidePanelListItemFocus(id);
+
+ const hasAction = isDefined(onClick) || isNonEmptyString(to);
+ const hasNativeOwner = hasAction || hasSubMenu;
+ const hasTrailingActionContent = hasNativeOwner && isDefined(RightComponent);
+ const hasTrailingSubmenuIndicator =
+ hasTrailingActionContent && hasSubMenu && !hasAction;
+ const submenuIndicator = hasSubMenu ? (
+ <ListItemSubmenuIndicator isOpen={isSubMenuOpened} disabled={disabled} />
+ ) : undefined;
+ const descriptionPlacement =
+ contextualTextPosition === 'right' ? ('end' as const) : ('inline' as const);
+
+ const itemProps = {
+ startIcon: getCommandMenuItemStartIcon({
+ LeftComponent,
+ Icon,
+ iconSize: theme.icon.size.md,
+ iconStroke: theme.icon.stroke.sm,
+ }),
+ description,
+ descriptionPlacement,
+ shortcut: isDefined(hotKeys) ? hotKeys.map((key) => [key]) : undefined,
+ shortcutJoinLabel: t`then`,
+ focused: !disabled && isSelectedItemId,
+ endIcon: (
+ <>
+ {!hasTrailingActionContent && RightComponent}
+ {!hasTrailingSubmenuIndicator && submenuIndicator}
+ </>
+ ),
+ disabled,
+ };
+
+ const item = hasNativeOwner ? (
+ <ListItemButton
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...itemProps}
+ ref={nativeItemRef}
+ focusableWhenDisabled
+ aria-expanded={hasSubMenu ? isSubMenuOpened : undefined}
+ aria-controls={ariaControls}
+ aria-haspopup={hasSubMenu ? true : undefined}
+ onClick={hasAction ? () => onItemClick({ onClick, to }) : undefined}
+ onFocus={handleFocus}
+ >
+ {label}
+ </ListItemButton>
+ ) : (
+ <ListItem
+ // oxlint-disable-next-line react/jsx-props-no-spreading
+ {...itemProps}
+ ref={nativeItemRef}
+ tabIndex={-1}
+ onFocus={handleFocus}
+ >
+ {label}
+ </ListItem>
);
+ if (!hasTrailingActionContent) {
+ return item;
+ }
+
return (
- <MenuItem
- withIconContainer={!isDefined(LeftComponent)}
- LeftIcon={isDefined(LeftComponent) ? undefined : Icon}
- LeftComponent={LeftComponent}
- text={label}
- contextualText={description}
- contextualTextPosition={contextualTextPosition}
- shortcut={isDefined(hotKeys) ? hotKeys.map((key) => [key]) : undefined}
- shortcutJoinLabel={t`then`}
- onClick={
- onClick || to
- ? () =>
- onItemClick({
- onClick,
- to,
- })
- : undefined
- }
- focused={!disabled && isSelectedItemId}
- RightComponent={RightComponent}
- hasSubMenu={hasSubMenu}
- isSubMenuOpened={isSubMenuOpened}
- disabled={disabled}
- />
+ <StyledActionRow>
+ {item}
+ <StyledTrailingContent>
+ {RightComponent}
+ {hasTrailingSubmenuIndicator && submenuIndicator}
+ </StyledTrailingContent>
+ </StyledActionRow>
);
};
diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemDropdown.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemDropdown.tsx
index 9c4e606df15..86d9c76cf57 100644
--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemDropdown.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemDropdown.tsx
@@ -45,6 +45,7 @@ export const CommandMenuItemDropdown = ({
return (
<Dropdown
+ clickableComponentRole="presentation"
clickableComponent={
<CommandMenuItem
id={id}
@@ -56,6 +57,7 @@ export const CommandMenuItemDropdown = ({
RightComponent={RightComponent}
hasSubMenu
isSubMenuOpened={isDropdownOpen}
+ aria-controls={`${dropdownId}-options`}
disabled={disabled}
/>
}
diff --git a/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenuItem.stories.tsx b/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenuItem.stories.tsx
new file mode 100644
index 00000000000..cf2af92f832
--- /dev/null
+++ b/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenuItem.stories.tsx
@@ -0,0 +1,206 @@
+import { CommandMenuItemDropdown } from '@/command-menu/components/CommandMenuItemDropdown';
+import { usePushFocusItemToFocusStack } from '@/ui/utilities/focus/hooks/usePushFocusItemToFocusStack';
+import { useRemoveFocusItemFromFocusStackById } from '@/ui/utilities/focus/hooks/useRemoveFocusItemFromFocusStackById';
+import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';
+import { useEffect } from 'react';
+import { CommandMenuItem } from '@/command-menu/components/CommandMenuItem';
+import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, within } from 'storybook/test';
+import { IconPlus } from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
+import { ComponentDecorator } from 'twenty-ui/testing';
+import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
+
+const onTrailingAction = fn();
+const onFirstCommand = fn();
+const onDisabledCommand = fn();
+const onLastCommand = fn();
+const FOCUS_ID = 'command-menu-item-story';
+
+const CommandMenuItemStoryFocusEffect = () => {
+ const { pushFocusItemToFocusStack } = usePushFocusItemToFocusStack();
+ const { removeFocusItemFromFocusStackById } =
+ useRemoveFocusItemFromFocusStackById();
+
+ useEffect(() => {
+ pushFocusItemToFocusStack({
+ focusId: FOCUS_ID,
+ component: { type: FocusComponentType.DROPDOWN, instanceId: FOCUS_ID },
+ });
+
+ return () => removeFocusItemFromFocusStackById({ focusId: FOCUS_ID });
+ }, [pushFocusItemToFocusStack, removeFocusItemFromFocusStackById]);
+
+ return null;
+};
+
+const meta: Meta<typeof CommandMenuItem> = {
+ title: 'Modules/CommandMenu/CommandMenuItem',
+ component: CommandMenuItem,
+ decorators: [
+ (Story) => (
+ <SelectableList
+ selectableListInstanceId="command-menu-item-story"
+ selectableItemIdArray={['command']}
+ focusId="command-menu-item-story"
+ >
+ <CommandMenuItemStoryFocusEffect />
+ <Story />
+ </SelectableList>
+ ),
+ MemoryRouterDecorator,
+ ComponentDecorator,
+ ],
+ args: {
+ id: 'command',
+ label: 'Run command',
+ Icon: IconPlus,
+ hotKeys: ['G', 'C'],
+ onClick: fn(),
+ },
+ beforeEach: () => {
+ onTrailingAction.mockClear();
+ onFirstCommand.mockClear();
+ onDisabledCommand.mockClear();
+ onLastCommand.mockClear();
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof CommandMenuItem>;
+
+export const NativeAction: Story = {
+ play: async ({ canvasElement, args }) => {
+ const action = await within(canvasElement).findByRole('button', {
+ name: /Run command/,
+ });
+
+ await userEvent.click(action);
+ await userEvent.keyboard('{Enter}');
+ await userEvent.keyboard(' ');
+
+ expect(args.onClick).toHaveBeenCalledTimes(3);
+ expect(action).toHaveFocus();
+ },
+};
+
+export const IndependentTrailingAction: Story = {
+ args: {
+ RightComponent: <Button onClick={onTrailingAction}>Configure</Button>,
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const configure = await canvas.findByRole('button', { name: 'Configure' });
+
+ expect(configure.parentElement?.closest('button')).toBeNull();
+
+ await userEvent.click(configure);
+
+ expect(onTrailingAction).toHaveBeenCalledTimes(1);
+ expect(args.onClick).not.toHaveBeenCalled();
+
+ const action = canvas.getByRole('button', { name: /Run command/ });
+
+ action.focus();
+ await userEvent.keyboard('{Enter}');
+
+ expect(args.onClick).toHaveBeenCalledTimes(1);
+ expect(onTrailingAction).toHaveBeenCalledTimes(1);
+ },
+};
+
+export const DisabledAction: Story = {
+ args: { disabled: true },
+ play: async ({ canvasElement, args }) => {
+ const action = await within(canvasElement).findByRole('button', {
+ name: /Run command/,
+ });
+
+ expect(action).toHaveAttribute('aria-disabled', 'true');
+
+ await userEvent.click(action);
+
+ expect(args.onClick).not.toHaveBeenCalled();
+ },
+};
+
+export const MixedNativeCommandOwners: Story = {
+ render: () => (
+ <SelectableList
+ selectableListInstanceId="mixed-command-owners"
+ selectableItemIdArray={['first', 'dropdown', 'disabled', 'last']}
+ focusId={FOCUS_ID}
+ >
+ <CommandMenuItem
+ id="first"
+ label="First command"
+ onClick={onFirstCommand}
+ />
+ <CommandMenuItemDropdown
+ id="dropdown"
+ label="Choose destination"
+ dropdownId="command-menu-item-destination"
+ dropdownComponents={<div>Available destinations</div>}
+ />
+ <CommandMenuItem
+ id="disabled"
+ label="Unavailable command"
+ disabled
+ onClick={onDisabledCommand}
+ />
+ <CommandMenuItem id="last" label="Last command" onClick={onLastCommand} />
+ </SelectableList>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const firstCommand = await canvas.findByRole('button', {
+ name: 'First command',
+ });
+
+ await userEvent.click(firstCommand);
+ await userEvent.keyboard('{ArrowDown}');
+
+ const destination = canvas.getByRole('button', {
+ name: 'Choose destination',
+ });
+
+ expect(destination.parentElement?.closest('[role="button"]')).toBeNull();
+ expect(destination).toHaveAttribute(
+ 'aria-controls',
+ 'command-menu-item-destination-options',
+ );
+ expect(destination).toHaveFocus();
+
+ await userEvent.keyboard('{Enter}');
+
+ expect(await body.findByText('Available destinations')).toBeVisible();
+ expect(onFirstCommand).toHaveBeenCalledTimes(1);
+
+ await userEvent.keyboard('{Escape}{ArrowDown}');
+
+ expect(
+ canvas.getByRole('button', { name: 'Unavailable command' }),
+ ).toHaveFocus();
+
+ await userEvent.keyboard('{Enter}');
+
+ expect(onDisabledCommand).not.toHaveBeenCalled();
+ expect(onFirstCommand).toHaveBeenCalledTimes(1);
+
+ const lastCommand = canvas.getByRole('button', { name: 'Last command' });
+
+ lastCommand.focus();
+ await userEvent.keyboard('{ArrowUp}');
+
+ expect(
+ canvas.getByRole('button', { name: 'Unavailable command' }),
+ ).toHaveFocus();
+
+ await userEvent.keyboard('{ArrowDown}{Enter}');
+
+ expect(lastCommand).toHaveFocus();
+ expect(onLastCommand).toHaveBeenCalledTimes(1);
+ },
+};
diff --git a/packages/twenty-front/src/modules/command-menu/types/CommandMenuItemProps.ts b/packages/twenty-front/src/modules/command-menu/types/CommandMenuItemProps.ts
index 7343180018f..b4ef3432e27 100644
--- a/packages/twenty-front/src/modules/command-menu/types/CommandMenuItemProps.ts
+++ b/packages/twenty-front/src/modules/command-menu/types/CommandMenuItemProps.ts
@@ -16,4 +16,5 @@ export type CommandMenuItemProps = {
hasSubMenu?: boolean;
isSubMenuOpened?: boolean;
disabled?: boolean;
+ 'aria-controls'?: string;
};
diff --git a/packages/twenty-front/src/modules/command-menu/utils/getCommandMenuItemStartIcon.tsx b/packages/twenty-front/src/modules/command-menu/utils/getCommandMenuItemStartIcon.tsx
new file mode 100644
index 00000000000..815443d41af
--- /dev/null
+++ b/packages/twenty-front/src/modules/command-menu/utils/getCommandMenuItemStartIcon.tsx
@@ -0,0 +1,32 @@
+import { type CommandMenuItemProps } from '@/command-menu/types/CommandMenuItemProps';
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
+import { isDefined } from 'twenty-shared/utils';
+
+type GetCommandMenuItemStartIconOptions = Pick<
+ CommandMenuItemProps,
+ 'Icon' | 'LeftComponent'
+> & {
+ iconSize: number;
+ iconStroke: number;
+};
+
+export const getCommandMenuItemStartIcon = ({
+ LeftComponent,
+ Icon,
+ iconSize,
+ iconStroke,
+}: GetCommandMenuItemStartIconOptions) => {
+ if (isDefined(LeftComponent)) {
+ return LeftComponent;
+ }
+
+ if (!isDefined(Icon)) {
+ return undefined;
+ }
+
+ return (
+ <ListItemIconContainer>
+ <Icon size={iconSize} stroke={iconStroke} />
+ </ListItemIconContainer>
+ );
+};
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/components/RecordPageAddWidgetSection.tsx b/packages/twenty-front/src/modules/page-layout/widgets/components/RecordPageAddWidgetSection.tsx
index 483ef2ee765..9198de7974c 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/components/RecordPageAddWidgetSection.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/components/RecordPageAddWidgetSection.tsx
@@ -1,3 +1,4 @@
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
import { usePageLayoutContentContext } from '@/page-layout/contexts/PageLayoutContentContext';
import { useCreateRecordPageFieldWidget } from '@/page-layout/hooks/useCreateRecordPageFieldWidget';
import { useCreateRecordPageFieldsWidget } from '@/page-layout/hooks/useCreateRecordPageFieldsWidget';
@@ -8,14 +9,14 @@ import { type WidgetInsertionContext } from '@/page-layout/states/widgetInsertio
import { type PageLayoutWidget } from '@/page-layout/types/PageLayoutWidget';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import {
IconListDetails,
IconListSearch,
IconNotes,
IconPlus,
} from 'twenty-ui/icon';
-import { themeCssVariables } from 'twenty-ui/theme';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
const StyledContainer = styled.div`
border: 1px solid transparent;
@@ -54,6 +55,7 @@ type RecordPageAddWidgetSectionProps = {
export const RecordPageAddWidgetSection = ({
insertionContext = null,
}: RecordPageAddWidgetSectionProps) => {
+ const theme = useTheme();
const { tabId } = usePageLayoutContentContext();
const { createRecordPageFieldsWidget } = useCreateRecordPageFieldsWidget();
@@ -75,36 +77,64 @@ export const RecordPageAddWidgetSection = ({
<StyledContainer>
<StyledHeader>{t`Add widget`}</StyledHeader>
<StyledMenuItemList>
- <MenuItem
- LeftIcon={IconListDetails}
- withIconContainer
- text={t`Fields group`}
- contextualText={t`Group multiple fields from this record`}
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer>
+ <IconListDetails
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ </ListItemIconContainer>
+ }
+ description={t`Group multiple fields from this record`}
onClick={() => handleCreateWidget(createRecordPageFieldsWidget)}
- />
- <MenuItem
- LeftIcon={IconListSearch}
- withIconContainer
- text={t`Field`}
- contextualText={t`Single field with smart formats`}
+ >
+ {t`Fields group`}
+ </ListItemButton>
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer>
+ <IconListSearch
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ </ListItemIconContainer>
+ }
+ description={t`Single field with smart formats`}
onClick={() => handleCreateWidget(createRecordPageFieldWidget)}
- />
- <MenuItem
- LeftIcon={IconNotes}
- withIconContainer
- text={t`Note`}
- contextualText={t`Static text shared across all record pages`}
+ >
+ {t`Field`}
+ </ListItemButton>
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer>
+ <IconNotes
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ </ListItemIconContainer>
+ }
+ description={t`Static text shared across all record pages`}
onClick={() =>
handleCreateWidget(() => createRecordPageNoteWidget({ tabId }))
}
- />
- <MenuItem
- LeftIcon={IconPlus}
- withIconContainer
- text={t`More widgets`}
- hasSubMenu
+ >
+ {t`Note`}
+ </ListItemButton>
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer>
+ <IconPlus
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ </ListItemIconContainer>
+ }
+ hasSubmenu
onClick={() => navigateToMoreWidgets(insertionContext)}
- />
+ >
+ {t`More widgets`}
+ </ListItemButton>
</StyledMenuItemList>
</StyledContainer>
);
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationEditor.tsx b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationEditor.tsx
index 9db498423d3..f4cc3f4120e 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationEditor.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationEditor.tsx
@@ -1,3 +1,4 @@
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
import { DragDropProvider } from '@dnd-kit/react';
import { styled } from '@linaria/react';
@@ -29,7 +30,8 @@ import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/use
import { useLingui } from '@lingui/react/macro';
import { Fragment, useState } from 'react';
import { flushSync } from 'react-dom';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { useTheme } from 'twenty-ui/theme';
import { IconNewSection } from 'twenty-ui/icon';
const StyledGroupsDroppable = styled.div`
@@ -52,6 +54,7 @@ export const FieldsConfigurationEditor = ({
widgetId,
}: FieldsConfigurationEditorProps) => {
const { t } = useLingui();
+ const theme = useTheme();
const { objectMetadataItem } = useContextStoreObjectMetadataItemOrThrow();
const { editorMode } = useFieldsWidgetEditorMode({
@@ -228,13 +231,19 @@ export const FieldsConfigurationEditor = ({
/>
<StyledAddGroupButtonContainer>
- <MenuItem
- LeftIcon={IconNewSection}
- text={t`Add a Group`}
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer background="none">
+ <IconNewSection
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ </ListItemIconContainer>
+ }
onClick={() => handleAddGroup({})}
- withIconContainer
- withIconContainerBackground={false}
- />
+ >
+ {t`Add a Group`}
+ </ListItemButton>
</StyledAddGroupButtonContainer>
</StyledGroupsDroppable>
</DragDropProvider>
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationUngroupedEditor.tsx b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationUngroupedEditor.tsx
index b9b7c092028..f4a1fbcf823 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationUngroupedEditor.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationUngroupedEditor.tsx
@@ -1,9 +1,11 @@
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
import { DragDropProvider } from '@dnd-kit/react';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { Fragment, useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { useTheme } from 'twenty-ui/theme';
import { IconNewSection } from 'twenty-ui/icon';
import { FieldsConfigurationFieldEditor } from '@/page-layout/widgets/fields/components/FieldsConfigurationFieldEditor';
@@ -46,6 +48,7 @@ export const FieldsConfigurationUngroupedEditor = ({
onAddGroup,
}: FieldsConfigurationUngroupedEditorProps) => {
const { t } = useLingui();
+ const theme = useTheme();
const sortedFields = [...ungroupedFields].sort(
(a, b) => a.position - b.position,
@@ -169,13 +172,19 @@ export const FieldsConfigurationUngroupedEditor = ({
compact
/>
- <MenuItem
- LeftIcon={IconNewSection}
- text={t`Add a Group`}
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer background="none">
+ <IconNewSection
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ </ListItemIconContainer>
+ }
onClick={onAddGroup}
- withIconContainer
- withIconContainerBackground={false}
- />
+ >
+ {t`Add a Group`}
+ </ListItemButton>
</StyledFieldsDroppable>
</DragDropProvider>
</DragDropItemDndContext.Provider>
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/__stories__/FieldsConfigurationEditor.stories.tsx b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/__stories__/FieldsConfigurationEditor.stories.tsx
index e3ef9e91153..c568b40e62f 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/__stories__/FieldsConfigurationEditor.stories.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/__stories__/FieldsConfigurationEditor.stories.tsx
@@ -344,3 +344,24 @@ export const AddAGroupOpensItsRenamePanel: Story = {
expect(getGroupNames()).toEqual(['General', 'Social', 'Details']);
},
};
+
+export const AddAGroupWithKeyboard: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const addGroup = await canvas.findByRole('button', { name: 'Add a Group' });
+
+ addGroup.focus();
+ await userEvent.keyboard('{Enter}');
+
+ const renamePanel = await body.findByRole('dialog', {
+ name: 'Rename group',
+ });
+ const groupNameInput = within(renamePanel).getByRole('textbox', {
+ name: 'Group name',
+ });
+
+ await waitFor(() => expect(groupNameInput).toHaveFocus());
+ expect(getGroupNames()).toEqual(['General', 'Details', 'New Group']);
+ },
+};
diff --git a/packages/twenty-front/src/modules/side-panel/hooks/useSidePanelListItemFocus.ts b/packages/twenty-front/src/modules/side-panel/hooks/useSidePanelListItemFocus.ts
new file mode 100644
index 00000000000..e5234a977e8
--- /dev/null
+++ b/packages/twenty-front/src/modules/side-panel/hooks/useSidePanelListItemFocus.ts
@@ -0,0 +1,25 @@
+import { hasUserSelectedSidePanelListItemState } from '@/side-panel/states/hasUserSelectedSidePanelListItemState';
+import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
+import { useSelectableListNativeItemRef } from '@/ui/layout/selectable-list/hooks/useSelectableListNativeItemRef';
+import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
+import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
+import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
+
+export const useSidePanelListItemFocus = (itemId: string) => {
+ const nativeItemRef = useSelectableListNativeItemRef(itemId);
+ const isSelectedItemId = useAtomComponentFamilyStateValue(
+ isSelectedItemIdComponentFamilyState,
+ itemId,
+ );
+ const { setSelectedItemId } = useSelectableList();
+ const setHasUserSelectedSidePanelListItem = useSetAtomState(
+ hasUserSelectedSidePanelListItemState,
+ );
+
+ const handleFocus = () => {
+ setSelectedItemId(itemId);
+ setHasUserSelectedSidePanelListItem(true);
+ };
+
+ return { nativeItemRef, isSelectedItemId, handleFocus };
+};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/EmailBlockInsertList.tsx b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/EmailBlockInsertList.tsx
index 8aa24b3fbe0..310ec3eb7ac 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/EmailBlockInsertList.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/email-block-settings/components/EmailBlockInsertList.tsx
@@ -1,3 +1,4 @@
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { isNonEmptyArray } from '@sniptt/guards';
@@ -5,7 +6,7 @@ import { type Editor, type JSONContent } from '@tiptap/core';
import { useRef } from 'react';
import { EMAIL_IMAGE_MIME_TYPES } from 'twenty-shared/constants';
import { isDefined, TIPTAP_NODE_TYPES } from 'twenty-shared/utils';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { type IconComponent, IconPhoto, IconVariable } from 'twenty-ui/icon';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -84,22 +85,29 @@ export const EmailBlockInsertList = ({ editor }: EmailBlockInsertListProps) => {
Icon={Icon}
label={label}
>
- <MenuItem
- withIconContainer
- LeftIcon={() => <Icon color={iconColor} size={16} />}
- text={label}
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer>
+ <Icon color={iconColor} size={16} />
+ </ListItemIconContainer>
+ }
onClick={() => insertContent(content)}
- />
+ >
+ {label}
+ </ListItemButton>
</AdvancedTextEditorDraggableContent>
);
- const renderInsertionItems = (
+ const renderInsertionItems = ({
+ items,
+ iconColor,
+ }: {
items: Pick<
AdvancedTextEditorBlockInsertionItem,
'id' | 'title' | 'icon' | 'createContent'
- >[],
- iconColor: string,
- ) =>
+ >[];
+ iconColor: string;
+ }) =>
items.map(({ id, title, icon, createContent }) =>
renderDraggableItem({
id,
@@ -123,34 +131,36 @@ export const EmailBlockInsertList = ({ editor }: EmailBlockInsertListProps) => {
}}
/>
<CommandMenuItemSectionGroup heading={t`Text`}>
- {renderInsertionItems(
- ADVANCED_TEXT_EDITOR_TEXT_INSERTION_ITEMS,
- themeCssVariables.color.gray9,
- )}
+ {renderInsertionItems({
+ items: ADVANCED_TEXT_EDITOR_TEXT_INSERTION_ITEMS,
+ iconColor: themeCssVariables.color.gray9,
+ })}
</CommandMenuItemSectionGroup>
<CommandMenuItemSectionGroup heading={t`Layout`}>
- {renderInsertionItems(
- ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES.filter(({ nodeType }) =>
- LAYOUT_NODE_TYPES.includes(nodeType),
+ {renderInsertionItems({
+ items: ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES.filter(
+ ({ nodeType }) => LAYOUT_NODE_TYPES.includes(nodeType),
),
- themeCssVariables.color.green9,
- )}
+ iconColor: themeCssVariables.color.green9,
+ })}
</CommandMenuItemSectionGroup>
<CommandMenuItemSectionGroup heading={t`Content`}>
- <MenuItem
- withIconContainer
- LeftIcon={() => (
- <IconPhoto color={themeCssVariables.color.orange9} size={16} />
- )}
- text={t`Image`}
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer>
+ <IconPhoto color={themeCssVariables.color.orange9} size={16} />
+ </ListItemIconContainer>
+ }
onClick={() => imageFileInputRef.current?.click()}
- />
- {renderInsertionItems(
- ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES.filter(
+ >
+ {t`Image`}
+ </ListItemButton>
+ {renderInsertionItems({
+ items: ADVANCED_TEXT_EDITOR_BLOCK_INSERTION_RECIPES.filter(
({ nodeType }) => !LAYOUT_NODE_TYPES.includes(nodeType),
),
- themeCssVariables.color.orange9,
- )}
+ iconColor: themeCssVariables.color.orange9,
+ })}
</CommandMenuItemSectionGroup>
{isNonEmptyArray(variables) && (
<CommandMenuItemSectionGroup heading={t`Variables`}>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/share-record/components/SidePanelShareRecordDropdownItem.tsx b/packages/twenty-front/src/modules/side-panel/pages/share-record/components/SidePanelShareRecordDropdownItem.tsx
index ebf27ceb2a2..bebfcf760b1 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/share-record/components/SidePanelShareRecordDropdownItem.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/share-record/components/SidePanelShareRecordDropdownItem.tsx
@@ -1,13 +1,21 @@
import { type ReactNode, useId } from 'react';
-import { Dropdown, type DropdownType } from 'twenty-ui/components/navigation';
+import { isDefined } from 'twenty-shared/utils';
+import {
+ Dropdown,
+ type DropdownType,
+ ListItemButton,
+} from 'twenty-ui/components/navigation';
import { type IconComponent } from 'twenty-ui/icon';
+import { useTheme } from 'twenty-ui/theme';
-import { CommandMenuItem } from '@/command-menu/components/CommandMenuItem';
+import { useSidePanelListItemFocus } from '@/side-panel/hooks/useSidePanelListItemFocus';
import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';
import { DropdownRoot } from '@/ui/layout/dropdown/components/DropdownRoot';
import { useOpenDropdown } from '@/ui/layout/dropdown/hooks/useOpenDropdown';
import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
+import { ListItemSubmenuIndicator } from '@/ui/navigation/list-item/components/ListItemSubmenuIndicator';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
type SidePanelShareRecordDropdownItemProps = {
@@ -31,12 +39,15 @@ export const SidePanelShareRecordDropdownItem = ({
width = 200,
children,
}: SidePanelShareRecordDropdownItemProps) => {
+ const theme = useTheme();
const dropdownId = useId();
const isDropdownOpen = useAtomComponentStateValue(
isDropdownOpenComponentState,
dropdownId,
);
const { openDropdown } = useOpenDropdown();
+ const { nativeItemRef, isSelectedItemId, handleFocus } =
+ useSidePanelListItemFocus(itemId);
return (
<SelectableListItem
@@ -50,24 +61,36 @@ export const SidePanelShareRecordDropdownItem = ({
>
<DropdownRoot dropdownId={dropdownId} type={type}>
<Dropdown.Trigger
- render={<div />}
- nativeButton={false}
+ ref={nativeItemRef}
+ render={
+ <ListItemButton
+ startIcon={
+ <ListItemIconContainer>
+ <Icon
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ </ListItemIconContainer>
+ }
+ description={description}
+ descriptionPlacement="end"
+ endIcon={
+ !disabled && (
+ <ListItemSubmenuIndicator isOpen={isDropdownOpen} />
+ )
+ }
+ focused={!disabled && isSelectedItemId}
+ focusableWhenDisabled
+ >
+ {label}
+ </ListItemButton>
+ }
disabled={disabled}
+ onFocus={handleFocus}
aria-label={
- description === undefined ? label : `${label} ${description}`
+ isDefined(description) ? `${label} ${description}` : label
}
- >
- <CommandMenuItem
- id={itemId}
- label={label}
- Icon={Icon}
- description={description}
- contextualTextPosition="right"
- hasSubMenu={!disabled}
- isSubMenuOpened={isDropdownOpen}
- disabled={disabled}
- />
- </Dropdown.Trigger>
+ />
<DropdownContent align="end" width={width} aria-label={label}>
{children}
</DropdownContent>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/share-record/components/__stories__/SidePanelShareRecordContent.stories.tsx b/packages/twenty-front/src/modules/side-panel/pages/share-record/components/__stories__/SidePanelShareRecordContent.stories.tsx
index 6d37bdda4af..b12a10b4984 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/share-record/components/__stories__/SidePanelShareRecordContent.stories.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/share-record/components/__stories__/SidePanelShareRecordContent.stories.tsx
@@ -146,14 +146,27 @@ type Story = StoryObj<typeof SidePanelShareRecordContent>;
export const Default: Story = {
play: async ({ canvasElement }) => {
const page = within(canvasElement.ownerDocument.body);
- await expect(
- await page.findByRole('button', { name: 'Restricted' }),
- ).toBeVisible();
+ const generalAccess = await page.findByRole('button', {
+ name: 'Restricted',
+ });
+ const addPeople = page.getByRole('button', { name: 'Add people or roles' });
+ const recipient = page.getByRole('button', { name: 'Phil Schiler Editor' });
+ await expect(generalAccess).toBeVisible();
await expect(page.getByText('You')).toBeVisible();
await expect(page.getByText('Owner')).toBeVisible();
- await userEvent.click(
- page.getByRole('button', { name: 'Phil Schiler Editor' }),
- );
+ await userEvent.tab();
+ await expect(addPeople).toHaveFocus();
+ await userEvent.tab();
+ await expect(generalAccess).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(
+ await page.findByRole('menuitemradio', { name: 'Restricted (default)' }),
+ ).toBeVisible();
+ await userEvent.keyboard('{Escape}');
+ await expect(generalAccess).toHaveFocus();
+ await userEvent.tab();
+ await expect(recipient).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
await userEvent.click(
await page.findByRole('menuitemradio', { name: 'Full access' }),
);
@@ -172,13 +185,45 @@ export const AddPeople: Story = {
await userEvent.click(
await page.findByRole('button', { name: 'Add people or roles' }),
);
- await expect(
- await page.findByPlaceholderText('Search people or roles'),
- ).toBeVisible();
+ await waitFor(() =>
+ expect(page.getByPlaceholderText('Search people or roles')).toBeVisible(),
+ );
await expect(page.getByText('Jane Austen')).toBeVisible();
},
};
+export const Saving: Story = {
+ args: {
+ sharingState: {
+ sharing: SHARING,
+ loading: false,
+ error: undefined,
+ saving: true,
+ setGeneralAccess,
+ setShare,
+ removeShare,
+ refetch,
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const page = within(canvasElement.ownerDocument.body);
+ const addPeople = await page.findByRole('button', {
+ name: 'Add people or roles',
+ });
+ await expect(addPeople).toHaveAttribute('aria-disabled', 'true');
+ await userEvent.click(addPeople);
+ await expect(
+ page.queryByPlaceholderText('Search people or roles'),
+ ).not.toBeInTheDocument();
+ await userEvent.tab();
+ await expect(addPeople).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(
+ page.queryByPlaceholderText('Search people or roles'),
+ ).not.toBeInTheDocument();
+ },
+};
+
export const ReadOnly: Story = {
args: {
sharingState: {
diff --git a/packages/twenty-front/src/modules/side-panel/pages/snooze-ai-chat/components/__stories__/SidePanelSnoozeAiChatPage.stories.tsx b/packages/twenty-front/src/modules/side-panel/pages/snooze-ai-chat/components/__stories__/SidePanelSnoozeAiChatPage.stories.tsx
new file mode 100644
index 00000000000..2fcdd5ad14f
--- /dev/null
+++ b/packages/twenty-front/src/modules/side-panel/pages/snooze-ai-chat/components/__stories__/SidePanelSnoozeAiChatPage.stories.tsx
@@ -0,0 +1,66 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+import { SidePanelSnoozeAiChatPage } from '@/side-panel/pages/snooze-ai-chat/components/SidePanelSnoozeAiChatPage';
+import { snoozeAiChatThreadIdsComponentState } from '@/side-panel/pages/snooze-ai-chat/states/snoozeAiChatThreadIdsComponentState';
+import { SidePanelPageComponentInstanceContext } from '@/side-panel/states/contexts/SidePanelPageComponentInstanceContext';
+import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
+import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
+import { ToastDecorator } from '~/testing/decorators/ToastDecorator';
+
+const PAGE_CONTEXT = { instanceId: 'snooze-ai-chat-story' };
+
+const meta = {
+ title: 'Modules/SidePanel/SnoozeAiChat',
+ component: SidePanelSnoozeAiChatPage,
+ decorators: [
+ (Story) => (
+ <SidePanelPageComponentInstanceContext.Provider value={PAGE_CONTEXT}>
+ <Story />
+ </SidePanelPageComponentInstanceContext.Provider>
+ ),
+ MemoryRouterDecorator,
+ ComponentDecorator,
+ ToastDecorator,
+ ],
+ beforeEach: () => {
+ jotaiStore.set(
+ snoozeAiChatThreadIdsComponentState.atomFamily(PAGE_CONTEXT),
+ ['thread-1', 'thread-2'],
+ );
+ },
+} satisfies Meta<typeof SidePanelSnoozeAiChatPage>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const DayAndTimePicker: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const trigger = await canvas.findByRole('button', { name: 'Day & Time' });
+
+ await userEvent.click(trigger);
+
+ await expect(
+ await body.findByRole('button', { name: /^Snooze until/ }),
+ ).toBeVisible();
+ await expect(trigger).toHaveAttribute('aria-expanded', 'true');
+ await expect(trigger).toHaveAttribute('data-highlighted');
+
+ await userEvent.keyboard('{Escape}');
+
+ await waitFor(() =>
+ expect(trigger).toHaveAttribute('aria-expanded', 'false'),
+ );
+
+ trigger.focus();
+ await userEvent.keyboard('{Enter}');
+
+ await expect(
+ await body.findByRole('button', { name: /^Snooze until/ }),
+ ).toBeVisible();
+ await expect(trigger).toHaveAttribute('data-highlighted');
+ },
+};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/snooze-ai-chat/components/__tests__/SidePanelSnoozeAiChatPage.test.tsx b/packages/twenty-front/src/modules/side-panel/pages/snooze-ai-chat/components/__tests__/SidePanelSnoozeAiChatPage.test.tsx
index 29c8f696027..335607c855a 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/snooze-ai-chat/components/__tests__/SidePanelSnoozeAiChatPage.test.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/snooze-ai-chat/components/__tests__/SidePanelSnoozeAiChatPage.test.tsx
@@ -1,7 +1,6 @@
import { i18n } from '@lingui/core';
import { I18nProvider } from '@lingui/react';
import { act, fireEvent, render, screen } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
import { Provider as JotaiProvider } from 'jotai';
import { type ReactNode } from 'react';
import { MemoryRouter } from 'react-router-dom';
@@ -76,22 +75,6 @@ describe('SidePanelSnoozeAiChatPage', () => {
expect(screen.getByText('Today, 6:00 PM')).toBeInTheDocument();
});
- it('opens the day and time picker for the chat in a dropdown', async () => {
- const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
-
- render(<SidePanelSnoozeAiChatPage />, { wrapper: Wrapper });
-
- await user.click(screen.getByText('Day & Time'));
-
- expect(
- await screen.findByRole('button', { name: /^Snooze until/ }),
- ).toBeInTheDocument();
- expect(updateAgentChatThreadInboxState).not.toHaveBeenCalled();
- expect(
- screen.getByText('Day & Time').closest('[data-focused]'),
- ).toHaveAttribute('data-focused', 'true');
- });
-
it('refreshes the options instead of snoozing into the past', () => {
render(<SidePanelSnoozeAiChatPage />, { wrapper: Wrapper });
diff --git a/packages/twenty-front/src/modules/side-panel/pages/workflow/action/components/WorkflowActionMenuItems.tsx b/packages/twenty-front/src/modules/side-panel/pages/workflow/action/components/WorkflowActionMenuItems.tsx
index a9e8b8aefa3..093d0d60d14 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/workflow/action/components/WorkflowActionMenuItems.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/workflow/action/components/WorkflowActionMenuItems.tsx
@@ -1,8 +1,9 @@
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
import { type WorkflowActionType } from '@/workflow/types/Workflow';
import { getActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIconColorOrThrow';
import { type MessageDescriptor } from '@lingui/core';
import { useLingui } from '@lingui/react/macro';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useIcons } from 'twenty-ui/icon';
type Action = {
@@ -29,17 +30,22 @@ export const WorkflowActionMenuItems = ({
const Icon = getIcon(action.icon);
return (
- <MenuItem
- withIconContainer={true}
+ <ListItemButton
key={action.type}
- LeftIcon={() => (
- <Icon color={getActionIconColorOrThrow(action.type)} size={16} />
- )}
+ startIcon={
+ <ListItemIconContainer>
+ <Icon
+ color={getActionIconColorOrThrow(action.type)}
+ size={16}
+ />
+ </ListItemIconContainer>
+ }
disabled={action.disabled}
- text={t(action.defaultLabel)}
- contextualText={action.contextualText}
+ description={action.contextualText}
onClick={() => onClick(action.type)}
- />
+ >
+ {t(action.defaultLabel)}
+ </ListItemButton>
);
})}
</>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/workflow/action/components/__stories__/WorkflowActionMenuItems.stories.tsx b/packages/twenty-front/src/modules/side-panel/pages/workflow/action/components/__stories__/WorkflowActionMenuItems.stories.tsx
index 9a77389b13d..485af815ff1 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/workflow/action/components/__stories__/WorkflowActionMenuItems.stories.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/workflow/action/components/__stories__/WorkflowActionMenuItems.stories.tsx
@@ -24,10 +24,17 @@ type Story = StoryObj<typeof meta>;
export const Available: Story = {
play: async ({ canvasElement, args }) => {
- await userEvent.click(
- await within(canvasElement).findByText('Classify (Jev)'),
- );
+ const button = await within(canvasElement).findByRole('button', {
+ name: 'Classify (Jev)',
+ });
+ await userEvent.click(button);
await expect(args.onClick).toHaveBeenCalledWith('CLASSIFY');
+ await expect(args.onClick).toHaveBeenCalledTimes(1);
+ await expect(button).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onClick).toHaveBeenCalledTimes(2);
+ await userEvent.keyboard(' ');
+ await expect(args.onClick).toHaveBeenCalledTimes(3);
},
};
@@ -48,7 +55,11 @@ export const Unavailable: Story = {
await expect(
await canvas.findByText(/TypeSafe AI API key missing/),
).toBeVisible();
- await userEvent.click(await canvas.findByText('Classify (Jev)'));
+ const button = await canvas.findByRole('button', {
+ name: /Classify \(Jev\)/,
+ });
+ await expect(button).toBeDisabled();
+ await userEvent.click(button);
await expect(args.onClick).not.toHaveBeenCalled();
},
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/workflow/trigger-type/components/SidePanelWorkflowSelectTriggerTypeContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/workflow/trigger-type/components/SidePanelWorkflowSelectTriggerTypeContent.tsx
index cf7d43f8061..7bbf21f84b3 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/workflow/trigger-type/components/SidePanelWorkflowSelectTriggerTypeContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/workflow/trigger-type/components/SidePanelWorkflowSelectTriggerTypeContent.tsx
@@ -1,3 +1,4 @@
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
import { useSidePanelWorkflowIdOrThrow } from '@/side-panel/pages/workflow/hooks/useSidePanelWorkflowIdOrThrow';
import { useSidePanelWorkflowNavigation } from '@/side-panel/pages/workflow/hooks/useSidePanelWorkflowNavigation';
@@ -18,7 +19,7 @@ import { getTriggerDefaultDefinition } from '@/workflow/workflow-trigger/utils/g
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import { TRIGGER_STEP_ID } from 'twenty-shared/workflow';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { useIcons } from 'twenty-ui/icon';
import { useTheme } from 'twenty-ui/theme';
@@ -82,16 +83,20 @@ export const SidePanelWorkflowSelectTriggerTypeContent = () => {
{DATABASE_TRIGGER_TYPES.map((action) => {
const Icon = getIcon(action.icon);
return (
- <MenuItem
- withIconContainer={true}
+ <ListItemButton
key={action.defaultLabel}
- LeftIcon={() => <Icon color={theme.color.blue} size={16} />}
- text={getWorkflowStepDisplayName({
+ startIcon={
+ <ListItemIconContainer>
+ <Icon color={theme.color.blue} size={16} />
+ </ListItemIconContainer>
+ }
+ onClick={handleTriggerTypeClick(action)}
+ >
+ {getWorkflowStepDisplayName({
name: action.defaultLabel,
type: action.type,
})}
- onClick={handleTriggerTypeClick(action)}
- />
+ </ListItemButton>
);
})}
@@ -101,16 +106,20 @@ export const SidePanelWorkflowSelectTriggerTypeContent = () => {
{OTHER_TRIGGER_TYPES.map((action) => {
const Icon = getIcon(action.icon);
return (
- <MenuItem
- withIconContainer={true}
+ <ListItemButton
key={action.defaultLabel}
- LeftIcon={() => <Icon color={theme.color.purple} size={16} />}
- text={getWorkflowStepDisplayName({
+ startIcon={
+ <ListItemIconContainer>
+ <Icon color={theme.color.purple} size={16} />
+ </ListItemIconContainer>
+ }
+ onClick={handleTriggerTypeClick(action)}
+ >
+ {getWorkflowStepDisplayName({
name: action.defaultLabel,
type: action.type,
})}
- onClick={handleTriggerTypeClick(action)}
- />
+ </ListItemButton>
);
})}
</SidePanelStepListContainer>
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx
index 659f13e2cb2..58fd0fdc122 100644
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx
@@ -52,6 +52,7 @@ const StyledClickableComponent = styled.div<{
export type DropdownProps = {
clickableComponent?: ReactNode;
clickableComponentWidth?: Width;
+ clickableComponentRole?: 'button' | 'presentation';
dropdownComponents: ReactNode;
hotkey?: {
key: Keys;
@@ -88,6 +89,7 @@ export const Dropdown = ({
onClose,
onOpen,
clickableComponentWidth = 'auto',
+ clickableComponentRole = 'button',
excludedClickOutsideIds,
isDropdownInModal = false,
disableClickForClickableComponent = false,
@@ -206,6 +208,8 @@ export const Dropdown = ({
],
);
+ const hasInteractiveClickableComponent = clickableComponentRole === 'button';
+
return (
<DropdownComponentInstanceContext.Provider
value={{ instanceId: dropdownId }}
@@ -214,10 +218,16 @@ export const Dropdown = ({
<StyledClickableComponent
ref={refs.setReference}
onClick={handleClickableComponentClick}
- aria-controls={`${dropdownId}-options`}
- aria-expanded={isDropdownOpen}
- aria-haspopup={true}
- role="button"
+ aria-controls={
+ hasInteractiveClickableComponent
+ ? `${dropdownId}-options`
+ : undefined
+ }
+ aria-expanded={
+ hasInteractiveClickableComponent ? isDropdownOpen : undefined
+ }
+ aria-haspopup={hasInteractiveClickableComponent || undefined}
+ role={clickableComponentRole}
width={clickableComponentWidth}
>
{clickableComponent}
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 6c646242082..f91aeb116be 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,4 +1,5 @@
import { type ReactNode, useCallback, useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
import { useSelectableListHotKeys } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys';
import { useSyncSelectableListItems } from '@/ui/layout/selectable-list/hooks/internal/useSyncSelectableListItems';
@@ -34,8 +35,15 @@ export const SelectableList = ({
continue;
}
- nativeItemRefs.get(itemId)?.focus();
- break;
+ const nextNativeItem = nativeItemRefs.get(itemId);
+
+ if (!isDefined(nextNativeItem)) {
+ nativeItem.blur();
+ return;
+ }
+
+ nextNativeItem.focus();
+ return;
}
},
[nativeItemRefs],
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 d0d1aff7040..0a89a129b0f 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
@@ -22,6 +22,7 @@ const focusId = 'selectable-list-story';
type RenderProps = {
onEnter: (itemLabel: string) => void;
shouldPreselectFirstItem?: boolean;
+ passiveItemLabels?: string[];
};
type NativeSelectableItemProps = {
@@ -44,9 +45,7 @@ const NativeSelectableItem = ({
);
};
-const Render = ({ onEnter, shouldPreselectFirstItem }: RenderProps) => {
- const [searchFilter, setSearchFilter] = useState('');
-
+const SelectableListStoryFocusEffect = () => {
const { pushFocusItemToFocusStack } = usePushFocusItemToFocusStack();
useEffect(() => {
@@ -59,6 +58,16 @@ const Render = ({ onEnter, shouldPreselectFirstItem }: RenderProps) => {
});
}, [pushFocusItemToFocusStack]);
+ return null;
+};
+
+const Render = ({
+ onEnter,
+ shouldPreselectFirstItem,
+ passiveItemLabels = [],
+}: RenderProps) => {
+ const [searchFilter, setSearchFilter] = useState('');
+
const filteredItemLabels = ITEM_LABELS.filter((itemLabel) =>
itemLabel.toLowerCase().includes(searchFilter.toLowerCase()),
);
@@ -72,19 +81,30 @@ const Render = ({ onEnter, shouldPreselectFirstItem }: RenderProps) => {
shouldPreselectFirstItem ?? isNonEmptyString(searchFilter)
}
>
+ <SelectableListStoryFocusEffect />
<input
aria-label="Search"
value={searchFilter}
onChange={(event) => setSearchFilter(event.currentTarget.value)}
autoFocus
/>
- {filteredItemLabels.map((itemLabel) => (
- <NativeSelectableItem
- key={itemLabel}
- itemLabel={itemLabel}
- onEnter={() => onEnter(itemLabel)}
- />
- ))}
+ {filteredItemLabels.map((itemLabel) =>
+ passiveItemLabels.includes(itemLabel) ? (
+ <SelectableListItem
+ key={itemLabel}
+ itemId={itemLabel}
+ onEnter={() => onEnter(itemLabel)}
+ >
+ <div>{itemLabel}</div>
+ </SelectableListItem>
+ ) : (
+ <NativeSelectableItem
+ key={itemLabel}
+ itemLabel={itemLabel}
+ onEnter={() => onEnter(itemLabel)}
+ />
+ ),
+ )}
</SelectableList>
);
};
@@ -203,3 +223,26 @@ export const NavigatesNativeOwnersAfterPointerSelection: Story = {
});
},
};
+
+export const NavigatesFromNativeToApplicationOwnedItems: Story = {
+ args: {
+ shouldPreselectFirstItem: true,
+ passiveItemLabels: ['Growth Hacking'],
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const nativeAction = await canvas.findByRole('button', {
+ name: 'Content Marketing',
+ });
+
+ await userEvent.click(nativeAction);
+ await userEvent.keyboard('{ArrowDown}');
+
+ expect(nativeAction).not.toHaveFocus();
+
+ await userEvent.keyboard('{Enter}');
+
+ expect(args.onEnter).toHaveBeenCalledTimes(2);
+ expect(args.onEnter).toHaveBeenLastCalledWith('Growth Hacking');
+ },
+};
diff --git a/packages/twenty-front/src/modules/ui/navigation/list-item/components/ListItemIconContainer.tsx b/packages/twenty-front/src/modules/ui/navigation/list-item/components/ListItemIconContainer.tsx
new file mode 100644
index 00000000000..a9115606f6a
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/list-item/components/ListItemIconContainer.tsx
@@ -0,0 +1,26 @@
+import { styled } from '@linaria/react';
+import { type ReactNode } from 'react';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const StyledContainer = styled.span`
+ align-items: center;
+ display: inline-flex;
+ padding: ${themeCssVariables.spacing[1]};
+
+ &[data-background='light'] {
+ background: ${themeCssVariables.background.transparent.light};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ }
+`;
+
+type ListItemIconContainerProps = {
+ children: ReactNode;
+ background?: 'light' | 'none';
+};
+
+export const ListItemIconContainer = ({
+ children,
+ background = 'light',
+}: ListItemIconContainerProps) => (
+ <StyledContainer data-background={background}>{children}</StyledContainer>
+);
diff --git a/packages/twenty-front/src/modules/ui/navigation/list-item/components/ListItemSubmenuIndicator.tsx b/packages/twenty-front/src/modules/ui/navigation/list-item/components/ListItemSubmenuIndicator.tsx
new file mode 100644
index 00000000000..308f8b6dfbe
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/list-item/components/ListItemSubmenuIndicator.tsx
@@ -0,0 +1,37 @@
+import { styled } from '@linaria/react';
+import { IconChevronRight } from 'twenty-ui/icon';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
+
+const StyledContainer = styled.span`
+ color: ${themeCssVariables.font.color.light};
+ display: inline-flex;
+
+ &[data-opened='true'] {
+ transform: rotate(90deg);
+ }
+
+ &[data-disabled='true'] {
+ visibility: hidden;
+ }
+`;
+
+type ListItemSubmenuIndicatorProps = {
+ isOpen: boolean;
+ disabled?: boolean;
+};
+
+export const ListItemSubmenuIndicator = ({
+ isOpen,
+ disabled = false,
+}: ListItemSubmenuIndicatorProps) => {
+ const theme = useTheme();
+
+ return (
+ <StyledContainer aria-hidden data-opened={isOpen} data-disabled={disabled}>
+ <IconChevronRight
+ size={theme.icon.size.sm}
+ stroke={theme.icon.stroke.sm}
+ />
+ </StyledContainer>
+ );
+};
diff --git a/packages/twenty-front/src/modules/validation-rules/components/SettingsValidationRuleHelperPanel.tsx b/packages/twenty-front/src/modules/validation-rules/components/SettingsValidationRuleHelperPanel.tsx
index d11f0763708..3738f73cd3a 100644
--- a/packages/twenty-front/src/modules/validation-rules/components/SettingsValidationRuleHelperPanel.tsx
+++ b/packages/twenty-front/src/modules/validation-rules/components/SettingsValidationRuleHelperPanel.tsx
@@ -1,7 +1,7 @@
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { isDefined } from 'twenty-shared/utils';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
import { useIcons } from 'twenty-ui/icon';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -68,33 +68,28 @@ export const SettingsValidationRuleHelperPanel = ({
{items.map((item, index) => {
const isHighlighted = index === highlightedIndex;
const isFocusedItem = isFocused && isHighlighted;
+ const ItemIcon = getValidationRuleHelperItemIcon({ item, getIcon });
return (
- <div
+ <ListItem
key={getItemKey(item)}
role="option"
aria-selected={isFocusedItem}
ref={
isHighlighted
- ? (element: HTMLDivElement | null) =>
+ ? (element: HTMLElement | null) =>
element?.scrollIntoView({ block: 'nearest' })
: undefined
}
onMouseDown={(event) => event.preventDefault()}
+ startIcon={<ItemIcon />}
+ endIcon={isFocusedItem ? <EnterHintIcon /> : undefined}
+ focused={isFocusedItem}
+ onMouseEnter={() => onHighlight(index)}
+ onClick={() => onSelect(item)}
>
- <MenuItem
- LeftIcon={getValidationRuleHelperItemIcon({ item, getIcon })}
- text={
- item.kind === 'field'
- ? item.field.label
- : item.definition.name
- }
- RightIcon={isFocusedItem ? EnterHintIcon : undefined}
- focused={isFocusedItem}
- onMouseEnter={() => onHighlight(index)}
- onClick={() => onSelect(item)}
- />
- </div>
+ {item.kind === 'field' ? item.field.label : item.definition.name}
+ </ListItem>
);
})}
</StyledList>
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsFlagRow.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsFlagRow.tsx
index 042f4f294dc..2a2af0e9dcb 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsFlagRow.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsFlagRow.tsx
@@ -1,7 +1,11 @@
+import { ListItemIconContainer } from '@/ui/navigation/list-item/components/ListItemIconContainer';
import { type SettingsRolePermissionsSettingPermission } from '@/settings/roles/role-permissions/permission-flags/types/SettingsRolePermissionsSettingPermission';
import { t } from '@lingui/core/macro';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { isDefined } from 'twenty-shared/utils';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
+import { useTheme } from 'twenty-ui/theme';
import { IconTrash } from 'twenty-ui/icon';
type WorkflowAiAgentPermissionsFlagRowProps = {
@@ -21,30 +25,39 @@ export const WorkflowAiAgentPermissionsFlagRow = ({
onAdd,
onDelete,
}: WorkflowAiAgentPermissionsFlagRowProps) => {
- const isClickable = !readonly && !isEnabled && Boolean(onAdd);
+ const theme = useTheme();
+ const isClickable = !readonly && !isEnabled && isDefined(onAdd);
const isDisabled = isEnabled && !showDeleteButton;
const showTrashButton = isEnabled && showDeleteButton;
+ const Icon = permission.Icon;
+ const startIcon = (
+ <ListItemIconContainer>
+ <Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
+ </ListItemIconContainer>
+ );
+
+ if (isClickable) {
+ return (
+ <ListItemButton startIcon={startIcon} onClick={onAdd}>
+ {permission.name}
+ </ListItemButton>
+ );
+ }
+
return (
- <MenuItem
- LeftIcon={permission.Icon}
- withIconContainer
- text={permission.name}
- onClick={isClickable ? onAdd : undefined}
+ <ListItem
+ startIcon={startIcon}
disabled={isDisabled}
- iconButtons={
+ actions={
showTrashButton && (
- <LightIconButton
- aria-label={t`Remove permission`}
- onClick={(event) => {
- event.stopPropagation();
- onDelete?.();
- }}
- >
+ <LightIconButton aria-label={t`Remove permission`} onClick={onDelete}>
<IconTrash />
</LightIconButton>
)
}
- />
+ >
+ {permission.name}
+ </ListItem>
);
};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsObjectRow.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsObjectRow.tsx
index 84b2b58104a..d9bdf9f4885 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsObjectRow.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsObjectRow.tsx
@@ -1,6 +1,8 @@
import { ObjectMetadataIcon } from '@/object-metadata/components/ObjectMetadataIcon';
import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { isDefined } from 'twenty-shared/utils';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
type WorkflowAiAgentPermissionsObjectRowProps = {
objectMetadata: Pick<
@@ -16,12 +18,17 @@ export const WorkflowAiAgentPermissionsObjectRow = ({
onClick,
readonly,
}: WorkflowAiAgentPermissionsObjectRowProps) => {
+ const startIcon = <ObjectMetadataIcon objectMetadataItem={objectMetadata} />;
+
+ if (readonly || !isDefined(onClick)) {
+ return (
+ <ListItem startIcon={startIcon}>{objectMetadata.labelPlural}</ListItem>
+ );
+ }
+
return (
- <MenuItem
- LeftComponent={<ObjectMetadataIcon objectMetadataItem={objectMetadata} />}
- text={objectMetadata.labelPlural}
- hasSubMenu={!readonly}
- onClick={!readonly ? onClick : undefined}
- />
+ <ListItemButton startIcon={startIcon} hasSubmenu onClick={onClick}>
+ {objectMetadata.labelPlural}
+ </ListItemButton>
);
};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsObjectsList.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsObjectsList.tsx
index 4bdd4da036f..6b3aec42e78 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsObjectsList.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsObjectsList.tsx
@@ -2,7 +2,8 @@ import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/Enriche
import { SidePanelGroup } from '@/side-panel/components/SidePanelGroup';
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
import { IconSettings } from 'twenty-ui/icon';
import { WorkflowAiAgentPermissionsObjectRow } from './WorkflowAiAgentPermissionsObjectRow';
@@ -36,14 +37,18 @@ export const WorkflowAiAgentPermissionsObjectsList = ({
readonly={readonly}
/>
))}
- {isDefined(onSystemObjectsClick) && (
- <MenuItem
- LeftIcon={IconSettings}
- text={t`System objects`}
- hasSubMenu={!readonly}
- onClick={!readonly ? onSystemObjectsClick : undefined}
- />
- )}
+ {isDefined(onSystemObjectsClick) &&
+ (readonly ? (
+ <ListItem startIcon={<IconSettings />}>{t`System objects`}</ListItem>
+ ) : (
+ <ListItemButton
+ startIcon={<IconSettings />}
+ hasSubmenu
+ onClick={onSystemObjectsClick}
+ >
+ {t`System objects`}
+ </ListItemButton>
+ ))}
</SidePanelGroup>
);
};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsPermissionRow.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsPermissionRow.tsx
index a082441a27b..27b1195832e 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsPermissionRow.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsPermissionRow.tsx
@@ -1,8 +1,10 @@
import { PermissionIcon } from '@/settings/roles/role-permissions/objects-permissions/components/PermissionIcon';
import { type SettingsRoleObjectPermissionKey } from '@/settings/roles/role-permissions/objects-permissions/constants/SettingsRoleObjectPermissionIconConfig';
import { t } from '@lingui/core/macro';
+import { isDefined } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItem } from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { ListItem } from 'twenty-ui/primitives/navigation';
import { IconTrash } from 'twenty-ui/icon';
type WorkflowAiAgentPermissionsPermissionRowProps = {
@@ -27,34 +29,38 @@ export const WorkflowAiAgentPermissionsPermissionRow = ({
onAdd,
onDelete,
}: WorkflowAiAgentPermissionsPermissionRowProps) => {
- const isClickable = !readonly && !isEnabled;
+ const isClickable = !readonly && !isEnabled && isDefined(onAdd);
const isDisabled = isEnabled && !showDeleteButton;
const showTrashButton = isEnabled && showDeleteButton;
+ const startIcon = (
+ <PermissionIcon
+ permission={permission.key}
+ state={alwaysShowGranted || isEnabled ? 'granted' : 'revoked'}
+ />
+ );
+
+ if (isClickable) {
+ return (
+ <ListItemButton startIcon={startIcon} onClick={onAdd}>
+ {permission.label}
+ </ListItemButton>
+ );
+ }
+
return (
- <MenuItem
- LeftComponent={
- <PermissionIcon
- permission={permission.key}
- state={alwaysShowGranted || isEnabled ? 'granted' : 'revoked'}
- />
- }
- text={permission.label}
- onClick={isClickable ? onAdd : undefined}
+ <ListItem
+ startIcon={startIcon}
disabled={isDisabled}
- iconButtons={
+ actions={
showTrashButton && (
- <LightIconButton
- aria-label={t`Remove permission`}
- onClick={(event) => {
- event.stopPropagation();
- onDelete?.();
- }}
- >
+ <LightIconButton aria-label={t`Remove permission`} onClick={onDelete}>
<IconTrash />
</LightIconButton>
)
}
- />
+ >
+ {permission.label}
+ </ListItem>
);
};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/__stories__/WorkflowAiAgentPermissionsPermissionRow.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/__stories__/WorkflowAiAgentPermissionsPermissionRow.stories.tsx
new file mode 100644
index 00000000000..75c209b5f9d
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/__stories__/WorkflowAiAgentPermissionsPermissionRow.stories.tsx
@@ -0,0 +1,81 @@
+import { WorkflowAiAgentPermissionsFlagRow } from '@/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsFlagRow';
+import { WorkflowAiAgentPermissionsPermissionRow } from '@/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowAiAgentPermissionsPermissionRow';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, within } from 'storybook/test';
+import { IconSettings } from 'twenty-ui/icon';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+const meta = {
+ title: 'Modules/Workflow/Actions/AiAgentPermissionRows',
+ component: WorkflowAiAgentPermissionsPermissionRow,
+ decorators: [ComponentDecorator],
+ args: {
+ permission: { key: 'canReadObjectRecords', label: 'Read records' },
+ isEnabled: false,
+ readonly: false,
+ onAdd: fn(),
+ onDelete: fn(),
+ },
+} satisfies Meta<typeof WorkflowAiAgentPermissionsPermissionRow>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+export const ActionOwnership: Story = {
+ render: (args) => (
+ <>
+ <WorkflowAiAgentPermissionsPermissionRow
+ permission={args.permission}
+ isEnabled={false}
+ readonly={false}
+ onAdd={args.onAdd}
+ />
+ <WorkflowAiAgentPermissionsFlagRow
+ permission={{
+ key: 'settings',
+ name: 'Manage settings',
+ description: 'Manage settings',
+ Icon: IconSettings,
+ }}
+ isEnabled
+ readonly={false}
+ showDeleteButton
+ onAdd={args.onAdd}
+ onDelete={args.onDelete}
+ />
+ </>
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const addButton = await canvas.findByRole('button', {
+ name: 'Read records',
+ });
+ await userEvent.tab();
+ await expect(addButton).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(args.onAdd).toHaveBeenCalledTimes(1);
+ await userEvent.tab();
+ const deleteButton = await canvas.findByRole('button', {
+ name: 'Remove permission',
+ });
+ await expect(deleteButton).toHaveFocus();
+ await userEvent.keyboard(' ');
+ await expect(args.onDelete).toHaveBeenCalledTimes(1);
+ await expect(args.onAdd).toHaveBeenCalledTimes(1);
+ await expect(
+ canvas.queryByRole('button', { name: 'Manage settings' }),
+ ).toBeNull();
+ },
+};
+
+export const Readonly: Story = {
+ args: { readonly: true, showDeleteButton: false },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ await expect(await canvas.findByText('Read records')).toBeVisible();
+ await expect(canvas.queryByRole('button')).toBeNull();
+ await userEvent.click(canvas.getByText('Read records'));
+ await expect(args.onAdd).not.toHaveBeenCalled();
+ await expect(args.onDelete).not.toHaveBeenCalled();
+ },
+};
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index d3efb1822b2..fc62aeae62c 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -30,8 +30,6 @@ import { NUMBER_STEPPER_PROP_DESCRIPTIONS } from './numberStepperPropDescription
import { NUMBER_FIELD_PART_PROP_DESCRIPTIONS } from './numberFieldPartPropDescriptions';
import { IMAGE_INPUT_PROP_DESCRIPTIONS } from './imageInputPropDescriptions';
import { ANIMATED_ICON_CROSSFADE_PROP_DESCRIPTIONS } from './animatedIconCrossfadePropDescriptions';
-import { MENU_ITEM_PROP_DESCRIPTIONS } from './menuItemPropDescriptions';
-import { MENU_ITEM_AVATAR_PROP_DESCRIPTIONS } from './menuItemAvatarPropDescriptions';
import { MENU_ITEM_DRAGGABLE_PROP_DESCRIPTIONS } from './menuItemDraggablePropDescriptions';
import { MENU_ITEM_SUGGESTION_PROP_DESCRIPTIONS } from './menuItemSuggestionPropDescriptions';
import { MENU_PICKER_PROP_DESCRIPTIONS } from './menuPickerPropDescriptions';
@@ -993,20 +991,6 @@ export const DOCUMENTED_COMPONENTS = [
slug: 'components/layout/animated-icon-crossfade',
propDescriptions: ANIMATED_ICON_CROSSFADE_PROP_DESCRIPTIONS,
},
- {
- name: 'MenuItem',
- source: 'components/navigation/MenuItem/MenuItem.tsx',
- entryPoint: 'twenty-ui/components/navigation',
- slug: 'components/navigation/menu-item',
- propDescriptions: MENU_ITEM_PROP_DESCRIPTIONS,
- },
- {
- name: 'MenuItemAvatar',
- source: 'components/navigation/MenuItemAvatar/MenuItemAvatar.tsx',
- entryPoint: 'twenty-ui/components/navigation',
- slug: 'components/navigation/menu-item-avatar',
- propDescriptions: MENU_ITEM_AVATAR_PROP_DESCRIPTIONS,
- },
{
name: 'MenuItemDraggable',
source: 'components/navigation/MenuItemDraggable/MenuItemDraggable.tsx',
diff --git a/packages/twenty-ui/docs/label-ownership.md b/packages/twenty-ui/docs/label-ownership.md
index 71d3de9dc35..e82ca5ded85 100644
--- a/packages/twenty-ui/docs/label-ownership.md
+++ b/packages/twenty-ui/docs/label-ownership.md
@@ -9,11 +9,11 @@ This covers production exports under components, primitives, and icons, includin
| 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 | Caller-owned catalogue, option content, selected content, placeholders, and trigger and popup names. `searchLabel` defaults to `Search`; native `searchProps` can override its attributes. `emptyLabel` defaults to `No results`. The listbox inherits the registered Dropdown title or trigger name; `listLabel` names only that selection listbox. Native Options accessible labels stay on its own wrapper div. |
-| 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. |
+| Legacy menu compositions | Draggable, suggestion, and picker presets receive their text from callers; they add no English fallback. |
| Button, MainButton, LightButton | Children and native accessible attributes. Applications compose upcoming-feature labels with Badge. Loading preserves the supplied name and marks the button busy; its spinner is decorative. Button hints use the shared Shortcut presentation and remain decorative. `shortcutJoinLabel` supplies the sequence join label. |
| IconButton and LightIconButton | Caller-supplied accessible label and optional tooltip. Native `aria-labelledby` remains available and takes precedence. |
| SearchInput | Caller-owned placeholder, native accessible name and action labels. Referenced labels take precedence over explicit labels and placeholder fallback. |
-| CountrySelect | Root owns caller-supplied country labels and `noCountryLabel` (default `No country`). Trigger accepts `label`, native accessible names, and custom children. Options owns `searchLabel` (default `Search`) and `noResultsLabel` (default `No results`). The shorthand exposes the same labels. Applications own translations, stable identifiers, and persistence conversions. |
+| CountrySelect | Root owns caller-supplied country labels and `noCountryLabel` (default `No country`). Trigger accepts `label`, native accessible names, and custom children. Options owns `searchLabel` (default `Search`) and `noResultsLabel` (default `No results`). The shorthand exposes the same labels. Applications own translations, stable identifiers, and persistence conversions. |
| PhoneCountryPicker | Callers supply country labels and the trigger name. The selected label describes the trigger; the popup uses its trigger name unless named explicitly. Options defaults are `Search` (`searchLabel`), `Countries` (`listLabel`) and `No results` (`emptyLabel`), also available through shorthand `optionsProps`. Calling codes omit the plus sign in caller data and display with LTR isolation. |
| ImageInput | `uploadLabel`, `removeLabel`, and `abortLabel` default to `Upload`, `Remove`, and `Abort`. The upload label names the visible upload button, preview button, and hidden file input. Native accessible attributes can supply names and descriptions for the file input. Applications supply `helperText` and `errorMessage`, including validation instructions and translated strings. |
| Toast and Toaster | Caller-owned children, description, icon, action, and `cancelLabel` nodes (default `Cancel`), plus `iconLabel` and `closeLabel` (default `Close`). Live updates replace only supplied fields. Toaster accepts native accessible attributes over its `Notifications` region default. Multiple Toasters mirror one provider-owned notification lifecycle; each region owns its accessible name. |
diff --git a/packages/twenty-ui/docs/menuItemAvatarPropDescriptions.ts b/packages/twenty-ui/docs/menuItemAvatarPropDescriptions.ts
deleted file mode 100644
index 00a0bdae551..00000000000
--- a/packages/twenty-ui/docs/menuItemAvatarPropDescriptions.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { type ComponentProps } from 'react';
-
-import { type MenuItemAvatar } from '../src/components/navigation/MenuItemAvatar/MenuItemAvatar';
-
-export const MENU_ITEM_AVATAR_PROP_DESCRIPTIONS = {
- accent: 'Default, danger, or placeholder row styling.',
- className: 'Class applied to the row.',
- iconButtons: 'Trailing action elements.',
- isIconDisplayedOnHoverOnly: 'Reveals trailing action elements only on hover.',
- isTooltipOpen: 'Accepted for compatibility; currently has no effect.',
- avatar:
- 'Avatar name, source, color seed, size, and shape. Omit to hide the avatar.',
- onClick:
- 'Pointer activation callback. The row itself does not add keyboard or menu semantics.',
- onMouseEnter: 'Pointer-entry callback on the row.',
- onMouseLeave: 'Pointer-exit callback on the row.',
- testId: 'Value of the row’s data-testid attribute.',
- text: 'Main row label.',
- hasSubMenu: 'Shows a submenu chevron; does not create a submenu.',
- contextualText: 'Supporting text beside the main label.',
-} satisfies Partial<
- Record<keyof ComponentProps<typeof MenuItemAvatar>, string>
->;
diff --git a/packages/twenty-ui/docs/menuItemPropDescriptions.ts b/packages/twenty-ui/docs/menuItemPropDescriptions.ts
deleted file mode 100644
index 3aed296da8a..00000000000
--- a/packages/twenty-ui/docs/menuItemPropDescriptions.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { type ComponentProps } from 'react';
-
-import { type MenuItem } from '../src/components/navigation/MenuItem/MenuItem';
-
-export const MENU_ITEM_PROP_DESCRIPTIONS = {
- accent: 'Default, danger, or placeholder row styling.',
- className: 'Class applied to the row.',
- withIconContainer: 'Places leading content in an icon container.',
- withIconContainerBackground:
- 'Adds a background to the leading icon container.',
- iconButtons: 'Trailing action elements.',
- isIconDisplayedOnHoverOnly: 'Reveals trailing action elements only on hover.',
- isTooltipOpen: 'Accepted for compatibility; currently has no effect.',
- LeftIcon: 'Leading icon component.',
- iconThemeColor: 'Theme color for the leading icon.',
- LeftComponent: 'Custom leading content.',
- RightIcon: 'Trailing icon component.',
- RightComponent: 'Custom trailing content.',
- onClick:
- 'Pointer activation callback. The row itself does not add keyboard or menu semantics.',
- onMouseEnter: 'Pointer-entry callback on the row.',
- onMouseLeave: 'Pointer-exit callback on the row.',
- testId: 'Value of the row’s data-testid attribute.',
- disabled: 'Disables activation and applies disabled styling.',
- text: 'Main row label.',
- contextualTextPosition: 'Position of the supporting text.',
- contextualText: 'Supporting text beside the main label.',
- hasSubMenu: 'Shows a submenu chevron; does not create a submenu.',
- focused: 'Applies focused appearance without moving DOM focus.',
- selected: 'Applies selected appearance without owning selection state.',
- shortcut:
- 'Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Register handlers in the application.',
- shortcutJoinLabel:
- 'Text between sequential shortcut steps. Defaults to `then`.',
- isSubMenuOpened: 'Applies the open treatment to the submenu chevron.',
-} satisfies Partial<Record<keyof ComponentProps<typeof MenuItem>, string>>;
diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.json
index 6962498af02..055fd47bff3 100644
--- a/packages/twenty-ui/docs/module-ownership.json
+++ b/packages/twenty-ui/docs/module-ownership.json
@@ -63,8 +63,6 @@
"LightIconButton",
"ListItemButton",
"MainButton",
- "MenuItem",
- "MenuItemAvatar",
"MenuItemDraggable",
"MenuItemSuggestion",
"MenuPicker",
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 884b11b46a0..d72dc9a33f8 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -151,8 +151,6 @@
"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",
"MenuItemSuggestion": "components/navigation/MenuItemSuggestion/MenuItemSuggestion",
"MenuPicker": "components/navigation/MenuPicker/MenuPicker",
@@ -183,10 +181,8 @@
"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",
"MenuItemDraggableProps": "components/navigation/MenuItemDraggable/types/MenuItemDraggableProps",
- "MenuItemProps": "components/navigation/MenuItem/types/MenuItemProps",
"MenuItemSuggestionProps": "components/navigation/MenuItemSuggestion/types/MenuItemSuggestionProps",
"MenuPickerProps": "components/navigation/MenuPicker/types/MenuPickerProps",
"TabButtonProps": "components/navigation/TabButton/types/TabButtonProps"
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 376767b270b..fee91f9f6aa 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -14593,293 +14593,6 @@
}
]
},
- {
- "name": "MenuItem",
- "entryPoint": "twenty-ui/components/navigation",
- "slug": "components/navigation/menu-item",
- "props": [
- {
- "name": "accent",
- "type": "\"danger\" | \"default\" | \"placeholder\"",
- "required": false,
- "defaultValue": "default",
- "description": "Default, danger, or placeholder row styling."
- },
- {
- "name": "className",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Class applied to the row."
- },
- {
- "name": "contextualText",
- "type": "ReactNode",
- "required": false,
- "defaultValue": null,
- "description": "Supporting text beside the main label."
- },
- {
- "name": "contextualTextPosition",
- "type": "\"left\" | \"right\"",
- "required": false,
- "defaultValue": "left",
- "description": "Position of the supporting text."
- },
- {
- "name": "disabled",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Disables activation and applies disabled styling."
- },
- {
- "name": "focused",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Applies focused appearance without moving DOM focus."
- },
- {
- "name": "hasSubMenu",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Shows a submenu chevron; does not create a submenu."
- },
- {
- "name": "iconButtons",
- "type": "ReactNode",
- "required": false,
- "defaultValue": null,
- "description": "Trailing action elements."
- },
- {
- "name": "iconThemeColor",
- "type": "ThemeColor | null",
- "required": false,
- "defaultValue": null,
- "description": "Theme color for the leading icon."
- },
- {
- "name": "isIconDisplayedOnHoverOnly",
- "type": "boolean",
- "required": false,
- "defaultValue": "true",
- "description": "Reveals trailing action elements only on hover."
- },
- {
- "name": "isSubMenuOpened",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Applies the open treatment to the submenu chevron."
- },
- {
- "name": "isTooltipOpen",
- "type": "boolean",
- "required": false,
- "defaultValue": null,
- "description": "Accepted for compatibility; currently has no effect."
- },
- {
- "name": "LeftComponent",
- "type": "ReactNode",
- "required": false,
- "defaultValue": null,
- "description": "Custom leading content."
- },
- {
- "name": "LeftIcon",
- "type": "IconComponent | null",
- "required": false,
- "defaultValue": null,
- "description": "Leading icon component."
- },
- {
- "name": "onClick",
- "type": "((event: MouseEvent<HTMLDivElement, MouseEvent>) => void)",
- "required": false,
- "defaultValue": null,
- "description": "Pointer activation callback. The row itself does not add keyboard or menu semantics."
- },
- {
- "name": "onMouseEnter",
- "type": "((event: MouseEvent<HTMLDivElement, MouseEvent>) => void)",
- "required": false,
- "defaultValue": null,
- "description": "Pointer-entry callback on the row."
- },
- {
- "name": "onMouseLeave",
- "type": "((event: MouseEvent<HTMLDivElement, MouseEvent>) => void)",
- "required": false,
- "defaultValue": null,
- "description": "Pointer-exit callback on the row."
- },
- {
- "name": "RightComponent",
- "type": "ReactNode",
- "required": false,
- "defaultValue": null,
- "description": "Custom trailing content."
- },
- {
- "name": "RightIcon",
- "type": "IconComponent | null",
- "required": false,
- "defaultValue": null,
- "description": "Trailing icon component."
- },
- {
- "name": "selected",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Applies selected appearance without owning selection state."
- },
- {
- "name": "shortcut",
- "type": "ShortcutDefinition",
- "required": false,
- "defaultValue": null,
- "description": "Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Register handlers in the application."
- },
- {
- "name": "shortcutJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between sequential shortcut steps. Defaults to `then`."
- },
- {
- "name": "testId",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Value of the row’s data-testid attribute."
- },
- {
- "name": "text",
- "type": "ReactNode",
- "required": true,
- "defaultValue": null,
- "description": "Main row label."
- },
- {
- "name": "withIconContainer",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Places leading content in an icon container."
- },
- {
- "name": "withIconContainerBackground",
- "type": "boolean",
- "required": false,
- "defaultValue": "true",
- "description": "Adds a background to the leading icon container."
- }
- ]
- },
- {
- "name": "MenuItemAvatar",
- "entryPoint": "twenty-ui/components/navigation",
- "slug": "components/navigation/menu-item-avatar",
- "props": [
- {
- "name": "accent",
- "type": "\"danger\" | \"default\" | \"placeholder\"",
- "required": false,
- "defaultValue": "default",
- "description": "Default, danger, or placeholder row styling."
- },
- {
- "name": "avatar",
- "type": "Pick<AvatarProps, \"name\" | \"size\" | \"src\" | \"shape\" | \"colorSeed\"> | null",
- "required": false,
- "defaultValue": null,
- "description": "Avatar name, source, color seed, size, and shape. Omit to hide the avatar."
- },
- {
- "name": "className",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Class applied to the row."
- },
- {
- "name": "contextualText",
- "type": "ReactNode",
- "required": false,
- "defaultValue": null,
- "description": "Supporting text beside the main label."
- },
- {
- "name": "hasSubMenu",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Shows a submenu chevron; does not create a submenu."
- },
- {
- "name": "iconButtons",
- "type": "ReactNode",
- "required": false,
- "defaultValue": null,
- "description": "Trailing action elements."
- },
- {
- "name": "isIconDisplayedOnHoverOnly",
- "type": "boolean",
- "required": false,
- "defaultValue": "true",
- "description": "Reveals trailing action elements only on hover."
- },
- {
- "name": "isTooltipOpen",
- "type": "boolean",
- "required": false,
- "defaultValue": null,
- "description": "Accepted for compatibility; currently has no effect."
- },
- {
- "name": "onClick",
- "type": "((event: MouseEvent<HTMLDivElement, MouseEvent>) => void)",
- "required": false,
- "defaultValue": null,
- "description": "Pointer activation callback. The row itself does not add keyboard or menu semantics."
- },
- {
- "name": "onMouseEnter",
- "type": "((event: MouseEvent<HTMLDivElement, MouseEvent>) => void)",
- "required": false,
- "defaultValue": null,
- "description": "Pointer-entry callback on the row."
- },
- {
- "name": "onMouseLeave",
- "type": "((event: MouseEvent<HTMLDivElement, MouseEvent>) => void)",
- "required": false,
- "defaultValue": null,
- "description": "Pointer-exit callback on the row."
- },
- {
- "name": "testId",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Value of the row’s data-testid attribute."
- },
- {
- "name": "text",
- "type": "string",
- "required": true,
- "defaultValue": null,
- "description": "Main row label."
- }
- ]
- },
{
"name": "MenuItemDraggable",
"entryPoint": "twenty-ui/components/navigation",
diff --git a/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx b/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx
index 1c24503da08..2ab8368013a 100644
--- a/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx
+++ b/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx
@@ -5,7 +5,7 @@ import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
import {
Callout,
Dropdown,
- MenuItem,
+ ListItemButton,
SearchInput,
Toaster,
ToastProvider,
@@ -63,11 +63,9 @@ export const ShortcutLabels: Story = {
<ListItem shortcut={[['G'], ['S']]} shortcutJoinLabel="followed by">
Supplied shortcut
</ListItem>
- <MenuItem
- text="Legacy shortcut"
- shortcut={[['G'], ['L']]}
- shortcutJoinLabel="next"
- />
+ <ListItemButton shortcut={[['G'], ['L']]} shortcutJoinLabel="next">
+ Action shortcut
+ </ListItemButton>
</>
),
play: async ({ canvasElement }) => {
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
index c86be26d4f5..22877d6876c 100644
--- a/packages/twenty-ui/src/components/navigation/ListItemButton/__stories__/ListItemButtonInteractions.stories.tsx
+++ b/packages/twenty-ui/src/components/navigation/ListItemButton/__stories__/ListItemButtonInteractions.stories.tsx
@@ -1,6 +1,7 @@
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 { Avatar } from '@ui/primitives/data-display/Avatar/Avatar';
import { ComponentDecorator } from '@ui/testing';
import { isDefined } from '@ui/utilities/utils/isDefined';
import { expect, fn, userEvent, within } from 'storybook/test';
@@ -27,6 +28,9 @@ export const NativeActivation: Story = {
<div role="presentation" onClick={bubbledClicks}>
<ListItemButton
{...args}
+ startIcon={<Avatar name="Alex Morgan" colorSeed="alex" size="md" />}
+ shortcut={[['G'], ['P']]}
+ shortcutJoinLabel="next"
ref={(element) => {
if (isDefined(element)) {
element.dataset.refTag = element.tagName;
@@ -44,17 +48,21 @@ export const NativeActivation: Story = {
),
play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);
- const button = canvas.getByRole('button', { name: 'Open record' });
+ 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');
+ expect(within(button).getByText('A')).toBeVisible();
+ expect(within(button).getByText('next')).toBeVisible();
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(getComputedStyle(button).outlineStyle).toBe('solid');
+ expect(getComputedStyle(button).outlineWidth).toBe('2px');
expect(args.onClick).toHaveBeenCalledTimes(3);
expect(bubbledClicks).toHaveBeenCalledTimes(3);
},
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.module.scss b/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.module.scss
deleted file mode 100644
index 313fe8a19fa..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.module.scss
+++ /dev/null
@@ -1,13 +0,0 @@
-// Replaces the deprecated framer-motion rotate animation on the sub-menu
-// chevron with an equivalent CSS transform transition.
-.subMenuIcon {
- display: flex;
- align-items: center;
- justify-content: center;
- transform: rotate(0deg);
- transition: transform duration(normal) ease-in-out;
-}
-
-.subMenuIconOpened {
- transform: rotate(90deg);
-}
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.tsx
deleted file mode 100644
index c7a4f19bda0..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-import { isDefined } from '@ui/utilities/utils/isDefined';
-import { IconChevronRight } from '@ui/icon';
-import { type MouseEvent } from 'react';
-import { type MenuItemProps } from './types/MenuItemProps';
-
-import { MenuItemLeftContent } from '@ui/components/navigation/MenuItem/parts/MenuItemLeftContent';
-import {
- StyledHoverableMenuItemBase,
- StyledMenuItemRightContent,
-} from '@ui/components/navigation/MenuItem/parts/StyledMenuItemBase';
-import { Shortcut } from '@ui/primitives/typography/Shortcut/Shortcut';
-import { useTheme } from '@ui/theme';
-import { clsx } from 'clsx';
-
-import styles from './MenuItem.module.scss';
-
-export const MenuItem = ({
- accent = 'default',
- className,
- withIconContainer = false,
- withIconContainerBackground = true,
- iconButtons,
- isIconDisplayedOnHoverOnly = true,
- LeftIcon,
- iconThemeColor,
- LeftComponent,
- RightIcon,
- RightComponent,
- onClick,
- onMouseEnter,
- onMouseLeave,
- testId,
- text,
- contextualTextPosition = 'left',
- contextualText,
- hasSubMenu = false,
- disabled = false,
- focused = false,
- selected = false,
- shortcut,
- shortcutJoinLabel,
- isSubMenuOpened = false,
-}: MenuItemProps) => {
- const theme = useTheme();
- const handleMenuItemClick = (event: MouseEvent<HTMLDivElement>) => {
- if (!onClick) return;
- event.preventDefault();
- event.stopPropagation();
-
- onClick?.(event);
- };
-
- return (
- <StyledHoverableMenuItemBase
- data-testid={testId ?? undefined}
- onClick={disabled ? undefined : handleMenuItemClick}
- disabled={disabled}
- className={className}
- accent={accent}
- isIconDisplayedOnHoverOnly={isIconDisplayedOnHoverOnly}
- onMouseEnter={onMouseEnter}
- onMouseLeave={onMouseLeave}
- focused={focused || selected}
- >
- <MenuItemLeftContent
- LeftIcon={LeftIcon ?? undefined}
- iconThemeColor={iconThemeColor}
- LeftComponent={LeftComponent}
- withIconContainer={withIconContainer}
- withIconContainerBackground={withIconContainerBackground}
- text={text}
- contextualText={contextualText}
- contextualTextPosition={contextualTextPosition}
- disabled={disabled}
- />
-
- <StyledMenuItemRightContent>
- {iconButtons && (
- <StyledMenuItemRightContent className="hoverable-buttons">
- {iconButtons}
- </StyledMenuItemRightContent>
- )}
- {isDefined(shortcut) && (
- <Shortcut shortcut={shortcut} sequenceJoinLabel={shortcutJoinLabel} />
- )}
- {RightIcon && (
- <RightIcon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
- )}
- {RightComponent}
- {hasSubMenu && (
- <div
- className={clsx(
- styles.subMenuIcon,
- isSubMenuOpened && styles.subMenuIconOpened,
- )}
- style={{ visibility: disabled ? 'hidden' : 'visible' }}
- >
- <IconChevronRight
- size={theme.icon.size.sm}
- color={theme.font.color.light}
- />
- </div>
- )}
- </StyledMenuItemRightContent>
- </StyledHoverableMenuItemBase>
- );
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/__stories__/MenuItem.stories.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/__stories__/MenuItem.stories.tsx
deleted file mode 100644
index ae03246f9ef..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/__stories__/MenuItem.stories.tsx
+++ /dev/null
@@ -1,349 +0,0 @@
-import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';
-import { LightIconButton } from '@ui/components/input/LightIconButton/LightIconButton';
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { action } from 'storybook/actions';
-
-import { MenuItem } from '@ui/components/navigation/MenuItem/MenuItem';
-import { type MenuItemAccent } from '@ui/components/navigation/MenuItem/types/MenuItemAccent';
-import { IconBell, IconCopy } from '@ui/icon';
-import {
- A11Y_DEFER_COLOR_CONTRAST,
- CatalogDecorator,
- ComponentDecorator,
- type CatalogStory,
-} from '@ui/testing';
-
-const meta: Meta<typeof MenuItem> = {
- id: 'ui-navigation-menu-menuitem-menuitem',
- title: 'UI/Components/Navigation/MenuItem/MenuItem',
- component: MenuItem,
-};
-
-export default meta;
-
-type Story = StoryObj<typeof MenuItem>;
-
-export const Display: Story = {
- args: {
- text: 'Copy record',
- LeftIcon: IconCopy,
- shortcut: ['Mod', 'C'],
- },
- decorators: [ComponentDecorator],
-};
-
-export const WithActions: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: {
- text: 'Menu item text',
- LeftIcon: IconBell,
- accent: 'default',
- iconButtons: (
- <ButtonGroup attached={false}>
- <LightIconButton aria-label={'Notify'} onClick={action('Clicked')}>
- <IconBell />
- </LightIconButton>
- <LightIconButton aria-label={'Notify'} onClick={action('Clicked')}>
- <IconBell />
- </LightIconButton>
- </ButtonGroup>
- ),
- },
- decorators: [ComponentDecorator],
-};
-
-export const Catalog: CatalogStory<Story, typeof MenuItem> = {
- args: { ...WithActions.args },
- argTypes: {
- accent: { control: false },
- className: { control: false },
- iconButtons: { control: false },
- },
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- pseudo: { hover: ['.hover'], active: ['.pressed'], focus: ['.focus'] },
- catalog: {
- dimensions: [
- {
- name: 'withIcon',
- values: [true, false],
- props: (withIcon: boolean) => ({
- LeftIcon: withIcon ? IconBell : undefined,
- }),
- labels: (withIcon: boolean) =>
- withIcon ? 'With left icon' : 'Without left icon',
- },
- {
- name: 'withIconContainer',
- values: [true, false],
- props: (withIconContainer: boolean) => ({ withIconContainer }),
- labels: (withIconContainer: boolean) =>
- withIconContainer
- ? 'With icon container'
- : 'Without icon container',
- },
- {
- name: 'accents',
- values: ['default', 'danger'] satisfies MenuItemAccent[],
- props: (accent: MenuItemAccent) => ({ accent }),
- },
- {
- name: 'states',
- values: ['default', 'hover'],
- props: (state: string) => {
- switch (state) {
- case 'default':
- return {};
- case 'hover':
- return { className: state };
- default:
- return {};
- }
- },
- },
- {
- name: 'iconButtons',
- values: ['no icon button', 'two icon buttons'],
- props: (choice: string) => {
- switch (choice) {
- case 'no icon button': {
- return {
- iconButtons: null,
- };
- }
- case 'two icon buttons': {
- return {
- iconButtons: (
- <ButtonGroup attached={false}>
- <LightIconButton
- aria-label={'Notify'}
- onClick={action('Clicked on first icon button')}
- >
- <IconBell />
- </LightIconButton>
- <LightIconButton
- aria-label={'Notify'}
- onClick={action('Clicked on second icon button')}
- >
- <IconBell />
- </LightIconButton>
- </ButtonGroup>
- ),
- };
- }
- default:
- return {};
- }
- },
- },
- {
- name: 'disabled',
- values: [true, false],
- props: (disabled: boolean) => ({ disabled }),
- },
- ],
- options: {
- elementContainer: {
- width: 200,
- },
- },
- },
- },
- decorators: [CatalogDecorator],
-};
-
-export const HotKeysCatalog: CatalogStory<Story, typeof MenuItem> = {
- args: {
- text: 'Menu item with shortcut',
- LeftIcon: IconBell,
- shortcut: ['Mod', 'K'],
- },
- argTypes: {
- className: { control: false },
- iconButtons: { control: false },
- },
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- pseudo: { hover: ['.hover'], active: ['.pressed'], focus: ['.focus'] },
- catalog: {
- dimensions: [
- {
- name: 'hotKeyTypes',
- values: ['no shortcut', 'single key', 'modifier + key'],
- props: (choice: string) => {
- switch (choice) {
- case 'no shortcut':
- return { shortcut: undefined };
- case 'single key':
- return { shortcut: ['K'] };
- case 'modifier + key':
- return {
- shortcut: ['Mod', 'K'],
- };
- default:
- return {};
- }
- },
- labels: (choice: string) => {
- switch (choice) {
- case 'no shortcut':
- return 'No shortcut';
- case 'single key':
- return 'Single key (K)';
- case 'modifier + key':
- return 'Modifier + key (⌘K)';
- default:
- return choice;
- }
- },
- },
- {
- name: 'states',
- values: ['default', 'hover'],
- props: (state: string) => {
- switch (state) {
- case 'default':
- return {};
- case 'hover':
- return { className: 'hover' };
- default:
- return {};
- }
- },
- },
- ],
- options: {
- elementContainer: {
- width: 300,
- },
- },
- },
- },
- decorators: [CatalogDecorator],
-};
-
-export const ContextualTextCatalog: CatalogStory<Story, typeof MenuItem> = {
- args: {
- text: 'Menu item with contextual text',
- },
- decorators: [CatalogDecorator],
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- pseudo: { hover: ['.hover'], active: ['.pressed'], focus: ['.focus'] },
- catalog: {
- dimensions: [
- {
- name: 'contextualTextPosition',
- values: ['left', 'right'],
- props: (contextualTextPosition: 'left' | 'right') => ({
- contextualTextPosition,
- }),
- labels: (contextualTextPosition: 'left' | 'right') =>
- contextualTextPosition === 'left' ? 'Left' : 'Right',
- },
- {
- name: 'contextualText',
- values: [
- 'Contextual text',
- 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Eveniet, corporis.',
- ],
- props: (contextualText: string) => ({ contextualText }),
- labels: (contextualText: string) => {
- switch (contextualText) {
- case 'Contextual text':
- return 'Contextual text';
- case 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Eveniet, corporis.':
- return 'Long contextual text';
- default:
- return contextualText;
- }
- },
- },
- {
- name: 'iconButtons',
- values: ['no icon button', 'one icon button'],
- props: (choice: string) => {
- switch (choice) {
- case 'no icon button': {
- return {
- iconButtons: null,
- };
- }
- case 'one icon button': {
- return {
- iconButtons: (
- <LightIconButton
- aria-label={'Notify'}
- onClick={action('Clicked on icon button')}
- >
- <IconBell />
- </LightIconButton>
- ),
- };
- }
- default:
- return {};
- }
- },
- labels: (choice: string) => {
- switch (choice) {
- case 'no icon button':
- return 'No icon button';
- case 'one icon button':
- return 'One icon button';
- default:
- return choice;
- }
- },
- },
- {
- name: 'states',
- values: ['default', 'hover'],
- props: (state: string) => {
- switch (state) {
- case 'default':
- return {};
- case 'hover':
- return { className: 'hover' };
- default:
- return {};
- }
- },
- },
- ],
- options: {
- elementContainer: {
- style: { width: '400px', overflow: 'hidden' },
- },
- },
- },
- },
-};
-
-export const SubMenuCatalog: CatalogStory<Story, typeof MenuItem> = {
- args: {
- text: 'Menu item with sub menu',
- LeftIcon: IconBell,
- hasSubMenu: true,
- },
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- catalog: {
- dimensions: [
- {
- name: 'isSubMenuOpened',
- values: [true, false],
- props: (isSubMenuOpened: boolean) => ({ isSubMenuOpened }),
- labels: (isSubMenuOpened: boolean) =>
- isSubMenuOpened ? 'Opened' : 'Closed',
- },
- ],
- options: {
- elementContainer: {
- width: 200,
- },
- },
- },
- },
- decorators: [CatalogDecorator],
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemProps.ts b/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemProps.ts
deleted file mode 100644
index 0bad177e6e3..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemProps.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { type ShortcutDefinition } from '@ui/primitives/typography/Shortcut/types/ShortcutDefinition';
-import { type MenuItemAccent } from '@ui/components/navigation/MenuItem/types/MenuItemAccent';
-import { type IconComponent } from '@ui/icon';
-import { type ThemeColor } from '@ui/theme';
-import { type MouseEvent, type ReactNode } from 'react';
-
-export type MenuItemProps = {
- accent?: MenuItemAccent;
- className?: string;
- withIconContainer?: boolean;
- withIconContainerBackground?: boolean;
- iconButtons?: ReactNode;
- isIconDisplayedOnHoverOnly?: boolean;
- isTooltipOpen?: boolean;
- LeftIcon?: IconComponent | null;
- iconThemeColor?: ThemeColor | null;
- LeftComponent?: ReactNode;
- RightIcon?: IconComponent | null;
- RightComponent?: ReactNode;
- onClick?: (event: MouseEvent<HTMLDivElement>) => void;
- onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void;
- onMouseLeave?: (event: MouseEvent<HTMLDivElement>) => void;
- testId?: string;
- disabled?: boolean;
- text: ReactNode;
- contextualTextPosition?: 'left' | 'right';
- contextualText?: ReactNode;
- hasSubMenu?: boolean;
- focused?: boolean;
- selected?: boolean;
- shortcut?: ShortcutDefinition;
- shortcutJoinLabel?: string;
- isSubMenuOpened?: boolean;
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemAvatar/MenuItemAvatar.tsx b/packages/twenty-ui/src/components/navigation/MenuItemAvatar/MenuItemAvatar.tsx
deleted file mode 100644
index d4dd2d37ea4..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemAvatar/MenuItemAvatar.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { MenuItem } from '@ui/components/navigation/MenuItem/MenuItem';
-import { Avatar } from '@ui/primitives/data-display/Avatar/Avatar';
-import { isDefined } from '@ui/utilities/utils/isDefined';
-import { type MenuItemAvatarProps } from './types/MenuItemAvatarProps';
-
-export const MenuItemAvatar = ({
- accent = 'default',
- className,
- iconButtons,
- isIconDisplayedOnHoverOnly = true,
- isTooltipOpen,
- onClick,
- onMouseEnter,
- onMouseLeave,
- testId,
- avatar,
- hasSubMenu = false,
- text,
- contextualText,
-}: MenuItemAvatarProps) => {
- return (
- <MenuItem
- accent={accent}
- className={className}
- iconButtons={iconButtons}
- isIconDisplayedOnHoverOnly={isIconDisplayedOnHoverOnly}
- isTooltipOpen={isTooltipOpen}
- LeftComponent={
- isDefined(avatar) ? (
- <Avatar
- name={avatar.name}
- src={avatar.src}
- colorSeed={avatar.colorSeed}
- size={avatar.size}
- shape={avatar.shape}
- />
- ) : undefined
- }
- onClick={onClick}
- onMouseEnter={onMouseEnter}
- onMouseLeave={onMouseLeave}
- testId={testId}
- text={text}
- contextualText={contextualText}
- hasSubMenu={hasSubMenu}
- />
- );
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemAvatar/__stories__/MenuItemAvatar.stories.tsx b/packages/twenty-ui/src/components/navigation/MenuItemAvatar/__stories__/MenuItemAvatar.stories.tsx
deleted file mode 100644
index 02252eadbba..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemAvatar/__stories__/MenuItemAvatar.stories.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-
-import { ComponentDecorator } from '@ui/testing';
-import { MenuItemAvatar } from '../MenuItemAvatar';
-
-const meta: Meta<typeof MenuItemAvatar> = {
- title: 'UI/Components/Navigation/MenuItemAvatar',
- component: MenuItemAvatar,
- decorators: [ComponentDecorator],
- parameters: { container: { width: 280 } },
-};
-
-export default meta;
-type Story = StoryObj<typeof MenuItemAvatar>;
-
-export const Display: Story = {
- args: {
- text: 'Ada Lovelace',
- avatar: { name: 'Ada Lovelace', shape: 'circle' },
- },
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemAvatar/types/MenuItemAvatarProps.ts b/packages/twenty-ui/src/components/navigation/MenuItemAvatar/types/MenuItemAvatarProps.ts
deleted file mode 100644
index 31602dcfa70..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemAvatar/types/MenuItemAvatarProps.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { type MenuItemAccent } from '@ui/components/navigation/MenuItem/types/MenuItemAccent';
-import { type AvatarProps } from '@ui/primitives/data-display/Avatar/types/AvatarProps';
-import { type MouseEvent, type ReactNode } from 'react';
-
-export type MenuItemAvatarProps = {
- accent?: MenuItemAccent;
- className?: string;
- iconButtons?: ReactNode;
- isIconDisplayedOnHoverOnly?: boolean;
- isTooltipOpen?: boolean;
- avatar?: Pick<
- AvatarProps,
- 'src' | 'colorSeed' | 'name' | 'size' | 'shape'
- > | null;
- onClick?: (event: MouseEvent<HTMLDivElement>) => void;
- onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void;
- onMouseLeave?: (event: MouseEvent<HTMLDivElement>) => void;
- testId?: string;
- text: string;
- hasSubMenu?: boolean;
- contextualText?: ReactNode;
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/__tests__/MenuItemIconButtons.test.tsx b/packages/twenty-ui/src/components/navigation/MenuItemDraggable/__tests__/MenuItemDraggableIconButtons.test.tsx
similarity index 84%
rename from packages/twenty-ui/src/components/navigation/MenuItem/__tests__/MenuItemIconButtons.test.tsx
rename to packages/twenty-ui/src/components/navigation/MenuItemDraggable/__tests__/MenuItemDraggableIconButtons.test.tsx
index 406fbd07ea9..775b50348be 100644
--- a/packages/twenty-ui/src/components/navigation/MenuItem/__tests__/MenuItemIconButtons.test.tsx
+++ b/packages/twenty-ui/src/components/navigation/MenuItemDraggable/__tests__/MenuItemDraggableIconButtons.test.tsx
@@ -3,23 +3,17 @@ import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';
import { LightIconButton } from '@ui/components/input/LightIconButton/LightIconButton';
-import { MenuItem } from '@ui/components/navigation/MenuItem/MenuItem';
-import { MenuItemAvatar } from '@ui/components/navigation/MenuItemAvatar/MenuItemAvatar';
import { MenuItemDraggable } from '@ui/components/navigation/MenuItemDraggable/MenuItemDraggable';
import { IconSearch, IconTrash } from '@ui/icon';
import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';
-describe.each([
- { name: 'MenuItem', Component: MenuItem },
- { name: 'MenuItemDraggable', Component: MenuItemDraggable },
- { name: 'MenuItemAvatar', Component: MenuItemAvatar },
-])('$name icon buttons', ({ Component }) => {
+describe('MenuItemDraggable icon buttons', () => {
it('preserves disabled buttons and wrapper-controlled triggers', async () => {
const user = userEvent.setup();
const onDelete = vi.fn();
const onSearch = vi.fn();
render(
- <Component
+ <MenuItemDraggable
text="Record"
iconButtons={
<ButtonGroup attached={false} onClick={onSearch}>
@@ -52,7 +46,7 @@ describe.each([
const onClick = vi.fn((event) => event.stopPropagation());
render(
<form onSubmit={onSubmit}>
- <Component
+ <MenuItemDraggable
text="Record"
onClick={onParentClick}
iconButtons={
diff --git a/packages/twenty-ui/src/components/navigation/index.ts b/packages/twenty-ui/src/components/navigation/index.ts
index f1b48108fbd..8549090e9f1 100644
--- a/packages/twenty-ui/src/components/navigation/index.ts
+++ b/packages/twenty-ui/src/components/navigation/index.ts
@@ -32,13 +32,9 @@ 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';
export type { MenuItemAccent } from './MenuItem/types/MenuItemAccent';
export type { MenuItemDraggableGripMode } from './MenuItem/types/MenuItemDraggableGripMode';
-export type { MenuItemProps } from './MenuItem/types/MenuItemProps';
-export { MenuItemAvatar } from './MenuItemAvatar/MenuItemAvatar';
-export type { MenuItemAvatarProps } from './MenuItemAvatar/types/MenuItemAvatarProps';
export { MenuItemDraggable } from './MenuItemDraggable/MenuItemDraggable';
export type { MenuItemDraggableProps } from './MenuItemDraggable/types/MenuItemDraggableProps';
export { MenuItemSuggestion } from './MenuItemSuggestion/MenuItemSuggestion';
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemAvatarMultiSelect.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemAvatarMultiSelect.stories.tsx
index b9e72df619c..d7b618e637d 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemAvatarMultiSelect.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemAvatarMultiSelect.stories.tsx
@@ -10,7 +10,7 @@ import {
import { ListItem } from '../ListItem';
const meta: Meta<typeof ListItem> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemMultiSelectAvatar',
+ title: 'UI/Navigation/ListItem/Avatar multiple selection',
component: ListItem,
args: {
role: 'option',
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemAvatarSelect.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemAvatarSelect.stories.tsx
index 3022113f2d5..fe1958e70c0 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemAvatarSelect.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemAvatarSelect.stories.tsx
@@ -9,7 +9,7 @@ import {
import { ListItem } from '../ListItem';
const meta: Meta<typeof ListItem> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemSelectAvatar',
+ title: 'UI/Navigation/ListItem/Avatar selection',
component: ListItem,
args: {
role: 'option',
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemColorSelect.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemColorSelect.stories.tsx
index 50b1268e902..198469862e3 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemColorSelect.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemColorSelect.stories.tsx
@@ -9,7 +9,7 @@ import {
import { ListItem } from '../ListItem';
const meta: Meta<typeof ListItem> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemSelectColor',
+ title: 'UI/Navigation/ListItem/Color selection',
component: ListItem,
args: {
role: 'option',
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMultiSelect.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMultiSelect.stories.tsx
index d8a95aa685a..55338a40836 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMultiSelect.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemMultiSelect.stories.tsx
@@ -9,7 +9,7 @@ import {
import { ListItem } from '../ListItem';
const meta: Meta<typeof ListItem> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemMultiSelect',
+ title: 'UI/Navigation/ListItem/Multiple selection',
component: ListItem,
args: {
role: 'option',
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemSingleSelect.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemSingleSelect.stories.tsx
index c35f2bfc4bb..0627daecf9e 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemSingleSelect.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemSingleSelect.stories.tsx
@@ -9,7 +9,7 @@ import {
import { ListItem } from '../ListItem';
const meta: Meta<typeof ListItem> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemSelect',
+ title: 'UI/Navigation/ListItem/Single selection',
component: ListItem,
args: {
role: 'option',
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemTagMultiSelect.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemTagMultiSelect.stories.tsx
index eb09107fdc6..79c9a2d7ff1 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemTagMultiSelect.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemTagMultiSelect.stories.tsx
@@ -9,7 +9,7 @@ import {
import { ListItem } from '../ListItem';
const meta: Meta<typeof ListItem> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemMultiSelectTag',
+ title: 'UI/Navigation/ListItem/Tag multiple selection',
component: ListItem,
args: {
role: 'option',
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemTagSelect.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemTagSelect.stories.tsx
index ab3df40fdef..32be3dc852c 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemTagSelect.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItemTagSelect.stories.tsx
@@ -9,7 +9,7 @@ import {
import { ListItem } from '../ListItem';
const meta: Meta<typeof ListItem> = {
- title: 'UI/Navigation/Menu/MenuItem/MenuItemSelectTag',
+ title: 'UI/Navigation/ListItem/Tag selection',
component: ListItem,
args: {
role: 'option',