Skip to content

The open alternative to Salesforce, designed for AI.

Retire specialized menu rows (#28290)

Raphaël Bosi3f07efadeda5
diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.json
index 0dd8479c4b6..71417806a38 100644
--- a/packages/twenty-docs/docs.json
+++ b/packages/twenty-docs/docs.json
@@ -672,8 +672,6 @@
"pages": [
"ui/components/navigation/list-item-button",
"ui/components/navigation/dropdown",
- "ui/components/navigation/menu-items",
- "ui/components/navigation/menu-picker",
"ui/components/navigation/tab-button"
]
},
diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.json
index 7fa72156940..c4a719465a2 100644
--- a/packages/twenty-docs/navigation/base-structure.json
+++ b/packages/twenty-docs/navigation/base-structure.json
@@ -695,8 +695,6 @@
"pages": [
"ui/components/navigation/list-item-button",
"ui/components/navigation/dropdown",
- "ui/components/navigation/menu-items",
- "ui/components/navigation/menu-picker",
"ui/components/navigation/tab-button"
]
},
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-draggable.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-draggable.mdx
deleted file mode 100644
index 91781854013..00000000000
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-draggable.mdx
+++ /dev/null
@@ -1,68 +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="gripMode" type="&quot;always&quot; | &quot;never&quot; | &quot;onHover&quot;" default="never">
- Grip visibility: never, always, or onHover. always and onHover render a single leading content (LeftComponent when set, otherwise LeftIcon); onHover swaps it for the grip on hover and shows no grip without leading content. Does not implement dragging.
-</ParamField>
-
-<ParamField body="iconButtons" type="ReactNode">
- Trailing action elements.
-</ParamField>
-
-<ParamField body="isDragDisabled" type="boolean" default="false">
- Disables drag appearance without installing or removing drag handlers.
-</ParamField>
-
-<ParamField body="isHoverDisabled" type="boolean">
- Accepted for compatibility; currently has no effect.
-</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="LeftComponent" type="ReactNode">
- Custom leading content.
-</ParamField>
-
-<ParamField body="LeftIcon" type="IconComponent">
- Leading icon component.
-</ParamField>
-
-<ParamField body="onClick" type="(() =&gt; void)">
- Pointer activation callback. The row itself does not add keyboard or menu semantics.
-</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>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-suggestion.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-suggestion.mdx
deleted file mode 100644
index cb44671a767..00000000000
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-suggestion.mdx
+++ /dev/null
@@ -1,44 +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="className" type="string">
- Class applied to the row.
-</ParamField>
-
-<ParamField body="contextualText" type="string">
- 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="LeftIcon" type="IconComponent | null">
- Leading icon component.
-</ParamField>
-
-<ParamField body="onClick" type="((event: MouseEvent&lt;HTMLLIElement, MouseEvent&gt;) =&gt; void)">
- Activation callback. When supplied, the row gains button semantics, a tab stop, and Enter/Space activation.
-</ParamField>
-
-<ParamField body="selected" type="boolean">
- Applies selected styling. The application owns selection.
-</ParamField>
-
-<ParamField body="text" type="string" required>
- Main row label.
-</ParamField>
-
-<ParamField body="withIconContainer" type="boolean" default="false">
- Places leading content in an icon container.
-</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-picker.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-picker.mdx
deleted file mode 100644
index fb2ed087f6b..00000000000
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-picker.mdx
+++ /dev/null
@@ -1,60 +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="className" type="string">
- Class applied to the button.
-</ParamField>
-
-<ParamField body="disabled" type="boolean" default="false">
- Disables the button.
-</ParamField>
-
-<ParamField body="icon" type="IconComponent" required>
- Leading icon component.
-</ParamField>
-
-<ParamField body="id" type="string" required>
- Button ID.
-</ParamField>
-
-<ParamField body="label" type="string">
- Button label and accessible name, including when showLabel is false.
-</ParamField>
-
-<ParamField body="onClick" type="(() =&gt; void)">
- Activation callback.
-</ParamField>
-
-<ParamField body="selected" type="boolean" default="false">
- Controls selected styling and aria-pressed.
-</ParamField>
-
-<ParamField body="showLabel" type="boolean" default="true">
- Shows the visible label beside the icon.
-</ParamField>
-
-<ParamField body="testId" type="string">
- Value of the button’s data-testid attribute.
-</ParamField>
-
-<ParamField body="tooltipContent" type="string">
- Optional tooltip text.
-</ParamField>
-
-<ParamField body="tooltipDelay" type="number" default="0">
- Hover delay in milliseconds.
-</ParamField>
-
-<ParamField body="tooltipOffset" type="number" default="5">
- Distance between the button and tooltip in pixels.
-</ParamField>
diff --git a/packages/twenty-docs/ui/components/navigation/menu-items.mdx b/packages/twenty-docs/ui/components/navigation/menu-items.mdx
deleted file mode 100644
index bf3de7a9884..00000000000
--- a/packages/twenty-docs/ui/components/navigation/menu-items.mdx
+++ /dev/null
@@ -1,67 +0,0 @@
----
-title: Menu rows
-description: MenuItemDraggable and MenuItemSuggestion presentation presets.
----
-
-import { StoryEmbed } from '/snippets/ui/StoryEmbed.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).
-
-## MenuItemDraggable
-
-<StoryEmbed
- storyId="ui-navigation-menu-menuitem-menuitemdraggable--display"
- title="Row with a drag grip"
- height={110}
-/>
-
-`MenuItemDraggable` renders a menu row that can show a drag grip. The application supplies drag behavior. `gripMode` defaults to `never`, which shows no grip; `always` shows the grip, and `onHover` swaps the leading content (`LeftComponent`, otherwise `LeftIcon`) for the grip while the row is hovered, so it shows nothing without leading content. `isDragDisabled` affects the appearance, not external drag handlers.
-
-```tsx
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
-
-export const ReorderRowPreview = () => (
- <MenuItemDraggable text="Company name" gripMode="always" />
-);
-```
-
-The root remains a div without keyboard drag behavior. `isTooltipOpen` and `isHoverDisabled` are currently accepted but unused. Provide an accessible reordering interface in the surrounding application.
-
-## MenuItemSuggestion
-
-<StoryEmbed
- storyId="ui-components-navigation-menuitemsuggestion--display"
- title="Suggested company with supporting text"
- height={110}
-/>
-
-`MenuItemSuggestion` presents a suggested value with an optional icon and supporting text. Without `onClick`, keep its `li` root inside a semantic list. `selected` changes its appearance without adding selection behavior.
-
-```tsx
-import { MenuItemSuggestion } from 'twenty-ui/components/navigation';
-import { Text } from 'twenty-ui/primitives/typography';
-
-export const SuggestedName = () => (
- <Text
- render={<ul />}
- style={{ margin: 0, padding: 0, listStyle: 'none', width: '100%' }}
- >
- <MenuItemSuggestion text="Acme" contextualText="Company" />
- </Text>
-);
-```
-
-Supplying `onClick` gives the row button semantics, a tab stop, and Enter/Space activation. Place clickable rows in `<ul role="none">` because their `li` roots expose `button` instead of `listitem`. For a complete selection or action workflow, prefer [Dropdown.OptionItem](/ui/components/navigation/dropdown) or [ListItemButton](/ui/components/navigation/list-item-button).
-
-## Props
-
-### MenuItemDraggable
-
-<MenuItemDraggableReference />
-
-### MenuItemSuggestion
-
-<MenuItemSuggestionReference />
diff --git a/packages/twenty-docs/ui/components/navigation/menu-picker.mdx b/packages/twenty-docs/ui/components/navigation/menu-picker.mdx
deleted file mode 100644
index 33d7785682e..00000000000
--- a/packages/twenty-docs/ui/components/navigation/menu-picker.mdx
+++ /dev/null
@@ -1,54 +0,0 @@
----
-title: MenuPicker
-description: A compact icon button with selected styling and an optional tooltip.
----
-
-import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
-
-import MenuPickerReference from '/snippets/ui/generated/components/navigation/menu-picker.mdx';
-
-`MenuPicker` renders a native button. Your application owns `selected` and the action. `selected` also controls `aria-pressed`.
-
-<StoryEmbed
- storyId="ui-navigation-menu-menupicker--display"
- title="Toggle the board view"
- height={130}
-/>
-
-## Usage
-
-```tsx
-import { useState } from 'react';
-import { MenuPicker } from 'twenty-ui/components/navigation';
-import { IconLayoutKanban } from 'twenty-ui/icon';
-
-export const BoardToggle = () => {
- const [selected, setSelected] = useState(false);
-
- return (
- <MenuPicker
- id="board-toggle"
- icon={IconLayoutKanban}
- label="Board view"
- selected={selected}
- onClick={() => setSelected(!selected)}
- />
- );
-};
-```
-
-Keep `label` even with `showLabel={false}` because it supplies the accessible name. `tooltipContent` adds a supplementary explanation. `disabled` prevents activation. Place the button outside a form unless its default native submission behavior is appropriate.
-
-## Visual options
-
-Compare selected and disabled appearances, hidden labels, and supplemental tooltips.
-
-<StoryEmbed
- storyId="ui-navigation-menu-menupicker--all-states"
- title="Menu picker presentation choices"
- height={280}
-/>
-
-## Props
-
-<MenuPickerReference />
diff --git a/packages/twenty-docs/ui/components/overview.mdx b/packages/twenty-docs/ui/components/overview.mdx
index 8ac1c66b3aa..1c65040d86b 100644
--- a/packages/twenty-docs/ui/components/overview.mdx
+++ b/packages/twenty-docs/ui/components/overview.mdx
@@ -34,8 +34,6 @@ Import from `twenty-ui/components/navigation`.
| [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 43b1dc4451c..f97bf541385 100644
--- a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
+++ b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
@@ -162,6 +162,14 @@ export const OpenRecord = ({ onOpen }: OpenRecordProps) => (
The caller also owns any `preventDefault()` policy, such as preventing a link's navigation. Passing `onClick` does not add a role, make a `div` keyboard-operable, or change propagation.
+## Application-owned drag and editor navigation
+
+Compose reorderable rows with `ListItem` inside your application's drag host. Put the host's drag attributes and listeners on its handle, and pass the handle or grip through `startIcon`. Keep independent visibility, edit and delete controls in `actions`. The drag host owns pointer and keyboard reordering, disabled dragging and accessible handle labels.
+
+For editor suggestions, keep the editor's existing listbox and active option owner. Render each `ListItem` with `role="option"` and `aria-selected`, and use `focused` for the active row's appearance. The editor owns arrow navigation and Enter activation while focus stays in the editing surface. Prevent pointer-down focus changes when the editor requires them, and handle pointer selection in the application's row handler.
+
+For suggestions in a Dropdown page, use `Dropdown.OptionItem` or `Dropdown.ActionItem` so that page owns navigation and activation. Do not add a second Enter or Space handler to an owner that already activates from the keyboard.
+
## Settings row
Use [SettingsRow](/ui/components/settings/settings-row) for a labeled switch row. It composes `ListItem` and `Switch`, manages their accessible association, and uses the switch’s disabled state for the row’s appearance.
diff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
index 354ce8375be..abb316ccaeb 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -27,6 +27,7 @@ import { pickerListItemsTest } from '@/__stories__/twenty-ui-gallery/utils/picke
import { iconButtonElevatedTest } from '@/__stories__/twenty-ui-gallery/utils/iconButtonElevatedTest';
import { buttonContractsTest } from '@/__stories__/twenty-ui-gallery/utils/buttonContractsTest';
import { buttonControlsTest } from '@/__stories__/twenty-ui-gallery/utils/buttonControlsTest';
+import { navigationControlsTest } from '@/__stories__/twenty-ui-gallery/utils/navigationControlsTest';
import { responsiveHooksTest } from '@/__stories__/twenty-ui-gallery/utils/responsiveHooksTest';
import { RESPONSIVE_HOOKS_WIDGET_SIZING } from '@/__stories__/twenty-ui-gallery/constants/RESPONSIVE_HOOKS_WIDGET_SIZING';
import { dialogTest } from '@/__stories__/twenty-ui-gallery/utils/dialogTest';
@@ -230,12 +231,12 @@ export const ResizeHandlePreact: Story = createGalleryStory({
export const NavigationReact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-navigation-gallery',
runtime: 'react',
- play: galleryRenderTest,
+ play: navigationControlsTest,
});
export const NavigationPreact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-navigation-gallery',
runtime: 'preact',
- play: galleryRenderTest,
+ play: navigationControlsTest,
});
export const SurfacesReact: Story = createGalleryStory({
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 fd75a2c3a24..a89eaed11e8 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,8 +7,7 @@ import {
MainButton,
} from 'twenty-ui/components/input';
import { AnimatedIconCrossfade } from 'twenty-ui/components/layout';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
-import { IconPencil, IconPlus, IconX } from 'twenty-ui/icon';
+import { IconGripVertical, 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';
@@ -109,10 +108,10 @@ const ButtonControls = () => {
>
Record
</ListItem>
- <MenuItemDraggable
- text="Draggable record"
- isIconDisplayedOnHoverOnly={false}
- iconButtons={
+ <ListItem
+ startIcon={<IconGripVertical />}
+ actionsVisibility="always"
+ actions={
<LightIconButton
aria-label="Add to draggable record"
onClick={handleClick}
@@ -120,7 +119,9 @@ const ButtonControls = () => {
<IconPlus />
</LightIconButton>
}
- />
+ >
+ Draggable record
+ </ListItem>
<Button variant="link" onClick={handleClick}>
Log out
</Button>
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 a4666f6a2d2..7ef7f14c99f 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,13 +1,13 @@
+import { useState } from 'react';
import { defineFrontComponent } from 'twenty-sdk/define';
import {
DEFAULT_COLOR_LABELS,
- MenuItemDraggable,
- MenuItemSuggestion,
- MenuPicker,
+ ListItemButton,
} from 'twenty-ui/components/navigation';
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
-import { IconHome, IconUser } from 'twenty-ui/icon';
+import { IconGripVertical, IconHome, IconUser } from 'twenty-ui/icon';
import { Avatar, ColorSample, Tag } from 'twenty-ui/primitives/data-display';
+import { Button } from 'twenty-ui/primitives/input';
import { Breadcrumb, ListItem } from 'twenty-ui/primitives/navigation';
import { ThemeProvider } from 'twenty-ui/theme';
import {
@@ -45,13 +45,18 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
),
},
{
- name: 'MenuItemDraggable',
+ name: 'Draggable row presentation',
node: (
- <MenuItemDraggable
- text="Draggable"
- LeftIcon={IconUser}
- gripMode="always"
- />
+ <ListItem
+ startIcon={
+ <>
+ <IconGripVertical />
+ <IconUser />
+ </>
+ }
+ >
+ Draggable
+ </ListItem>
),
},
{
@@ -128,24 +133,67 @@ const NAVIGATION_ENTRIES: GalleryEntry[] = [
</ListItem>
),
},
- {
- name: 'MenuItemSuggestion',
- node: <MenuItemSuggestion text="Suggestion" onClick={() => {}} />,
- },
- {
- name: 'MenuPicker',
- node: <MenuPicker id="picker-1" icon={IconHome} label="Picker" />,
- },
];
-const NavigationGallery = () => (
- <ThemeProvider colorScheme="light">
- <ComponentGallery
- title="twenty-ui/primitives/navigation"
- entries={NAVIGATION_ENTRIES}
- />
- </ThemeProvider>
-);
+const NavigationGallery = () => {
+ const [suggestionActivations, setSuggestionActivations] = useState(0);
+ const [pickerActivations, setPickerActivations] = useState(0);
+ const [isPickerSelected, setIsPickerSelected] = useState(false);
+
+ return (
+ <ThemeProvider colorScheme="light">
+ <ComponentGallery
+ title="twenty-ui/primitives/navigation"
+ entries={[
+ ...NAVIGATION_ENTRIES,
+ {
+ name: 'Suggestion action',
+ node: (
+ <ListItemButton
+ selected
+ startIcon={<IconUser />}
+ onClick={() => setSuggestionActivations((count) => count + 1)}
+ >
+ Suggestion
+ </ListItemButton>
+ ),
+ },
+ {
+ name: 'Picker toggle',
+ node: (
+ <Button
+ startIcon={<IconHome />}
+ aria-pressed={isPickerSelected}
+ onClick={() => {
+ setIsPickerSelected((selected) => !selected);
+ setPickerActivations((count) => count + 1);
+ }}
+ >
+ Picker
+ </Button>
+ ),
+ },
+ {
+ name: 'Disabled picker toggle',
+ node: (
+ <Button
+ disabled
+ aria-pressed={false}
+ onClick={() => setPickerActivations((count) => count + 1)}
+ >
+ Disabled picker
+ </Button>
+ ),
+ },
+ ]}
+ />
+ <output aria-label="Suggestion activations">
+ {suggestionActivations}
+ </output>
+ <output aria-label="Picker activations">{pickerActivations}</output>
+ </ThemeProvider>
+ );
+};
export default defineFrontComponent({
universalIdentifier: 'test-20ui0-0000-0000-0000-000000000108',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonControlsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonControlsTest.ts
index 4f484a20fdd..014f5af57ce 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonControlsTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonControlsTest.ts
@@ -80,23 +80,26 @@ export const buttonControlsTest: TwentyUiGalleryPlayFunction = async (
await expect(getComputedStyle(send).borderTopLeftRadius).toBe('50%');
await userEvent.click(canvas.getByRole('button', { name: 'Add to record' }));
- await userEvent.click(
- canvas.getByRole('button', { name: 'Add to draggable record' }),
- );
+ const draggableRecordAction = canvas.getByRole('button', {
+ name: 'Add to draggable record',
+ });
+ await userEvent.click(draggableRecordAction);
+ draggableRecordAction.focus();
+ await userEvent.keyboard('{Enter} ');
const unavailableRecordButton = canvas.getByRole('button', {
name: 'Unavailable record button',
});
await expect(unavailableRecordButton).toBeDisabled();
await userEvent.click(unavailableRecordButton);
await waitFor(() =>
- expect(canvas.getByLabelText('Activations')).toHaveTextContent('7'),
+ expect(canvas.getByLabelText('Activations')).toHaveTextContent('9'),
);
const logOut = canvas.getByRole('button', { name: 'Log out' });
await userEvent.click(logOut);
logOut.focus();
await userEvent.keyboard('{Enter} ');
await waitFor(() =>
- expect(canvas.getByLabelText('Activations')).toHaveTextContent('10'),
+ expect(canvas.getByLabelText('Activations')).toHaveTextContent('12'),
);
await expect(getComputedStyle(logOut).borderTopWidth).toBe('0px');
await expect(getComputedStyle(logOut).paddingInlineStart).toBe('4px');
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/navigationControlsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/navigationControlsTest.ts
new file mode 100644
index 00000000000..e0ab0f2480b
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/navigationControlsTest.ts
@@ -0,0 +1,43 @@
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+import { galleryRenderTest } from '@/__stories__/twenty-ui-gallery/utils/galleryRenderTests';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+export const navigationControlsTest: TwentyUiGalleryPlayFunction = async (
+ context,
+) => {
+ await galleryRenderTest(context);
+
+ const canvas = within(context.canvasElement);
+ const suggestion = canvas.getByRole('button', { name: 'Suggestion' });
+ await expect(suggestion).toHaveAttribute('data-selected');
+ await userEvent.click(suggestion);
+ suggestion.focus();
+ await userEvent.keyboard('{Enter} ');
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Suggestion activations')).toHaveTextContent(
+ '3',
+ ),
+ );
+
+ const picker = canvas.getByRole('button', { name: 'Picker' });
+ await expect(picker).toHaveAttribute('aria-pressed', 'false');
+ await userEvent.click(picker);
+ await waitFor(() => expect(picker).toHaveAttribute('aria-pressed', 'true'));
+ picker.focus();
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() => expect(picker).toHaveAttribute('aria-pressed', 'false'));
+ await userEvent.keyboard(' ');
+ await waitFor(() => {
+ expect(picker).toHaveAttribute('aria-pressed', 'true');
+ expect(canvas.getByLabelText('Picker activations')).toHaveTextContent('3');
+ });
+
+ const disabledPicker = canvas.getByRole('button', {
+ name: 'Disabled picker',
+ });
+ await expect(disabledPicker).toBeDisabled();
+ await userEvent.click(disabledPicker);
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Picker activations')).toHaveTextContent('3'),
+ );
+};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/components/__stories__/AdvancedTextEditor.stories.tsx b/packages/twenty-front/src/modules/advanced-text-editor/components/__stories__/AdvancedTextEditor.stories.tsx
index 96aaf344a83..22b7228a4cf 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/components/__stories__/AdvancedTextEditor.stories.tsx
+++ b/packages/twenty-front/src/modules/advanced-text-editor/components/__stories__/AdvancedTextEditor.stories.tsx
@@ -528,14 +528,58 @@ export const SlashMenuKeepsEditorFocus: Story = {
play: async ({ canvasElement }) => {
const body = within(canvasElement.ownerDocument.body);
const editor = await within(canvasElement).findByRole('textbox');
+ const previousControls = editor.getAttribute('aria-controls');
+ const previousActiveDescendant = editor.getAttribute(
+ 'aria-activedescendant',
+ );
+ const previousExpanded = editor.getAttribute('aria-expanded');
await userEvent.click(editor);
await userEvent.keyboard('/heading');
- await body.findByText('Heading 1');
+ const menu = await body.findByRole('listbox', { name: 'Suggestions' });
+ const firstHeadingOption = await body.findByRole('option', {
+ name: 'Heading 1',
+ });
+ await expect(menu.id).not.toBe('');
+ await expect(firstHeadingOption.id).not.toBe('');
+ await expect(editor).toHaveAttribute('aria-controls', menu.id);
+ await expect(editor).toHaveAttribute(
+ 'aria-activedescendant',
+ firstHeadingOption.id,
+ );
+ await expect(editor.getAttribute('aria-expanded')).toBe(previousExpanded);
+ await expect(firstHeadingOption).toHaveAttribute('aria-selected', 'true');
await expect(editor).toHaveFocus();
- await userEvent.keyboard('{ArrowDown}{Enter}');
+ await userEvent.keyboard('{ArrowDown}');
+ const secondHeadingOption = body.getByRole('option', { name: 'Heading 2' });
+ const secondHeadingOptionId = secondHeadingOption.id;
+ await expect(secondHeadingOption).toHaveAttribute('aria-selected', 'true');
+ await expect(editor).toHaveAttribute(
+ 'aria-activedescendant',
+ secondHeadingOptionId,
+ );
+ await expect(firstHeadingOption).toHaveAttribute('aria-selected', 'false');
+ await userEvent.keyboard('{Backspace>6}2');
+ await waitFor(() => {
+ expect(body.getAllByRole('option')).toHaveLength(1);
+ });
+ const filteredMenu = body.getByRole('listbox', { name: 'Suggestions' });
+ const filteredOption = body.getByRole('option', { name: 'Heading 2' });
+ await expect(filteredOption.id).not.toBe('');
+ await expect(editor).toHaveAttribute('aria-controls', filteredMenu.id);
+ await expect(editor).toHaveAttribute(
+ 'aria-activedescendant',
+ filteredOption.id,
+ );
+ await expect(filteredOption).toHaveAttribute('aria-selected', 'true');
+ await userEvent.keyboard('{Enter}');
await waitFor(() => {
expect(body.queryByText('Heading 2')).not.toBeInTheDocument();
+ expect(editor.getAttribute('aria-controls')).toBe(previousControls);
+ expect(editor.getAttribute('aria-activedescendant')).toBe(
+ previousActiveDescendant,
+ );
});
+ await expect(editor.getAttribute('aria-expanded')).toBe(previousExpanded);
await expect(editor).toHaveFocus();
await userEvent.keyboard('Heading from slash menu');
await expect(
@@ -544,5 +588,30 @@ export const SlashMenuKeepsEditorFocus: Story = {
name: 'Heading from slash menu',
}),
).toBeVisible();
+ await expect(within(editor).getAllByRole('heading')).toHaveLength(1);
+ },
+};
+
+export const SlashMenuPointerKeepsEditorFocus: Story = {
+ play: async ({ canvasElement }) => {
+ const body = within(canvasElement.ownerDocument.body);
+ const editor = await within(canvasElement).findByRole('textbox');
+ await userEvent.click(editor);
+ await userEvent.keyboard('/heading');
+ await userEvent.click(
+ await body.findByRole('option', { name: 'Heading 2' }),
+ );
+ await waitFor(() =>
+ expect(body.queryByRole('listbox')).not.toBeInTheDocument(),
+ );
+ await expect(editor).toHaveFocus();
+ await userEvent.keyboard('Heading from pointer selection');
+ await expect(
+ within(editor).getByRole('heading', {
+ level: 2,
+ name: 'Heading from pointer selection',
+ }),
+ ).toBeVisible();
+ await expect(within(editor).getAllByRole('heading')).toHaveLength(1);
},
};
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommand.ts b/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommand.ts
index 1777fd3e825..bb276b5b09e 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommand.ts
+++ b/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommand.ts
@@ -4,10 +4,8 @@ import Suggestion, { type SuggestionOptions } from '@tiptap/suggestion';
import { type IconComponent } from 'twenty-ui/icon';
import { DEFAULT_SLASH_COMMANDS } from '@/advanced-text-editor/extensions/slash-command/DefaultSlashCommands';
-import {
- SlashCommandMenu,
- type SlashCommandMenuProps,
-} from '@/advanced-text-editor/extensions/slash-command/SlashCommandMenu';
+import { SlashCommandMenu } from '@/advanced-text-editor/extensions/slash-command/SlashCommandMenu';
+import { type SlashCommandMenuProps } from '@/advanced-text-editor/extensions/slash-command/types/SlashCommandMenuProps';
import { type SlashCommandConfig } from '@/advanced-text-editor/extensions/slash-command/types/SlashCommandConfig';
import { createSuggestionRenderLifecycle } from '@/ui/suggestion/components/createSuggestionRenderLifecycle';
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommandMenu.tsx b/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommandMenu.tsx
index e4dbd28d693..73e25b48646 100644
--- a/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommandMenu.tsx
+++ b/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommandMenu.tsx
@@ -1,17 +1,11 @@
-import { type Editor, type Range } from '@tiptap/core';
import { forwardRef, useCallback, useState } from 'react';
-import { MenuItemSuggestion } from 'twenty-ui/components/navigation';
+import { isDefined } from 'twenty-shared/utils';
import { type SlashCommandItem } from '@/advanced-text-editor/extensions/slash-command/SlashCommand';
+import { type SlashCommandMenuProps } from '@/advanced-text-editor/extensions/slash-command/types/SlashCommandMenuProps';
+import { SuggestionListItem } from '@/ui/suggestion/components/SuggestionListItem';
import { SuggestionMenu } from '@/ui/suggestion/components/SuggestionMenu';
-
-export type SlashCommandMenuProps = {
- items: SlashCommandItem[];
- onSelect: (item: SlashCommandItem) => void;
- editor: Editor;
- range: Range;
- query: string;
-};
+import { type SuggestionMenuItemRenderProps } from '@/ui/suggestion/types/SuggestionMenuItemRenderProps';
const getItemKey = (item: SlashCommandItem) => item.id;
@@ -48,16 +42,26 @@ export const SlashCommandMenu = forwardRef<unknown, SlashCommandMenuProps>(
);
const renderItem = useCallback(
- (item: SlashCommandItem, isSelected: boolean) => (
- <MenuItemSuggestion
- LeftIcon={item.icon}
- text={item.title}
- selected={isSelected}
- onClick={() => {
- onSelect(item);
- }}
- />
- ),
+ ({
+ item,
+ isSelected,
+ id,
+ }: SuggestionMenuItemRenderProps<SlashCommandItem>) => {
+ const Icon = item.icon;
+
+ return (
+ <SuggestionListItem
+ id={id}
+ startIcon={isDefined(Icon) ? <Icon /> : undefined}
+ selected={isSelected}
+ onSelect={() => {
+ onSelect(item);
+ }}
+ >
+ {item.title}
+ </SuggestionListItem>
+ );
+ },
[onSelect],
);
diff --git a/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/types/SlashCommandMenuProps.ts b/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/types/SlashCommandMenuProps.ts
new file mode 100644
index 00000000000..0e2d2920495
--- /dev/null
+++ b/packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/types/SlashCommandMenuProps.ts
@@ -0,0 +1,11 @@
+import { type Editor, type Range } from '@tiptap/core';
+
+import { type SlashCommandItem } from '@/advanced-text-editor/extensions/slash-command/SlashCommand';
+
+export type SlashCommandMenuProps = {
+ items: SlashCommandItem[];
+ onSelect: (item: SlashCommandItem) => void;
+ editor: Editor;
+ range: Range;
+ query: string;
+};
diff --git a/packages/twenty-front/src/modules/blocknote-editor/components/CustomMentionMenu.tsx b/packages/twenty-front/src/modules/blocknote-editor/components/CustomMentionMenu.tsx
index a85c1f34045..2a709644d8c 100644
--- a/packages/twenty-front/src/modules/blocknote-editor/components/CustomMentionMenu.tsx
+++ b/packages/twenty-front/src/modules/blocknote-editor/components/CustomMentionMenu.tsx
@@ -1,12 +1,15 @@
import { styled } from '@linaria/react';
import { autoUpdate, useFloating } from '@floating-ui/react';
import { motion } from 'framer-motion';
+import { t } from '@lingui/core/macro';
import { type MouseEvent as ReactMouseEvent } from 'react';
import { createPortal } from 'react-dom';
import { MENTION_MENU_DROPDOWN_CLICK_OUTSIDE_ID } from '@/ui/input/constants/MentionMenuDropdownClickOutsideId';
import { MentionMenuListItem } from '@/mention/components/MentionMenuListItem';
import { type CustomMentionMenuProps } from '@/blocknote-editor/types/SuggestionMenuItems';
+import { BLOCK_NOTE_SUGGESTION_MENU_ID } from '@/blocknote-editor/constants/BlockNoteSuggestionMenuId';
+import { getBlockNoteSuggestionMenuItemId } from '@/blocknote-editor/utils/getBlockNoteSuggestionMenuItemId';
import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';
import { OverlayMenuList } from '@/ui/layout/overlay/components/OverlayMenuList';
import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer';
@@ -53,6 +56,9 @@ export const CustomMentionMenu = ({
onClick={handleContainerClick}
>
<OverlayContainer
+ id={BLOCK_NOTE_SUGGESTION_MENU_ID}
+ role="listbox"
+ aria-label={t`Suggestions`}
ref={refs.setFloating}
style={floatingStyles}
data-click-outside-id={MENTION_MENU_DROPDOWN_CLICK_OUTSIDE_ID}
@@ -60,6 +66,7 @@ export const CustomMentionMenu = ({
<OverlayMenuList width={GenericDropdownContentWidth.Large}>
{filteredItems.map((item, index) => (
<MentionMenuListItem
+ id={getBlockNoteSuggestionMenuItemId(index)}
key={item.recordId!}
recordId={item.recordId!}
objectNameSingular={item.objectNameSingular!}
diff --git a/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenu.tsx b/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenu.tsx
index fe4270cb2aa..cf13d935b36 100644
--- a/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenu.tsx
+++ b/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenu.tsx
@@ -2,16 +2,15 @@ import { useBlockNoteEditor } from '@blocknote/react';
import { styled } from '@linaria/react';
import { autoUpdate, flip, offset, useFloating } from '@floating-ui/react';
import { motion } from 'framer-motion';
+import { t } from '@lingui/core/macro';
import { createPortal } from 'react-dom';
import { SLASH_MENU_DROPDOWN_CLICK_OUTSIDE_ID } from '@/ui/input/constants/SlashMenuDropdownClickOutsideId';
-import { SLASH_MENU_LIST_ID } from '@/ui/input/constants/SlashMenuListId';
import { CustomSlashMenuListItem } from '@/blocknote-editor/components/CustomSlashMenuListItem';
-import { CustomSlashMenuSelectedIndexSyncEffect } from '@/blocknote-editor/components/CustomSlashMenuSelectedIndexSyncEffect';
+import { BLOCK_NOTE_SUGGESTION_MENU_ID } from '@/blocknote-editor/constants/BlockNoteSuggestionMenuId';
import type { CustomSlashMenuProps } from '@/blocknote-editor/types/SuggestionMenuItems';
import { OverlayMenuList } from '@/ui/layout/overlay/components/OverlayMenuList';
import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer';
-import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList';
const StyledContainer = styled.div`
height: 1px;
@@ -21,6 +20,7 @@ const StyledContainer = styled.div`
export const CustomSlashMenu = ({
items,
selectedIndex,
+ onItemClick,
}: CustomSlashMenuProps) => {
const editor = useBlockNoteEditor();
@@ -52,10 +52,6 @@ export const CustomSlashMenu = ({
return (
<StyledContainer ref={refs.setReference}>
- <CustomSlashMenuSelectedIndexSyncEffect
- items={items}
- selectedIndex={selectedIndex}
- />
<>
{createPortal(
<motion.div
@@ -64,20 +60,23 @@ export const CustomSlashMenu = ({
transition={{ duration: 0.1 }}
>
<OverlayContainer
+ id={BLOCK_NOTE_SUGGESTION_MENU_ID}
+ role="listbox"
+ aria-label={t`Suggestions`}
ref={refs.setFloating}
style={floatingStyles}
data-click-outside-id={SLASH_MENU_DROPDOWN_CLICK_OUTSIDE_ID}
>
<OverlayMenuList>
- <SelectableList
- focusId={SLASH_MENU_DROPDOWN_CLICK_OUTSIDE_ID}
- selectableListInstanceId={SLASH_MENU_LIST_ID}
- selectableItemIdArray={items.map((item) => item.title)}
- >
- {items.map((item) => (
- <CustomSlashMenuListItem key={item.title} item={item} />
- ))}
- </SelectableList>
+ {items.map((item, index) => (
+ <CustomSlashMenuListItem
+ key={item.title}
+ item={item}
+ index={index}
+ isSelected={index === selectedIndex}
+ onSelect={() => onItemClick?.(item)}
+ />
+ ))}
</OverlayMenuList>
</OverlayContainer>
</motion.div>,
diff --git a/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuListItem.tsx b/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuListItem.tsx
index 89dfcb7cf07..9eff85db999 100644
--- a/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuListItem.tsx
+++ b/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuListItem.tsx
@@ -1,38 +1,41 @@
import { type SuggestionItem } from '@/blocknote-editor/types/SuggestionMenuItems';
-import { SLASH_MENU_LIST_ID } from '@/ui/input/constants/SlashMenuListId';
-import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
-import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
-import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
-import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
-import { MenuItemSuggestion } from 'twenty-ui/components/navigation';
+import { CustomSlashMenuListItemScrollEffect } from '@/blocknote-editor/components/CustomSlashMenuListItemScrollEffect';
+import { getBlockNoteSuggestionMenuItemId } from '@/blocknote-editor/utils/getBlockNoteSuggestionMenuItemId';
+import { SuggestionListItem } from '@/ui/suggestion/components/SuggestionListItem';
+import { useRef } from 'react';
+import { isDefined } from 'twenty-shared/utils';
-export type CustomSlashMenuListItemProps = {
+type CustomSlashMenuListItemProps = {
item: SuggestionItem;
+ index: number;
+ isSelected: boolean;
+ onSelect: () => void;
};
export const CustomSlashMenuListItem = ({
item,
+ index,
+ isSelected,
+ onSelect,
}: CustomSlashMenuListItemProps) => {
- const { resetSelectedItem } = useSelectableList(SLASH_MENU_LIST_ID);
-
- const isSelectedItemId = useAtomComponentFamilyStateValue(
- isSelectedItemIdComponentFamilyState,
- item.title,
- );
-
- const handleClick = () => {
- resetSelectedItem();
- item.onItemClick();
- };
+ const Icon = item.Icon;
+ const itemRef = useRef<HTMLButtonElement>(null);
return (
- <SelectableListItem itemId={item.title} onEnter={handleClick}>
- <MenuItemSuggestion
- selected={isSelectedItemId}
- onClick={handleClick}
- LeftIcon={item.Icon}
- text={item.title}
+ <>
+ <CustomSlashMenuListItemScrollEffect
+ itemRef={itemRef}
+ isSelected={isSelected}
/>
- </SelectableListItem>
+ <SuggestionListItem
+ ref={itemRef}
+ id={getBlockNoteSuggestionMenuItemId(index)}
+ selected={isSelected}
+ onSelect={onSelect}
+ startIcon={isDefined(Icon) ? <Icon /> : undefined}
+ >
+ {item.title}
+ </SuggestionListItem>
+ </>
);
};
diff --git a/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuListItemScrollEffect.tsx b/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuListItemScrollEffect.tsx
new file mode 100644
index 00000000000..9ae5dd2301e
--- /dev/null
+++ b/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuListItemScrollEffect.tsx
@@ -0,0 +1,21 @@
+import { type RefObject, useEffect } from 'react';
+
+type CustomSlashMenuListItemScrollEffectProps = {
+ itemRef: RefObject<HTMLButtonElement | null>;
+ isSelected: boolean;
+};
+
+export const CustomSlashMenuListItemScrollEffect = ({
+ itemRef,
+ isSelected,
+}: CustomSlashMenuListItemScrollEffectProps) => {
+ useEffect(() => {
+ if (!isSelected) {
+ return;
+ }
+
+ itemRef.current?.scrollIntoView?.({ block: 'nearest' });
+ }, [itemRef, isSelected]);
+
+ return null;
+};
diff --git a/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuSelectedIndexSyncEffect.tsx b/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuSelectedIndexSyncEffect.tsx
deleted file mode 100644
index 28f9f58e5a0..00000000000
--- a/packages/twenty-front/src/modules/blocknote-editor/components/CustomSlashMenuSelectedIndexSyncEffect.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { SLASH_MENU_LIST_ID } from '@/ui/input/constants/SlashMenuListId';
-import { type SuggestionItem } from '@/blocknote-editor/types/SuggestionMenuItems';
-import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
-import { useEffect } from 'react';
-import { isDefined } from 'twenty-shared/utils';
-
-type CustomSlashMenuSelectedIndexSyncEffectProps = {
- items: SuggestionItem[];
- selectedIndex: number | undefined;
-};
-
-export const CustomSlashMenuSelectedIndexSyncEffect = ({
- items,
- selectedIndex,
-}: CustomSlashMenuSelectedIndexSyncEffectProps) => {
- const { setSelectedItemId } = useSelectableList(SLASH_MENU_LIST_ID);
-
- useEffect(() => {
- if (!isDefined(selectedIndex)) return;
-
- const selectedItem = items[selectedIndex];
-
- if (isDefined(selectedItem)) {
- setSelectedItemId(selectedItem.title);
- }
- }, [items, selectedIndex, setSelectedItemId]);
-
- return <></>;
-};
diff --git a/packages/twenty-front/src/modules/blocknote-editor/components/__stories__/CustomSlashMenu.stories.tsx b/packages/twenty-front/src/modules/blocknote-editor/components/__stories__/CustomSlashMenu.stories.tsx
new file mode 100644
index 00000000000..0f0aad2a97a
--- /dev/null
+++ b/packages/twenty-front/src/modules/blocknote-editor/components/__stories__/CustomSlashMenu.stories.tsx
@@ -0,0 +1,111 @@
+import '@blocknote/mantine/style.css';
+import '@blocknote/react/style.css';
+
+import { BlockNoteView } from '@blocknote/mantine';
+import { SuggestionMenuController, useCreateBlockNote } from '@blocknote/react';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import { IconH1, IconTextSize } from 'twenty-ui/icon';
+
+import { CustomSlashMenu } from '@/blocknote-editor/components/CustomSlashMenu';
+import { type SuggestionItem } from '@/blocknote-editor/types/SuggestionMenuItems';
+
+const EditorWithSlashMenu = ({ onSelect }: { onSelect: () => void }) => {
+ const editor = useCreateBlockNote({
+ domAttributes: {
+ editor: { role: 'textbox', 'aria-label': 'Block editor' },
+ },
+ });
+
+ const items: SuggestionItem[] = [
+ {
+ title: 'First suggestion',
+ Icon: IconTextSize,
+ onItemClick: () => {
+ onSelect();
+ editor.insertInlineContent('First selection');
+ },
+ },
+ {
+ title: 'Second suggestion',
+ Icon: IconH1,
+ onItemClick: () => {
+ onSelect();
+ editor.insertInlineContent('Second selection');
+ },
+ },
+ ];
+
+ return (
+ <BlockNoteView
+ editor={editor}
+ slashMenu={false}
+ formattingToolbar={false}
+ sideMenu={false}
+ >
+ <SuggestionMenuController
+ triggerCharacter="/"
+ getItems={async () => items}
+ suggestionMenuComponent={CustomSlashMenu}
+ />
+ </BlockNoteView>
+ );
+};
+
+const meta = {
+ title: 'Modules/BlocknoteEditor/CustomSlashMenu',
+ component: EditorWithSlashMenu,
+ args: { onSelect: fn() },
+} satisfies Meta<typeof EditorWithSlashMenu>;
+
+export default meta;
+
+type Story = StoryObj<typeof meta>;
+
+export const EditorOwnsKeyboardSelection: Story = {
+ play: async ({ canvasElement, args }) => {
+ const body = within(canvasElement.ownerDocument.body);
+ const editor = await within(canvasElement).findByRole('textbox', {
+ name: 'Block editor',
+ });
+ await userEvent.click(editor);
+ await userEvent.keyboard('/');
+ const firstOption = await body.findByRole('option', {
+ name: 'First suggestion',
+ });
+ await expect(firstOption).toHaveAttribute('aria-selected', 'true');
+ await expect(editor).toHaveFocus();
+ await userEvent.keyboard('{ArrowDown}');
+ await expect(
+ body.getByRole('option', { name: 'Second suggestion' }),
+ ).toHaveAttribute('aria-selected', 'true');
+ await expect(firstOption).toHaveAttribute('aria-selected', 'false');
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() =>
+ expect(body.queryByRole('listbox')).not.toBeInTheDocument(),
+ );
+ await expect(args.onSelect).toHaveBeenCalledTimes(1);
+ await expect(editor).toHaveTextContent('Second selection');
+ await expect(editor).toHaveFocus();
+ },
+};
+
+export const PointerKeepsEditorFocus: Story = {
+ play: async ({ canvasElement, args }) => {
+ const body = within(canvasElement.ownerDocument.body);
+ const editor = await within(canvasElement).findByRole('textbox', {
+ name: 'Block editor',
+ });
+ await userEvent.click(editor);
+ await userEvent.keyboard('/');
+ await userEvent.click(
+ await body.findByRole('option', { name: 'Second suggestion' }),
+ );
+ await waitFor(() =>
+ expect(body.queryByRole('listbox')).not.toBeInTheDocument(),
+ );
+ await expect(args.onSelect).toHaveBeenCalledTimes(1);
+ await expect(editor).toHaveTextContent('Second selection');
+ await expect(editor).toHaveFocus();
+ },
+};
diff --git a/packages/twenty-front/src/modules/blocknote-editor/constants/BlockNoteSuggestionMenuId.ts b/packages/twenty-front/src/modules/blocknote-editor/constants/BlockNoteSuggestionMenuId.ts
new file mode 100644
index 00000000000..960aa0485cb
--- /dev/null
+++ b/packages/twenty-front/src/modules/blocknote-editor/constants/BlockNoteSuggestionMenuId.ts
@@ -0,0 +1 @@
+export const BLOCK_NOTE_SUGGESTION_MENU_ID = 'bn-suggestion-menu';
diff --git a/packages/twenty-front/src/modules/blocknote-editor/utils/getBlockNoteSuggestionMenuItemId.ts b/packages/twenty-front/src/modules/blocknote-editor/utils/getBlockNoteSuggestionMenuItemId.ts
new file mode 100644
index 00000000000..52dc96fc4b2
--- /dev/null
+++ b/packages/twenty-front/src/modules/blocknote-editor/utils/getBlockNoteSuggestionMenuItemId.ts
@@ -0,0 +1,4 @@
+import { BLOCK_NOTE_SUGGESTION_MENU_ID } from '@/blocknote-editor/constants/BlockNoteSuggestionMenuId';
+
+export const getBlockNoteSuggestionMenuItemId = (index: number) =>
+ `${BLOCK_NOTE_SUGGESTION_MENU_ID}-item-${index}`;
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 e1162957d7c..975491b035b 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
@@ -1,3 +1,4 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { AppMenuItemIcon } from '@/applications/components/AppMenuItemIcon';
import { ApplicationStackIcon } from '@/applications/components/ApplicationStackIcon';
import { CommandMenuItemEditRecordSelectionDropdown } from '@/command-menu-item/edit/components/CommandMenuItemEditRecordSelectionDropdown';
@@ -24,7 +25,6 @@ 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 { MenuItemDraggable } from 'twenty-ui/components/navigation';
import { ListItem } from 'twenty-ui/primitives/navigation';
import {
IconDotsVertical,
@@ -235,18 +235,17 @@ export const SidePanelCommandMenuItemEditPage = () => {
})
}
>
- <MenuItemDraggable
- withIconContainer
- LeftComponent={
+ <DraggableListRow
+ hasIconBackground
+ startIcon={
<ApplicationStackIcon
Icon={ItemIcon}
applicationId={item.applicationId}
/>
}
- text={getDisplayLabel(item)}
- gripMode="onHover"
- isIconDisplayedOnHoverOnly={false}
- iconButtons={
+ dragHandleVisibility="hover"
+ actionsVisibility="always"
+ actions={
<ButtonGroup
attached={false}
aria-label={t`Menu item actions`}
@@ -278,7 +277,9 @@ export const SidePanelCommandMenuItemEditPage = () => {
</LightIconButton>
</ButtonGroup>
}
- />
+ >
+ {getDisplayLabel(item)}
+ </DraggableListRow>
</SelectableListItem>
}
/>
diff --git a/packages/twenty-front/src/modules/mention/components/MentionMenuListItem.tsx b/packages/twenty-front/src/modules/mention/components/MentionMenuListItem.tsx
index 6261be83f76..ab508b9cce5 100644
--- a/packages/twenty-front/src/modules/mention/components/MentionMenuListItem.tsx
+++ b/packages/twenty-front/src/modules/mention/components/MentionMenuListItem.tsx
@@ -1,12 +1,11 @@
-import { type MouseEvent } from 'react';
-
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
import { getAvatarShape } from '@/object-metadata/utils/getAvatarShape';
-import { MenuItemSuggestion } from 'twenty-ui/components/navigation';
+import { SuggestionListItem } from '@/ui/suggestion/components/SuggestionListItem';
import { Avatar } from 'twenty-ui/primitives/data-display';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
type MentionMenuListItemProps = {
+ id: string;
recordId: string;
objectNameSingular: string;
label: string;
@@ -17,6 +16,7 @@ type MentionMenuListItemProps = {
};
export const MentionMenuListItem = ({
+ id,
recordId,
objectNameSingular,
label,
@@ -31,20 +31,13 @@ export const MentionMenuListItem = ({
(item) => item.nameSingular === objectNameSingular,
);
- const handleClick = (event?: MouseEvent) => {
- event?.preventDefault();
- event?.stopPropagation();
- onClick();
- };
-
return (
- <MenuItemSuggestion
+ <SuggestionListItem
+ id={id}
selected={isSelected}
- onClick={handleClick}
- text={label}
- contextualText={objectLabelSingular}
- contextualTextPosition="left"
- LeftIcon={() => (
+ onSelect={onClick}
+ description={objectLabelSingular}
+ startIcon={
<Avatar
name={label}
colorSeed={recordId}
@@ -52,7 +45,9 @@ export const MentionMenuListItem = ({
shape={getAvatarShape(objectMetadataItem)}
size="sm"
/>
- )}
- />
+ }
+ >
+ {label}
+ </SuggestionListItem>
);
};
diff --git a/packages/twenty-front/src/modules/mention/components/MentionSuggestionMenu.tsx b/packages/twenty-front/src/modules/mention/components/MentionSuggestionMenu.tsx
index f6ef274a555..daf18cf9774 100644
--- a/packages/twenty-front/src/modules/mention/components/MentionSuggestionMenu.tsx
+++ b/packages/twenty-front/src/modules/mention/components/MentionSuggestionMenu.tsx
@@ -1,6 +1,6 @@
import { forwardRef } from 'react';
import { CoreObjectNameSingular } from 'twenty-shared/types';
-import { MenuItemSuggestion } from 'twenty-ui/components/navigation';
+import { SuggestionListItem } from '@/ui/suggestion/components/SuggestionListItem';
import type { MentionSearchResult } from '@/mention/types/MentionSearchResult';
import type { MentionSuggestionMenuProps } from '@/mention/types/MentionSuggestionMenuProps';
@@ -20,27 +20,35 @@ const getItemSection = (item: MentionSearchResult) => ({
label: item.objectLabelPlural,
});
-const renderItem = (
- item: MentionSearchResult,
- isSelected: boolean,
- onSelect: (item: MentionSearchResult) => void,
-) => (
- <MenuItemSuggestion
- LeftIcon={() => (
+const renderItem = ({
+ item,
+ isSelected,
+ onSelect,
+ id,
+}: {
+ item: MentionSearchResult;
+ isSelected: boolean;
+ onSelect: (item: MentionSearchResult) => void;
+ id: string;
+}) => (
+ <SuggestionListItem
+ id={id}
+ startIcon={
<AvatarOrIcon
name={item.label}
colorSeed={item.recordId}
shape="circle"
src={getAbsoluteImageUrl(item.imageUrl)}
/>
- )}
- text={item.label}
- contextualText={item.objectLabelSingular}
+ }
+ description={item.objectLabelSingular}
selected={isSelected}
- onClick={() => {
+ onSelect={() => {
onSelect(item);
}}
- />
+ >
+ {item.label}
+ </SuggestionListItem>
);
export const MentionSuggestionMenu = forwardRef<
@@ -58,7 +66,9 @@ export const MentionSuggestionMenu = forwardRef<
range={range}
getItemKey={getItemKey}
getItemSection={getItemSection}
- renderItem={(item, isSelected) => renderItem(item, isSelected, onSelect)}
+ renderItem={({ item, isSelected, id }) =>
+ renderItem({ item, isSelected, onSelect, id })
+ }
/>
);
});
diff --git a/packages/twenty-front/src/modules/mention/components/__tests__/MentionSuggestionMenu.test.tsx b/packages/twenty-front/src/modules/mention/components/__tests__/MentionSuggestionMenu.test.tsx
index caeff043f82..cfe663a0183 100644
--- a/packages/twenty-front/src/modules/mention/components/__tests__/MentionSuggestionMenu.test.tsx
+++ b/packages/twenty-front/src/modules/mention/components/__tests__/MentionSuggestionMenu.test.tsx
@@ -10,7 +10,10 @@ import type { MentionSearchResult } from '@/mention/types/MentionSearchResult';
import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
const editor = {
- view: { coordsAtPos: () => ({ left: 0, top: 0, bottom: 16 }) },
+ view: {
+ dom: document.createElement('div'),
+ coordsAtPos: () => ({ left: 0, top: 0, bottom: 16 }),
+ },
} as unknown as Editor;
const buildResult = (
diff --git a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupMenuItemDraggable.tsx b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupVisibilityRow.tsx
similarity index 81%
rename from packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupMenuItemDraggable.tsx
rename to packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupVisibilityRow.tsx
index 7c24ba1d32a..a7fa97cde4d 100644
--- a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupMenuItemDraggable.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupVisibilityRow.tsx
@@ -1,3 +1,4 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { RecordGroupChip } from '@/object-record/record-group/components/RecordGroupChip';
import { recordGroupDefinitionFamilyState } from '@/object-record/record-group/states/recordGroupDefinitionFamilyState';
import {
@@ -10,10 +11,9 @@ import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAto
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
import { IconEye, IconEyeOff } from 'twenty-ui/icon';
-type RecordGroupMenuItemDraggableProps = {
+type RecordGroupVisibilityRowProps = {
recordGroupId: string;
showDragGrip?: boolean;
isDraggable?: boolean;
@@ -21,13 +21,13 @@ type RecordGroupMenuItemDraggableProps = {
isVisibleLimitReached?: boolean;
};
-export const RecordGroupMenuItemDraggable = ({
+export const RecordGroupVisibilityRow = ({
recordGroupId,
showDragGrip,
isDraggable,
onVisibilityChange,
isVisibleLimitReached = false,
-}: RecordGroupMenuItemDraggableProps) => {
+}: RecordGroupVisibilityRowProps) => {
const recordGroupDefinition = useAtomFamilyStateValue(
recordGroupDefinitionFamilyState,
recordGroupId,
@@ -49,17 +49,11 @@ export const RecordGroupMenuItemDraggable = ({
recordGroupDefinition.isVisible || !isVisibleLimitReached;
return (
- <MenuItemDraggable
+ <DraggableListRow
key={recordGroupDefinition.id}
- text={
- <RecordGroupChip
- recordGroupDefinition={recordGroupDefinition}
- fieldMetadataItem={recordIndexGroupFieldMetadataItem}
- />
- }
- accent={isNoValue || showDragGrip ? 'placeholder' : 'default'}
- iconButtons={
- canToggleVisibility && (
+ isMuted={isNoValue || showDragGrip}
+ actions={
+ canToggleVisibility ? (
<LightIconButton
aria-label={
recordGroupDefinition.isVisible
@@ -80,10 +74,15 @@ export const RecordGroupMenuItemDraggable = ({
>
{recordGroupDefinition.isVisible ? <IconEyeOff /> : <IconEye />}
</LightIconButton>
- )
+ ) : undefined
}
- gripMode={isNoValue || showDragGrip ? 'always' : 'never'}
+ dragHandleVisibility={isNoValue || showDragGrip ? 'always' : 'none'}
isDragDisabled={!isDraggable}
- />
+ >
+ <RecordGroupChip
+ recordGroupDefinition={recordGroupDefinition}
+ fieldMetadataItem={recordIndexGroupFieldMetadataItem}
+ />
+ </DraggableListRow>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupsVisibilityDropdownSection.tsx b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupsVisibilityDropdownSection.tsx
index 730b383101a..ac7fcb4bbf2 100644
--- a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupsVisibilityDropdownSection.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupsVisibilityDropdownSection.tsx
@@ -1,7 +1,7 @@
import { type DraggableListDropResult } from '@/ui/layout/draggable-list/types/DraggableListDropResult';
import { useRef } from 'react';
-import { RecordGroupMenuItemDraggable } from '@/object-record/record-group/components/RecordGroupMenuItemDraggable';
+import { RecordGroupVisibilityRow } from '@/object-record/record-group/components/RecordGroupVisibilityRow';
import { type RecordGroupDefinition } from '@/object-record/record-group/types/RecordGroupDefinition';
import { DraggableItem } from '@/ui/layout/draggable-list/components/DraggableItem';
import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableList';
@@ -45,7 +45,7 @@ export const RecordGroupsVisibilityDropdownSection = ({
<>
{!isDraggable ? (
recordGroupIds.map((recordGroupId) => (
- <RecordGroupMenuItemDraggable
+ <RecordGroupVisibilityRow
key={recordGroupId}
recordGroupId={recordGroupId}
onVisibilityChange={onVisibilityChange}
@@ -65,7 +65,7 @@ export const RecordGroupsVisibilityDropdownSection = ({
draggableId={recordGroupId}
index={index + 1}
itemComponent={
- <RecordGroupMenuItemDraggable
+ <RecordGroupVisibilityRow
recordGroupId={recordGroupId}
onVisibilityChange={onVisibilityChange}
showDragGrip={showDragGrip}
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationFieldEditor.tsx b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationFieldEditor.tsx
index 943e04d8372..2f4347d4955 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationFieldEditor.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationFieldEditor.tsx
@@ -1,9 +1,9 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { ApplicationStackIcon } from '@/applications/components/ApplicationStackIcon';
import { type FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { type FieldsConfigurationFieldItem } from '@/page-layout/types/FieldsConfiguration';
import { t } from '@lingui/core/macro';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
import { IconEye, IconEyeOff, useIcons } from 'twenty-ui/icon';
type FieldsConfigurationFieldEditorProps = {
@@ -22,18 +22,17 @@ export const FieldsConfigurationFieldEditor = ({
const FieldIcon = getIcon(fieldMetadata.icon);
return (
- <MenuItemDraggable
- LeftComponent={
+ <DraggableListRow
+ startIcon={
<ApplicationStackIcon
Icon={FieldIcon}
applicationId={fieldMetadata.applicationId}
/>
}
- text={fieldMetadata.label}
- gripMode="onHover"
- withIconContainer
- isIconDisplayedOnHoverOnly={false}
- iconButtons={
+ dragHandleVisibility="hover"
+ hasIconBackground
+ actionsVisibility="always"
+ actions={
<LightIconButton
aria-label={isVisible ? t`Hide field` : t`Show field`}
onClick={(event) => {
@@ -44,6 +43,8 @@ export const FieldsConfigurationFieldEditor = ({
{isVisible ? <IconEye /> : <IconEyeOff />}
</LightIconButton>
}
- />
+ >
+ {fieldMetadata.label}
+ </DraggableListRow>
);
};
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationGroupEditor.tsx b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationGroupEditor.tsx
index e4ba2e4e360..098b5227c11 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationGroupEditor.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/fields/components/FieldsConfigurationGroupEditor.tsx
@@ -48,7 +48,7 @@ const StyledGroupHeaderRow = styled.div`
width: 100%;
`;
-const StyledMenuItemDraggableWrapper = styled.div`
+const StyledGroupHeaderContent = styled.div`
flex: 1;
min-width: 0;
`;
@@ -119,11 +119,11 @@ export const FieldsConfigurationGroupEditor = ({
return (
<StyledGroupContainer isDragging={isDragging}>
<StyledGroupHeaderRow>
- <StyledMenuItemDraggableWrapper ref={groupHeaderRef}>
+ <StyledGroupHeaderContent ref={groupHeaderRef}>
<DragDropItemSortableHandle fill>
<FieldsConfigurationGroupDraggableHeader text={group.name} />
</DragDropItemSortableHandle>
- </StyledMenuItemDraggableWrapper>
+ </StyledGroupHeaderContent>
<DropdownRoot
dropdownId={renameDropdownId}
type="panel"
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/ChartTypeSelectionSection.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/ChartTypeSelectionSection.tsx
index 927076e105c..a7a6c2a11f3 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/ChartTypeSelectionSection.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/ChartTypeSelectionSection.tsx
@@ -3,10 +3,11 @@ import { styled } from '@linaria/react';
import { GraphType } from '@/side-panel/pages/page-layout/types/GraphType';
import { t } from '@lingui/core/macro';
-import { MenuPicker } from 'twenty-ui/components/navigation';
-import { themeCssVariables } from 'twenty-ui/theme';
+import { Button } from 'twenty-ui/primitives/input';
+import { Tooltip } from 'twenty-ui/primitives/surfaces';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
-const graphTypeOptions = [
+const GRAPH_TYPE_OPTIONS = [
GraphType.VERTICAL_BAR,
GraphType.HORIZONTAL_BAR,
GraphType.LINE,
@@ -20,6 +21,30 @@ const StyledChartTypeSelectionContainer = styled.div`
gap: ${themeCssVariables.spacing[2]};
`;
+const StyledChartTypeButton = styled(Button)`
+ background: transparent;
+ border-color: ${themeCssVariables.border.color.medium};
+ border-radius: calc(
+ ${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}
+ );
+ color: ${themeCssVariables.font.color.tertiary};
+ flex: 1;
+ padding-inline: ${themeCssVariables.spacing[1]};
+
+ &:hover {
+ background: ${themeCssVariables.background.transparent.light};
+ }
+
+ &[aria-pressed='true'] {
+ border-color: ${themeCssVariables.color.blue};
+ color: ${themeCssVariables.color.blue};
+
+ &:hover {
+ background: ${themeCssVariables.background.transparent.primary};
+ }
+ }
+`;
+
type ChartTypeSelectionSectionProps = {
currentGraphType: GraphType;
setCurrentGraphType: (graphType: GraphType) => void;
@@ -29,21 +54,35 @@ export const ChartTypeSelectionSection = ({
currentGraphType,
setCurrentGraphType,
}: ChartTypeSelectionSectionProps) => {
+ const theme = useTheme();
+
return (
- <StyledChartTypeSelectionContainer>
- {graphTypeOptions.map((graphType) => {
+ <StyledChartTypeSelectionContainer role="group" aria-label={t`Chart type`}>
+ {GRAPH_TYPE_OPTIONS.map((graphType) => {
+ const Icon = GRAPH_TYPE_INFORMATION[graphType].icon;
+ const label = t(GRAPH_TYPE_INFORMATION[graphType].label);
+
return (
- <MenuPicker
- id={graphType}
- selected={currentGraphType === graphType}
+ <Tooltip
key={graphType}
- icon={GRAPH_TYPE_INFORMATION[graphType].icon}
- onClick={() => {
- setCurrentGraphType(graphType);
- }}
- showLabel
- tooltipContent={t(GRAPH_TYPE_INFORMATION[graphType].label)}
- />
+ content={label}
+ side="bottom"
+ sideOffset={theme.spacingMultiplicator}
+ positionMethod="fixed"
+ delay={0}
+ >
+ <StyledChartTypeButton
+ id={graphType}
+ fullWidth
+ aria-label={label}
+ aria-pressed={currentGraphType === graphType}
+ onClick={() => {
+ setCurrentGraphType(graphType);
+ }}
+ >
+ <Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
+ </StyledChartTypeButton>
+ </Tooltip>
);
})}
</StyledChartTypeSelectionContainer>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/__stories__/ChartTypeSelectionSection.stories.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/__stories__/ChartTypeSelectionSection.stories.tsx
new file mode 100644
index 00000000000..c1241ed2b6d
--- /dev/null
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/__stories__/ChartTypeSelectionSection.stories.tsx
@@ -0,0 +1,70 @@
+import { ChartTypeSelectionSection } from '@/side-panel/pages/page-layout/components/ChartTypeSelectionSection';
+import { GraphType } from '@/side-panel/pages/page-layout/types/GraphType';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useState } from 'react';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+const meta: Meta<typeof ChartTypeSelectionSection> = {
+ title: 'Modules/SidePanel/PageLayout/ChartTypeSelectionSection',
+ component: ChartTypeSelectionSection,
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 320 } },
+ args: {
+ currentGraphType: GraphType.VERTICAL_BAR,
+ setCurrentGraphType: fn(),
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof ChartTypeSelectionSection>;
+
+export const KeyboardActivation: Story = {
+ render: (args) => {
+ const [currentGraphType, setCurrentGraphType] = useState(
+ args.currentGraphType,
+ );
+
+ return (
+ <ChartTypeSelectionSection
+ currentGraphType={currentGraphType}
+ setCurrentGraphType={(graphType) => {
+ setCurrentGraphType(graphType);
+ args.setCurrentGraphType(graphType);
+ }}
+ />
+ );
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const group = within(canvas.getByRole('group', { name: 'Chart type' }));
+ const verticalBar = group.getByRole('button', {
+ name: 'Vertical Bar Chart',
+ });
+ const line = group.getByRole('button', { name: 'Line Chart' });
+
+ expect(verticalBar).toHaveAttribute('aria-pressed', 'true');
+ expect(line).toHaveAttribute('aria-pressed', 'false');
+ expect(group.getAllByRole('button')).toHaveLength(5);
+ expect(line.getBoundingClientRect().height).toBe(32);
+ expect(line.getBoundingClientRect().width).toBeCloseTo(
+ verticalBar.getBoundingClientRect().width,
+ );
+
+ line.focus();
+ await userEvent.keyboard('{Enter}');
+ expect(args.setCurrentGraphType).toHaveBeenCalledTimes(1);
+ expect(args.setCurrentGraphType).toHaveBeenCalledWith(GraphType.LINE);
+ await waitFor(() => {
+ expect(line).toHaveAttribute('aria-pressed', 'true');
+ expect(verticalBar).toHaveAttribute('aria-pressed', 'false');
+ });
+ await userEvent.keyboard(' ');
+ expect(args.setCurrentGraphType).toHaveBeenCalledTimes(2);
+ await userEvent.click(verticalBar);
+ expect(args.setCurrentGraphType).toHaveBeenCalledTimes(3);
+ expect(args.setCurrentGraphType).toHaveBeenLastCalledWith(
+ GraphType.VERTICAL_BAR,
+ );
+ },
+};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
index a85f3ea268a..6d622eb2e32 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
@@ -1,3 +1,4 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { type DraggableListDropResult } from '@/ui/layout/draggable-list/types/DraggableListDropResult';
import { usePageLayoutSidePanelTarget } from '@/side-panel/pages/page-layout/hooks/usePageLayoutSidePanelTarget';
@@ -15,7 +16,6 @@ import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
import { IconChevronLeft } from 'twenty-ui/icon';
import { Tag } from 'twenty-ui/primitives/data-display';
import { type WidgetConfiguration } from '~/generated-metadata/graphql';
@@ -100,15 +100,14 @@ export const ChartManualSortSubMenuContent = ({
index={index}
isDragDisabled={sortedOptions.length === 1}
itemComponent={
- <MenuItemDraggable
- gripMode="always"
+ <DraggableListRow
+ dragHandleVisibility="always"
isDragDisabled={sortedOptions.length === 1}
- text={
- <Tag truncate={false} color={option.color}>
- {option.label}
- </Tag>
- }
- />
+ >
+ <Tag truncate={false} color={option.color}>
+ {option.label}
+ </Tag>
+ </DraggableListRow>
}
/>
))}
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
index 82d1ba0d4a7..32db9e8dd1c 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableFieldsDropdownVisibleFieldsContent.tsx
@@ -1,3 +1,4 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { ApplicationStackIcon } from '@/applications/components/ApplicationStackIcon';
import { useGetFieldMetadataItemByIdOrThrow } from '@/object-metadata/hooks/useGetFieldMetadataItemById';
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
@@ -15,10 +16,7 @@ import { useAtomComponentSelectorValue } from '@/ui/utilities/state/jotai/hooks/
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components/input';
-import {
- ListItemButton,
- MenuItemDraggable,
-} from 'twenty-ui/components/navigation';
+import { ListItemButton } from 'twenty-ui/components/navigation';
import { IconEyeOff, useIcons } from 'twenty-ui/icon';
import { sortByProperty } from '~/utils/array/sortByProperty';
@@ -99,18 +97,19 @@ export const RecordTableFieldsDropdownVisibleFieldsContent = ({
<LegacyDropdownContent>
<DropdownMenuItemsContainer>
{isDefined(fieldMetadataItemLabelIdentifier) && (
- <MenuItemDraggable
- LeftComponent={
+ <DraggableListRow
+ startIcon={
<ApplicationStackIcon
Icon={getIcon(fieldMetadataItemLabelIdentifier.icon)}
applicationId={fieldMetadataItemLabelIdentifier.applicationId}
/>
}
- text={fieldMetadataItemLabelIdentifier.label}
- accent="placeholder"
- gripMode="always"
+ isMuted
+ dragHandleVisibility="always"
isDragDisabled
- />
+ >
+ {fieldMetadataItemLabelIdentifier.label}
+ </DraggableListRow>
)}
{draggableRecordFields.length > 0 && (
<DraggableList
@@ -128,14 +127,14 @@ export const RecordTableFieldsDropdownVisibleFieldsContent = ({
draggableId={recordField.fieldMetadataItemId}
index={index}
itemComponent={
- <MenuItemDraggable
- LeftComponent={
+ <DraggableListRow
+ startIcon={
<ApplicationStackIcon
Icon={getIcon(fieldMetadataItem.icon)}
applicationId={fieldMetadataItem.applicationId}
/>
}
- iconButtons={
+ actions={
<LightIconButton
aria-label={t`Hide field`}
onClick={() =>
@@ -145,9 +144,10 @@ export const RecordTableFieldsDropdownVisibleFieldsContent = ({
<IconEyeOff />
</LightIconButton>
}
- text={fieldMetadataItem.label}
- gripMode="always"
- />
+ dragHandleVisibility="always"
+ >
+ {fieldMetadataItem.label}
+ </DraggableListRow>
}
/>
);
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableSettingsFieldVisibility.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableSettingsFieldVisibility.tsx
index dc0f6cc00fd..04e807edb04 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableSettingsFieldVisibility.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/record-table-settings/RecordTableSettingsFieldVisibility.tsx
@@ -1,3 +1,4 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { ApplicationStackIcon } from '@/applications/components/ApplicationStackIcon';
import { useRecordTableWidgetViewFieldItems } from '@/page-layout/widgets/record-table/hooks/useRecordTableWidgetViewFieldItems';
import { useReorderRecordTableWidgetFields } from '@/page-layout/widgets/record-table/hooks/useReorderRecordTableWidgetFields';
@@ -9,7 +10,6 @@ import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { useMemo } from 'react';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
import { IconEye, IconEyeOff, useIcons } from 'twenty-ui/icon';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -96,8 +96,8 @@ export const RecordTableSettingsFieldVisibility = ({
draggableId={fieldItem.viewField.id}
index={index}
itemComponent={
- <MenuItemDraggable
- LeftComponent={
+ <DraggableListRow
+ startIcon={
<ApplicationStackIcon
Icon={getIcon(fieldItem.fieldMetadataItem.icon)}
applicationId={
@@ -105,7 +105,7 @@ export const RecordTableSettingsFieldVisibility = ({
}
/>
}
- iconButtons={
+ actions={
<LightIconButton
aria-label={t`Hide field`}
onClick={() => {
@@ -118,9 +118,10 @@ export const RecordTableSettingsFieldVisibility = ({
<IconEyeOff />
</LightIconButton>
}
- text={fieldItem.fieldMetadataItem.label}
- gripMode="always"
- />
+ dragHandleVisibility="always"
+ >
+ {fieldItem.fieldMetadataItem.label}
+ </DraggableListRow>
}
/>
))}
@@ -132,15 +133,15 @@ export const RecordTableSettingsFieldVisibility = ({
<>
<StyledSectionLabel>{t`Hidden`}</StyledSectionLabel>
{hiddenFieldItems.map((fieldItem) => (
- <MenuItemDraggable
+ <DraggableListRow
key={fieldItem.viewField.id}
- LeftComponent={
+ startIcon={
<ApplicationStackIcon
Icon={getIcon(fieldItem.fieldMetadataItem.icon)}
applicationId={fieldItem.fieldMetadataItem.applicationId}
/>
}
- iconButtons={
+ actions={
<LightIconButton
aria-label={t`Show field`}
onClick={() => {
@@ -153,10 +154,11 @@ export const RecordTableSettingsFieldVisibility = ({
<IconEye />
</LightIconButton>
}
- text={fieldItem.fieldMetadataItem.label}
- accent="placeholder"
+ isMuted
isDragDisabled
- />
+ >
+ {fieldItem.fieldMetadataItem.label}
+ </DraggableListRow>
))}
</>
)}
diff --git a/packages/twenty-front/src/modules/side-panel/pages/record-creation-form-settings/components/SidePanelRecordCreationFormSettingsPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/record-creation-form-settings/components/SidePanelRecordCreationFormSettingsPage.tsx
index bd51f439844..e98b63615bc 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/record-creation-form-settings/components/SidePanelRecordCreationFormSettingsPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/record-creation-form-settings/components/SidePanelRecordCreationFormSettingsPage.tsx
@@ -1,3 +1,4 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { useObjectMetadataItemById } from '@/object-metadata/hooks/useObjectMetadataItemById';
import { useRecordFormFields } from '@/object-record/record-form/hooks/useRecordFormFields';
import { type RecordFormField } from '@/object-record/record-form/types/RecordFormField';
@@ -22,7 +23,6 @@ import { useLingui } from '@lingui/react/macro';
import { useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
import { IconEye, IconEyeOff, useIcons } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -177,6 +177,7 @@ const SidePanelRecordCreationFormSettings = ({
draggableItems={orderedConfigurableRecordFormFields.map(
(recordFormField, index) => {
const { fieldMetadataItem } = recordFormField;
+ const FieldIcon = getIcon(fieldMetadataItem.icon);
const isVisible = isRecordFormFieldVisible(recordFormField);
return (
@@ -186,11 +187,10 @@ const SidePanelRecordCreationFormSettings = ({
index={index}
isDragDisabled={isSaving}
itemComponent={
- <MenuItemDraggable
- LeftIcon={getIcon(fieldMetadataItem.icon)}
- withIconContainer
- text={fieldMetadataItem.label}
- contextualText={
+ <DraggableListRow
+ startIcon={<FieldIcon />}
+ hasIconBackground
+ description={
isFieldTypeSupportedInSettings(fieldMetadataItem.type)
? i18n._(
getSettingsFieldTypeConfig(
@@ -199,11 +199,14 @@ const SidePanelRecordCreationFormSettings = ({
)
: undefined
}
- isIconDisplayedOnHoverOnly={false}
- gripMode="onHover"
- onClick={() => handleToggleVisibility(recordFormField)}
- iconButtons={
+ actionsVisibility="always"
+ dragHandleVisibility="hover"
+ isDragDisabled={isSaving}
+ onAction={() => handleToggleVisibility(recordFormField)}
+ isActionDisabled={isSaving}
+ actions={
<LightIconButton
+ disabled={isSaving}
aria-label={
isVisible
? t`Hide ${fieldMetadataItem.label}`
@@ -217,7 +220,9 @@ const SidePanelRecordCreationFormSettings = ({
{isVisible ? <IconEye /> : <IconEyeOff />}
</LightIconButton>
}
- />
+ >
+ {fieldMetadataItem.label}
+ </DraggableListRow>
}
/>
);
diff --git a/packages/twenty-front/src/modules/skill-suggestion/components/SkillSuggestionMenu.tsx b/packages/twenty-front/src/modules/skill-suggestion/components/SkillSuggestionMenu.tsx
index f2adf14ca2e..4d93f8aa1da 100644
--- a/packages/twenty-front/src/modules/skill-suggestion/components/SkillSuggestionMenu.tsx
+++ b/packages/twenty-front/src/modules/skill-suggestion/components/SkillSuggestionMenu.tsx
@@ -23,8 +23,9 @@ export const SkillSuggestionMenu = forwardRef<
editor={editor}
range={range}
getItemKey={getItemKey}
- renderItem={(item, isSelected) => (
+ renderItem={({ item, isSelected, id }) => (
<SkillSuggestionMenuItem
+ id={id}
item={item}
isSelected={isSelected}
onSelect={onSelect}
diff --git a/packages/twenty-front/src/modules/skill-suggestion/components/SkillSuggestionMenuItem.tsx b/packages/twenty-front/src/modules/skill-suggestion/components/SkillSuggestionMenuItem.tsx
index 708283e2b61..c46369a325c 100644
--- a/packages/twenty-front/src/modules/skill-suggestion/components/SkillSuggestionMenuItem.tsx
+++ b/packages/twenty-front/src/modules/skill-suggestion/components/SkillSuggestionMenuItem.tsx
@@ -1,30 +1,35 @@
-import { MenuItemSuggestion } from 'twenty-ui/components/navigation';
+import { SuggestionListItem } from '@/ui/suggestion/components/SuggestionListItem';
import { useIcons } from 'twenty-ui/icon';
import { DEFAULT_SKILL_ICON } from '@/skill-suggestion/constants/DefaultSkillIcon';
import type { SkillSuggestionItem } from '@/skill-suggestion/types/SkillSuggestionItem';
type SkillSuggestionMenuItemProps = {
+ id: string;
item: SkillSuggestionItem;
isSelected: boolean;
onSelect: (item: SkillSuggestionItem) => void;
};
export const SkillSuggestionMenuItem = ({
+ id,
item,
isSelected,
onSelect,
}: SkillSuggestionMenuItemProps) => {
const { getIcon } = useIcons();
+ const Icon = getIcon(item.icon ?? DEFAULT_SKILL_ICON);
return (
- <MenuItemSuggestion
- LeftIcon={getIcon(item.icon ?? DEFAULT_SKILL_ICON)}
- text={item.label}
+ <SuggestionListItem
+ id={id}
+ startIcon={<Icon />}
selected={isSelected}
- onClick={() => {
+ onSelect={() => {
onSelect(item);
}}
- />
+ >
+ {item.label}
+ </SuggestionListItem>
);
};
diff --git a/packages/twenty-front/src/modules/ui/input/constants/SlashMenuListId.ts b/packages/twenty-front/src/modules/ui/input/constants/SlashMenuListId.ts
deleted file mode 100644
index ac1e4f51874..00000000000
--- a/packages/twenty-front/src/modules/ui/input/constants/SlashMenuListId.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const SLASH_MENU_LIST_ID = 'editor-slash-menu-list';
diff --git a/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRow.tsx b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRow.tsx
new file mode 100644
index 00000000000..929a2b30173
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRow.tsx
@@ -0,0 +1,97 @@
+import { styled } from '@linaria/react';
+import { type ReactNode } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { ListItem } from 'twenty-ui/primitives/navigation';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+import { DraggableListRowLeadingContent } from '@/ui/layout/draggable-list/components/DraggableListRowLeadingContent';
+import { DraggableListRowPrimaryAction } from '@/ui/layout/draggable-list/components/DraggableListRowPrimaryAction';
+
+const StyledListItem = styled(ListItem)`
+ cursor: inherit;
+
+ &[data-muted] {
+ color: ${themeCssVariables.font.color.tertiary};
+ }
+`;
+
+const StyledDescription = styled.span`
+ color: ${themeCssVariables.font.color.light};
+`;
+
+const StyledActions = styled.span`
+ align-items: center;
+ display: flex;
+ position: relative;
+ z-index: 1;
+`;
+
+type DraggableListRowProps = {
+ children: ReactNode;
+ startIcon?: ReactNode;
+ actions?: ReactNode;
+ actionsVisibility?: 'hover' | 'always';
+ description?: ReactNode;
+ dragHandleVisibility?: 'always' | 'hover' | 'none';
+ isDragDisabled?: boolean;
+ hasIconBackground?: boolean;
+ isMuted?: boolean;
+ onAction?: () => void;
+ isActionDisabled?: boolean;
+};
+
+export const DraggableListRow = ({
+ children,
+ startIcon,
+ actions,
+ actionsVisibility = 'hover',
+ description,
+ dragHandleVisibility = 'none',
+ isDragDisabled = false,
+ hasIconBackground = false,
+ isMuted = false,
+ onAction,
+ isActionDisabled = false,
+}: DraggableListRowProps) => {
+ const hasLeadingContent =
+ isDefined(startIcon) || dragHandleVisibility === 'always';
+
+ return (
+ <StyledListItem
+ data-draggable-list-row
+ data-muted={isMuted || undefined}
+ startIcon={
+ hasLeadingContent && (
+ <DraggableListRowLeadingContent
+ startIcon={startIcon}
+ dragHandleVisibility={dragHandleVisibility}
+ hasIconBackground={hasIconBackground}
+ isDragDisabled={isDragDisabled}
+ />
+ )
+ }
+ description={
+ isDefined(description) ? (
+ <StyledDescription>{description}</StyledDescription>
+ ) : undefined
+ }
+ actions={
+ isDefined(actions) ? (
+ <StyledActions>{actions}</StyledActions>
+ ) : undefined
+ }
+ actionsVisibility={actionsVisibility}
+ >
+ {isDefined(onAction) ? (
+ <DraggableListRowPrimaryAction
+ onAction={onAction}
+ isDisabled={isActionDisabled}
+ >
+ {children}
+ </DraggableListRowPrimaryAction>
+ ) : (
+ children
+ )}
+ </StyledListItem>
+ );
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRowLeadingContent.tsx b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRowLeadingContent.tsx
new file mode 100644
index 00000000000..45c68f2930f
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRowLeadingContent.tsx
@@ -0,0 +1,144 @@
+import { styled } from '@linaria/react';
+import { type ReactNode } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { IconGripVertical } from 'twenty-ui/icon';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
+
+const StyledDefaultIcon = styled.span`
+ display: flex;
+
+ [data-draggable-list-row]:hover &,
+ [data-draggable-list-row]:focus-within & {
+ opacity: 0;
+ }
+`;
+
+const StyledIcon = styled.span`
+ align-items: center;
+ display: inline-flex;
+ justify-content: center;
+ position: relative;
+
+ > svg,
+ ${StyledDefaultIcon} > svg {
+ flex-shrink: 0;
+ height: calc(${themeCssVariables.icon.size.md} * 1px);
+ stroke-width: ${themeCssVariables.icon.stroke.sm};
+ width: calc(${themeCssVariables.icon.size.md} * 1px);
+ }
+
+ > svg[data-hover-grip] {
+ opacity: 0;
+ position: absolute;
+ }
+
+ [data-draggable-list-row]:hover & > svg[data-hover-grip],
+ [data-draggable-list-row]:focus-within & > svg[data-hover-grip] {
+ opacity: 1;
+ }
+
+ &[data-background] {
+ background: ${themeCssVariables.background.transparent.light};
+ border-radius: ${themeCssVariables.border.radius.sm};
+ padding: ${themeCssVariables.spacing[1]};
+ }
+`;
+
+const StyledLeadingContent = styled.span`
+ align-items: center;
+ display: inline-flex;
+ gap: ${themeCssVariables.spacing[2]};
+ position: relative;
+ z-index: 1;
+`;
+
+type DraggableListRowLeadingContentProps = {
+ startIcon?: ReactNode;
+ dragHandleVisibility: 'always' | 'hover' | 'none';
+ hasIconBackground: boolean;
+ isDragDisabled: boolean;
+};
+
+const getGripColor = ({
+ hasIconBackground,
+ isDragDisabled,
+}: Pick<
+ DraggableListRowLeadingContentProps,
+ 'hasIconBackground' | 'isDragDisabled'
+>) => {
+ if (hasIconBackground) {
+ return themeCssVariables.font.color.tertiary;
+ }
+
+ if (isDragDisabled) {
+ return themeCssVariables.font.color.extraLight;
+ }
+
+ return themeCssVariables.font.color.light;
+};
+
+const renderStartIcon = ({
+ startIcon,
+ grip,
+ dragHandleVisibility,
+ hasIconBackground,
+}: Pick<
+ DraggableListRowLeadingContentProps,
+ 'startIcon' | 'dragHandleVisibility' | 'hasIconBackground'
+> & {
+ grip: ReactNode;
+}) => {
+ if (!isDefined(startIcon)) {
+ return null;
+ }
+
+ if (dragHandleVisibility === 'hover') {
+ return (
+ <StyledIcon data-background={hasIconBackground || undefined}>
+ <StyledDefaultIcon>{startIcon}</StyledDefaultIcon>
+ {grip}
+ </StyledIcon>
+ );
+ }
+
+ return (
+ <StyledIcon data-background={hasIconBackground || undefined}>
+ {startIcon}
+ </StyledIcon>
+ );
+};
+
+export const DraggableListRowLeadingContent = ({
+ startIcon,
+ dragHandleVisibility,
+ hasIconBackground,
+ isDragDisabled,
+}: DraggableListRowLeadingContentProps) => {
+ const theme = useTheme();
+ const gripColor = getGripColor({ hasIconBackground, isDragDisabled });
+ const grip = (
+ <IconGripVertical
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ color={gripColor}
+ data-hover-grip={dragHandleVisibility === 'hover' || undefined}
+ aria-hidden
+ />
+ );
+
+ return (
+ <StyledLeadingContent>
+ {dragHandleVisibility === 'always' && (
+ <StyledIcon data-background={hasIconBackground || undefined}>
+ {grip}
+ </StyledIcon>
+ )}
+ {renderStartIcon({
+ startIcon,
+ grip,
+ dragHandleVisibility,
+ hasIconBackground,
+ })}
+ </StyledLeadingContent>
+ );
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRowPrimaryAction.tsx b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRowPrimaryAction.tsx
new file mode 100644
index 00000000000..c3725dcdf80
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRowPrimaryAction.tsx
@@ -0,0 +1,69 @@
+import { styled } from '@linaria/react';
+import { isString } from '@sniptt/guards';
+import { type ReactNode } from 'react';
+import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const DISABLED_PRIMARY_ACTION_OPACITY = 0.5;
+
+const StyledPrimaryAction = styled.button`
+ appearance: none;
+ background: transparent;
+ border: 0;
+ color: inherit;
+ cursor: pointer;
+ font: inherit;
+ max-width: 100%;
+ outline: none;
+ overflow: hidden;
+ padding: 0;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+
+ &::after {
+ content: '';
+ inset: 0;
+ position: absolute;
+ }
+
+ &&:focus-visible {
+ outline: none;
+ }
+
+ &:focus-visible::after {
+ border-radius: calc(
+ ${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}
+ );
+ outline: 2px solid ${themeCssVariables.color.blue};
+ outline-offset: -2px;
+ }
+
+ &:disabled {
+ cursor: not-allowed;
+ opacity: ${DISABLED_PRIMARY_ACTION_OPACITY};
+ }
+`;
+
+type DraggableListRowPrimaryActionProps = {
+ children: ReactNode;
+ onAction: () => void;
+ isDisabled: boolean;
+};
+
+export const DraggableListRowPrimaryAction = ({
+ children,
+ onAction,
+ isDisabled,
+}: DraggableListRowPrimaryActionProps) => {
+ const primaryAction = (
+ <StyledPrimaryAction type="button" onClick={onAction} disabled={isDisabled}>
+ {children}
+ </StyledPrimaryAction>
+ );
+
+ if (!isString(children)) {
+ return primaryAction;
+ }
+
+ return <OverflowingTextWithTooltip text={children} render={primaryAction} />;
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableItem.stories.tsx b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableItem.stories.tsx
index 286152de807..97cb5dc1a09 100644
--- a/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableItem.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableItem.stories.tsx
@@ -1,10 +1,11 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { fn } from 'storybook/test';
+import { expect, fn, userEvent, within } from 'storybook/test';
import { DraggableItem } from '@/ui/layout/draggable-list/components/DraggableItem';
import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableList';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
-import { IconBell } from 'twenty-ui/icon';
+import { LightIconButton } from 'twenty-ui/components/input';
+import { IconBell, IconEyeOff } from 'twenty-ui/icon';
import { ComponentDecorator } from 'twenty-ui/testing';
const meta: Meta<typeof DraggableItem> = {
@@ -25,7 +26,9 @@ const meta: Meta<typeof DraggableItem> = {
index: 0,
isDragDisabled: false,
itemComponent: (
- <MenuItemDraggable LeftIcon={IconBell} text="Draggable item 1" />
+ <DraggableListRow startIcon={<IconBell />}>
+ Draggable item 1
+ </DraggableListRow>
),
},
};
@@ -35,3 +38,56 @@ export default meta;
type Story = StoryObj<typeof DraggableItem>;
export const Default: Story = {};
+
+const onRowAction = fn();
+const onVisibilityChange = fn();
+
+export const SiblingActionKeyboardOwnership: Story = {
+ parameters: { container: { width: 320 } },
+ args: {
+ itemComponent: (
+ <DraggableListRow
+ startIcon={<IconBell />}
+ dragHandleVisibility="hover"
+ hasIconBackground
+ onAction={onRowAction}
+ actionsVisibility="always"
+ actions={
+ <LightIconButton aria-label="Hide field" onClick={onVisibilityChange}>
+ <IconEyeOff />
+ </LightIconButton>
+ }
+ >
+ Company name
+ </DraggableListRow>
+ ),
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const rowAction = canvas.getByText('Company name', { selector: 'button' });
+ const visibilityAction = canvas.getByRole('button', { name: 'Hide field' });
+
+ onRowAction.mockClear();
+ onVisibilityChange.mockClear();
+ await expect(rowAction).toHaveAttribute('type', 'button');
+ await expect(rowAction).not.toContainElement(visibilityAction);
+ await userEvent.click(rowAction);
+ await expect(onRowAction).toHaveBeenCalledTimes(1);
+ await userEvent.keyboard('{Enter}');
+ await expect(onRowAction).toHaveBeenCalledTimes(2);
+ await userEvent.keyboard(' ');
+ await expect(onRowAction).toHaveBeenCalledTimes(3);
+ await userEvent.tab();
+ await expect(visibilityAction).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(onVisibilityChange).toHaveBeenCalledTimes(1);
+ await userEvent.keyboard(' ');
+ await expect(onVisibilityChange).toHaveBeenCalledTimes(2);
+ await expect(onRowAction).toHaveBeenCalledTimes(3);
+ await userEvent.tab({ shift: true });
+ await expect(rowAction).toHaveFocus();
+ const focusRing = getComputedStyle(rowAction, '::after');
+ await expect(focusRing.outlineStyle).toBe('solid');
+ await expect(focusRing.outlineWidth).toBe('2px');
+ },
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableList.stories.tsx b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableList.stories.tsx
index 23e2968f9bf..f472da42ced 100644
--- a/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableList.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableList.stories.tsx
@@ -1,22 +1,22 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { DraggableItem } from '@/ui/layout/draggable-list/components/DraggableItem';
import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableList';
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { action } from 'storybook/actions';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
-import { IconBell } from 'twenty-ui/icon';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import { isDefined } from 'twenty-shared/utils';
+import { LightIconButton } from 'twenty-ui/components/input';
+import { IconBell, IconEyeOff } from 'twenty-ui/icon';
import { ComponentDecorator } from 'twenty-ui/testing';
const meta: Meta<typeof DraggableList> = {
title: 'UI/Layout/DraggableList/DraggableList',
component: DraggableList,
decorators: [ComponentDecorator],
- parameters: {
- onDragEnd: action('dragged'),
- },
argTypes: {
draggableItems: { control: false },
},
args: {
+ onDragEnd: fn(),
draggableItems: (
<>
<DraggableItem
@@ -24,24 +24,27 @@ const meta: Meta<typeof DraggableList> = {
index={0}
isDragDisabled={false}
itemComponent={
- <MenuItemDraggable
- LeftIcon={IconBell}
- text="Non Draggable item 1"
- />
+ <DraggableListRow startIcon={<IconBell />}>
+ Draggable item 1
+ </DraggableListRow>
}
/>
<DraggableItem
draggableId="draggable-2"
index={1}
itemComponent={
- <MenuItemDraggable LeftIcon={IconBell} text="Draggable item 2" />
+ <DraggableListRow startIcon={<IconBell />}>
+ Draggable item 2
+ </DraggableListRow>
}
/>
<DraggableItem
draggableId="draggable-3"
index={2}
itemComponent={
- <MenuItemDraggable LeftIcon={IconBell} text="Draggable item 3" />
+ <DraggableListRow startIcon={<IconBell />}>
+ Draggable item 3
+ </DraggableListRow>
}
/>
</>
@@ -51,6 +54,142 @@ const meta: Meta<typeof DraggableList> = {
export default meta;
-type Story = StoryObj<typeof DraggableItem>;
+type Story = StoryObj<typeof DraggableList>;
export const Default: Story = {};
+
+export const KeyboardReorder: Story = {
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const firstItem = canvas.getByRole('button', { name: 'Draggable item 1' });
+
+ await userEvent.tab();
+ await expect(firstItem).toHaveFocus();
+ await userEvent.keyboard(' ');
+ await userEvent.keyboard('{Shift>}{ArrowDown}{/Shift}');
+ await userEvent.keyboard(' ');
+ await expect(args.onDragEnd).toHaveBeenCalledTimes(1);
+ await expect(args.onDragEnd).toHaveBeenCalledWith({
+ draggableId: 'draggable-1',
+ source: { index: 0 },
+ destination: { index: 1 },
+ });
+ },
+};
+
+const onRowAction = fn();
+const onVisibilityChange = fn();
+
+export const PointerGripReorder: Story = {
+ parameters: { container: { width: 320 } },
+ args: {
+ draggableItems: (
+ <>
+ <DraggableItem
+ draggableId="draggable-1"
+ index={0}
+ itemComponent={
+ <DraggableListRow
+ startIcon={<IconBell />}
+ dragHandleVisibility="hover"
+ hasIconBackground
+ onAction={onRowAction}
+ actionsVisibility="always"
+ actions={
+ <LightIconButton
+ aria-label="Hide field"
+ onClick={onVisibilityChange}
+ >
+ <IconEyeOff />
+ </LightIconButton>
+ }
+ >
+ Company name
+ </DraggableListRow>
+ }
+ />
+ <DraggableItem
+ draggableId="draggable-2"
+ index={1}
+ itemComponent={
+ <DraggableListRow startIcon={<IconBell />}>Phone</DraggableListRow>
+ }
+ />
+ </>
+ ),
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const pointerUser = userEvent.setup();
+ const rowAction = canvas
+ .getAllByRole('button', { name: 'Company name' })
+ .find((button) => button instanceof HTMLButtonElement);
+
+ if (!isDefined(rowAction)) {
+ throw new Error('The row action must be a native button');
+ }
+
+ const firstItem = rowAction.closest('[aria-roledescription="draggable"]');
+
+ if (!(firstItem instanceof HTMLElement)) {
+ throw new Error('The row action must stay inside its drag host');
+ }
+ const secondItem = canvas.getByRole('button', { name: 'Phone' });
+ const firstBounds = firstItem.getBoundingClientRect();
+ const secondBounds = secondItem.getBoundingClientRect();
+ const clientX = firstBounds.left + 16;
+ const clientY = firstBounds.top + firstBounds.height / 2;
+ const dragSurface = canvasElement.ownerDocument.elementFromPoint(
+ clientX,
+ clientY,
+ );
+
+ if (
+ !isDefined(dragSurface) ||
+ (!(dragSurface instanceof HTMLElement) &&
+ !(dragSurface instanceof SVGElement))
+ ) {
+ throw new Error('The drag grip must have a pointer target');
+ }
+
+ onRowAction.mockClear();
+ onVisibilityChange.mockClear();
+ await expect(rowAction).not.toContainElement(dragSurface);
+ await pointerUser.pointer([
+ {
+ target: dragSurface,
+ keys: '[MouseLeft>]',
+ coords: { clientX, clientY },
+ },
+ {
+ target: dragSurface,
+ coords: { clientX, clientY: clientY + 12 },
+ },
+ ]);
+ await waitFor(() =>
+ expect(firstItem).toHaveAttribute('aria-grabbed', 'true'),
+ );
+ await pointerUser.pointer([
+ {
+ target: secondItem,
+ coords: { clientX, clientY: secondBounds.bottom - 4 },
+ },
+ ]);
+ await waitFor(() =>
+ expect(
+ within(canvasElement.ownerDocument.body).getByRole('status'),
+ ).toHaveTextContent(
+ 'Draggable item draggable-1 was moved over droppable target draggable-2.',
+ ),
+ );
+ await pointerUser.pointer({ target: secondItem, keys: '[/MouseLeft]' });
+ await waitFor(() => expect(args.onDragEnd).toHaveBeenCalledTimes(1));
+ await expect(args.onDragEnd).toHaveBeenCalledWith({
+ draggableId: 'draggable-1',
+ source: { index: 0 },
+ destination: { index: 1 },
+ });
+ await expect(onRowAction).not.toHaveBeenCalled();
+ await expect(onVisibilityChange).not.toHaveBeenCalled();
+ },
+};
diff --git a/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableListRow.stories.tsx b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableListRow.stories.tsx
new file mode 100644
index 00000000000..23813d13282
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/draggable-list/components/__stories__/DraggableListRow.stories.tsx
@@ -0,0 +1,104 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import { LightIconButton } from 'twenty-ui/components/input';
+import { IconBell, IconEyeOff } from 'twenty-ui/icon';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+const onVisibilityChange = fn();
+
+const meta: Meta<typeof DraggableListRow> = {
+ title: 'UI/Layout/DraggableList/DraggableListRow',
+ component: DraggableListRow,
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 320 } },
+ args: {
+ children: 'Company name',
+ startIcon: <IconBell />,
+ dragHandleVisibility: 'always',
+ actionsVisibility: 'always',
+ actions: (
+ <LightIconButton aria-label="Hide field" onClick={onVisibilityChange}>
+ <IconEyeOff />
+ </LightIconButton>
+ ),
+ },
+};
+
+export default meta;
+
+type Story = StoryObj<typeof DraggableListRow>;
+
+export const PresentationalRow: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const action = canvas.getByRole('button', { name: 'Hide field' });
+
+ onVisibilityChange.mockClear();
+ await expect(canvas.getAllByRole('button')).toHaveLength(1);
+ await userEvent.tab();
+ await expect(action).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(onVisibilityChange).toHaveBeenCalledTimes(1);
+ },
+};
+
+export const DisabledPrimaryAction: Story = {
+ args: { onAction: fn(), isActionDisabled: true, isDragDisabled: true },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const rowAction = canvas.getByRole('button', { name: 'Company name' });
+ const visibilityAction = canvas.getByRole('button', { name: 'Hide field' });
+
+ onVisibilityChange.mockClear();
+ await expect(rowAction).toBeDisabled();
+ await expect(visibilityAction).toBeEnabled();
+ await userEvent.tab();
+ await expect(visibilityAction).toHaveFocus();
+ await userEvent.click(visibilityAction);
+ await expect(onVisibilityChange).toHaveBeenCalledTimes(1);
+ await expect(args.onAction).not.toHaveBeenCalled();
+ },
+};
+
+export const OverflowingPrimaryAction: Story = {
+ parameters: { container: { width: 180 } },
+ args: {
+ children: 'A record creation form field with a long label',
+ onAction: fn(),
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ const rowAction = canvas.getByRole('button', {
+ name: 'A record creation form field with a long label',
+ });
+ const visibilityAction = canvas.getByRole('button', { name: 'Hide field' });
+
+ onVisibilityChange.mockClear();
+ await expect(rowAction.scrollWidth).toBeGreaterThan(rowAction.clientWidth);
+ await userEvent.hover(rowAction);
+ await expect(await page.findByRole('tooltip')).toHaveTextContent(
+ 'A record creation form field with a long label',
+ );
+ await userEvent.click(rowAction);
+ await expect(args.onAction).toHaveBeenCalledTimes(1);
+ await expect(rowAction).toHaveFocus();
+ await userEvent.unhover(rowAction);
+ await expect(page.getByRole('tooltip')).toBeVisible();
+ await userEvent.tab();
+ await expect(visibilityAction).toHaveFocus();
+ await waitFor(() =>
+ expect(page.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ await userEvent.click(visibilityAction);
+ await expect(onVisibilityChange).toHaveBeenCalledTimes(1);
+ await expect(args.onAction).toHaveBeenCalledTimes(1);
+ await userEvent.tab({ shift: true });
+ await expect(rowAction).toHaveFocus();
+ await expect(getComputedStyle(rowAction).outlineStyle).toBe('none');
+ const focusRing = getComputedStyle(rowAction, '::after');
+ await expect(focusRing.outlineStyle).toBe('solid');
+ await expect(focusRing.outlineWidth).toBe('2px');
+ },
+};
diff --git a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionListItem.tsx b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionListItem.tsx
new file mode 100644
index 00000000000..90a27b05697
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionListItem.tsx
@@ -0,0 +1,66 @@
+import { styled } from '@linaria/react';
+import { isNonEmptyString } from '@sniptt/guards';
+import { type ReactNode, type Ref } from 'react';
+import { ListItemButton } from 'twenty-ui/components/navigation';
+import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const StyledListItemButton = styled(ListItemButton)`
+ &[aria-selected='true'] {
+ background: ${themeCssVariables.background.transparent.medium};
+ }
+
+ &:hover {
+ background: ${themeCssVariables.background.transparent.light};
+ }
+`;
+
+const StyledDescription = styled.span`
+ color: ${themeCssVariables.font.color.light};
+`;
+
+type SuggestionListItemProps = {
+ id?: string;
+ ref?: Ref<HTMLButtonElement>;
+ children: ReactNode;
+ startIcon?: ReactNode;
+ description?: string;
+ selected: boolean;
+ onSelect: () => void;
+};
+
+export const SuggestionListItem = ({
+ id,
+ ref,
+ children,
+ startIcon,
+ description,
+ selected,
+ onSelect,
+}: SuggestionListItemProps) => (
+ <StyledListItemButton
+ id={id}
+ ref={ref}
+ role="option"
+ aria-selected={selected}
+ selected={selected}
+ tabIndex={-1}
+ startIcon={startIcon}
+ description={
+ isNonEmptyString(description) ? (
+ <OverflowingTextWithTooltip
+ text={description}
+ render={<StyledDescription />}
+ />
+ ) : undefined
+ }
+ onMouseDown={(event) => event.preventDefault()}
+ onClick={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ onSelect();
+ }}
+ >
+ {children}
+ </StyledListItemButton>
+);
diff --git a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenu.tsx b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenu.tsx
index 2cb3ff57572..5240950d411 100644
--- a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenu.tsx
+++ b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenu.tsx
@@ -6,8 +6,10 @@ import {
useFloating,
} from '@floating-ui/react';
import { motion } from 'framer-motion';
+import { t } from '@lingui/core/macro';
import {
forwardRef,
+ useId,
useImperativeHandle,
useLayoutEffect,
useMemo,
@@ -21,6 +23,7 @@ import { OverlayMenuList } from '@/ui/layout/overlay/components/OverlayMenuList'
import { OverlayMenuListSeparator } from '@/ui/layout/overlay/components/OverlayMenuListSeparator';
import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer';
import { SuggestionItemPreviewTooltip } from '@/ui/suggestion/components/SuggestionItemPreviewTooltip';
+import { SuggestionMenuAccessibilityEffect } from '@/ui/suggestion/components/SuggestionMenuAccessibilityEffect';
import type { SuggestionMenuProps } from '@/ui/suggestion/types/SuggestionMenuProps';
import { getSuggestionMenuItemAnchorId } from '@/ui/suggestion/utils/getSuggestionMenuItemAnchorId';
import { isDefined } from 'twenty-shared/utils';
@@ -47,6 +50,7 @@ const SuggestionMenuInner = <TItem,>(
} = props;
const isMobile = useIsMobile();
+ const menuId = useId();
const [selectedIndex, setSelectedIndex] = useState(0);
@@ -54,6 +58,12 @@ const SuggestionMenuInner = <TItem,>(
items.length > 0 ? Math.min(selectedIndex, items.length - 1) : 0;
const selectedItem = items[clampedSelectedIndex];
+ const activeOptionId = isDefined(selectedItem)
+ ? getSuggestionMenuItemAnchorId({
+ menuId,
+ itemKey: getItemKey(selectedItem),
+ })
+ : undefined;
const [isSelectedItemVisible, setIsSelectedItemVisible] = useState(true);
@@ -199,7 +209,15 @@ const SuggestionMenuInner = <TItem,>(
transition={{ duration: 0.1 }}
data-suggestion-menu
>
+ <SuggestionMenuAccessibilityEffect
+ editor={editor}
+ menuId={menuId}
+ activeOptionId={activeOptionId}
+ />
<OverlayContainer
+ id={menuId}
+ role="listbox"
+ aria-label={t`Suggestions`}
ref={refs.setFloating}
style={{
...floatingStyles,
@@ -218,7 +236,6 @@ const SuggestionMenuInner = <TItem,>(
return (
<div
key={getItemKey(item)}
- id={getSuggestionMenuItemAnchorId(getItemKey(item))}
ref={isSelected ? activeItemRef : null}
onMouseDown={(event) => {
event.preventDefault();
@@ -228,7 +245,14 @@ const SuggestionMenuInner = <TItem,>(
{isFirstOfSection && (
<DropdownMenuSectionLabel label={section.label} />
)}
- {renderItem(item, isSelected)}
+ {renderItem({
+ item,
+ isSelected,
+ id: getSuggestionMenuItemAnchorId({
+ menuId,
+ itemKey: getItemKey(item),
+ }),
+ })}
</div>
);
})}
diff --git a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenuAccessibilityEffect.tsx b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenuAccessibilityEffect.tsx
new file mode 100644
index 00000000000..6d56ba441e6
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionMenuAccessibilityEffect.tsx
@@ -0,0 +1,97 @@
+import { type Editor } from '@tiptap/core';
+import { useEffect, useRef } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+
+type SuggestionMenuAccessibilityEffectProps = {
+ editor: Editor;
+ menuId: string;
+ activeOptionId?: string;
+};
+
+const restoreAttributeIfUnchanged = ({
+ editorElement,
+ attributeName,
+ previousValue,
+ writtenValue,
+}: {
+ editorElement: HTMLElement;
+ attributeName: string;
+ previousValue: string | null;
+ writtenValue: string | null;
+}) => {
+ if (editorElement.getAttribute(attributeName) !== writtenValue) {
+ return;
+ }
+
+ if (isDefined(previousValue)) {
+ editorElement.setAttribute(attributeName, previousValue);
+ return;
+ }
+
+ editorElement.removeAttribute(attributeName);
+};
+
+export const SuggestionMenuAccessibilityEffect = ({
+ editor,
+ menuId,
+ activeOptionId,
+}: SuggestionMenuAccessibilityEffectProps) => {
+ const writtenActiveOptionElementRef = useRef<HTMLElement>(null);
+
+ useEffect(() => {
+ const editorElement = editor.view.dom;
+
+ const previousControls = editorElement.getAttribute('aria-controls');
+ const previousActiveDescendant = editorElement.getAttribute(
+ 'aria-activedescendant',
+ );
+
+ writtenActiveOptionElementRef.current = null;
+ editorElement.setAttribute('aria-controls', menuId);
+
+ return () => {
+ if (editorElement.getAttribute('aria-controls') !== menuId) {
+ return;
+ }
+
+ restoreAttributeIfUnchanged({
+ editorElement,
+ attributeName: 'aria-controls',
+ previousValue: previousControls,
+ writtenValue: menuId,
+ });
+ restoreAttributeIfUnchanged({
+ editorElement,
+ attributeName: 'aria-activedescendant',
+ previousValue: previousActiveDescendant,
+ writtenValue: writtenActiveOptionElementRef.current?.id ?? null,
+ });
+ };
+ }, [editor, menuId]);
+
+ useEffect(() => {
+ const editorElement = editor.view.dom;
+
+ if (editorElement.getAttribute('aria-controls') !== menuId) {
+ return;
+ }
+
+ const activeOptionElement = isDefined(activeOptionId)
+ ? editorElement.ownerDocument.getElementById(activeOptionId)
+ : null;
+
+ writtenActiveOptionElementRef.current = activeOptionElement;
+
+ if (isDefined(activeOptionElement)) {
+ editorElement.setAttribute(
+ 'aria-activedescendant',
+ activeOptionElement.id,
+ );
+ return;
+ }
+
+ editorElement.removeAttribute('aria-activedescendant');
+ }, [activeOptionId, editor, menuId]);
+
+ return null;
+};
diff --git a/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuItemRenderProps.ts b/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuItemRenderProps.ts
new file mode 100644
index 00000000000..0f58276f690
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuItemRenderProps.ts
@@ -0,0 +1,5 @@
+export type SuggestionMenuItemRenderProps<TItem> = {
+ item: TItem;
+ isSelected: boolean;
+ id: string;
+};
diff --git a/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuProps.ts b/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuProps.ts
index f93c4fd03ef..2c3ffe12b77 100644
--- a/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuProps.ts
+++ b/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuProps.ts
@@ -1,15 +1,9 @@
import type { Editor, Range } from '@tiptap/core';
import type { ReactNode } from 'react';
-export type SuggestionMenuSelectedItemPreview<TItem> = {
- render: (item: TItem) => ReactNode;
- width: number;
-};
-
-export type SuggestionMenuSection = {
- key: string;
- label: string;
-};
+import { type SuggestionMenuItemRenderProps } from '@/ui/suggestion/types/SuggestionMenuItemRenderProps';
+import { type SuggestionMenuSection } from '@/ui/suggestion/types/SuggestionMenuSection';
+import { type SuggestionMenuSelectedItemPreview } from '@/ui/suggestion/types/SuggestionMenuSelectedItemPreview';
export type SuggestionMenuProps<TItem> = {
items: TItem[];
@@ -17,7 +11,7 @@ export type SuggestionMenuProps<TItem> = {
editor: Editor;
range: Range;
getItemKey: (item: TItem) => string;
- renderItem: (item: TItem, isSelected: boolean) => ReactNode;
+ renderItem: (props: SuggestionMenuItemRenderProps<TItem>) => ReactNode;
selectedItemPreview?: SuggestionMenuSelectedItemPreview<TItem>;
getItemSection?: (item: TItem) => SuggestionMenuSection;
onKeyDown?: (
diff --git a/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuSection.ts b/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuSection.ts
new file mode 100644
index 00000000000..479992f0ace
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuSection.ts
@@ -0,0 +1,4 @@
+export type SuggestionMenuSection = {
+ key: string;
+ label: string;
+};
diff --git a/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuSelectedItemPreview.ts b/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuSelectedItemPreview.ts
new file mode 100644
index 00000000000..d818c950590
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/suggestion/types/SuggestionMenuSelectedItemPreview.ts
@@ -0,0 +1,6 @@
+import { type ReactNode } from 'react';
+
+export type SuggestionMenuSelectedItemPreview<TItem> = {
+ render: (item: TItem) => ReactNode;
+ width: number;
+};
diff --git a/packages/twenty-front/src/modules/ui/suggestion/utils/getSuggestionMenuItemAnchorId.ts b/packages/twenty-front/src/modules/ui/suggestion/utils/getSuggestionMenuItemAnchorId.ts
index 6a53c503ea1..8339cc0b5e5 100644
--- a/packages/twenty-front/src/modules/ui/suggestion/utils/getSuggestionMenuItemAnchorId.ts
+++ b/packages/twenty-front/src/modules/ui/suggestion/utils/getSuggestionMenuItemAnchorId.ts
@@ -1,2 +1,7 @@
-export const getSuggestionMenuItemAnchorId = (itemKey: string) =>
- `suggestion-menu-item-${itemKey.replace(/[^a-zA-Z0-9-_]/g, '_')}`;
+export const getSuggestionMenuItemAnchorId = ({
+ menuId,
+ itemKey,
+}: {
+ menuId: string;
+ itemKey: string;
+}) => `${menuId}-${encodeURIComponent(itemKey)}`;
diff --git a/packages/twenty-front/src/modules/views/components/ViewFieldsVisibleDropdownSection.tsx b/packages/twenty-front/src/modules/views/components/ViewFieldsVisibleDropdownSection.tsx
index 881acac98e0..be05a54ff10 100644
--- a/packages/twenty-front/src/modules/views/components/ViewFieldsVisibleDropdownSection.tsx
+++ b/packages/twenty-front/src/modules/views/components/ViewFieldsVisibleDropdownSection.tsx
@@ -1,3 +1,4 @@
+import { DraggableListRow } from '@/ui/layout/draggable-list/components/DraggableListRow';
import { ApplicationStackIcon } from '@/applications/components/ApplicationStackIcon';
import { useGetFieldMetadataItemByIdOrThrow } from '@/object-metadata/hooks/useGetFieldMetadataItemById';
import { getLabelIdentifierFieldMetadataItem } from '@/object-metadata/utils/getLabelIdentifierFieldMetadataItem';
@@ -16,7 +17,6 @@ import { t } from '@lingui/core/macro';
import { useContext } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { LightIconButton } from 'twenty-ui/components/input';
-import { MenuItemDraggable } from 'twenty-ui/components/navigation';
import { IconEyeOff, useIcons } from 'twenty-ui/icon';
import { sortByProperty } from '~/utils/array/sortByProperty';
@@ -89,18 +89,19 @@ export const ViewFieldsVisibleDropdownSection = () => {
<>
<DropdownMenuItemsContainer>
{fieldMetadataItemLabelIdentifier && (
- <MenuItemDraggable
- LeftComponent={
+ <DraggableListRow
+ startIcon={
<ApplicationStackIcon
Icon={getIcon(fieldMetadataItemLabelIdentifier.icon)}
applicationId={fieldMetadataItemLabelIdentifier.applicationId}
/>
}
- text={fieldMetadataItemLabelIdentifier.label}
- accent="placeholder"
- gripMode="always"
+ isMuted
+ dragHandleVisibility="always"
isDragDisabled
- />
+ >
+ {fieldMetadataItemLabelIdentifier.label}
+ </DraggableListRow>
)}
{draggableRecordFields.length > 0 && (
<DraggableList
@@ -118,15 +119,15 @@ export const ViewFieldsVisibleDropdownSection = () => {
draggableId={recordField.fieldMetadataItemId}
index={index}
itemComponent={
- <MenuItemDraggable
+ <DraggableListRow
key={recordField.fieldMetadataItemId}
- LeftComponent={
+ startIcon={
<ApplicationStackIcon
Icon={getIcon(fieldMetadataItem.icon)}
applicationId={fieldMetadataItem.applicationId}
/>
}
- iconButtons={
+ actions={
<LightIconButton
aria-label={t`Hide field`}
onClick={() => {
@@ -140,9 +141,10 @@ export const ViewFieldsVisibleDropdownSection = () => {
<IconEyeOff />
</LightIconButton>
}
- text={fieldMetadataItem.label}
- gripMode="always"
- />
+ dragHandleVisibility="always"
+ >
+ {fieldMetadataItem.label}
+ </DraggableListRow>
}
/>
);
diff --git a/packages/twenty-oxlint-rules/rules/no-twenty-ui-override.exemptions.ts b/packages/twenty-oxlint-rules/rules/no-twenty-ui-override.exemptions.ts
index b6d50e81df7..a32eee5ccf3 100644
--- a/packages/twenty-oxlint-rules/rules/no-twenty-ui-override.exemptions.ts
+++ b/packages/twenty-oxlint-rules/rules/no-twenty-ui-override.exemptions.ts
@@ -146,6 +146,12 @@ export const TWENTY_UI_OVERRIDE_EXEMPTIONS = [
'packages/twenty-front/src/modules/settings/mcp/components/SettingsMcpSetupCard.tsx',
reason: 'One-off Card.Content row layout',
},
+ {
+ filePath:
+ 'packages/twenty-front/src/modules/side-panel/pages/page-layout/components/ChartTypeSelectionSection.tsx',
+ reason:
+ 'Chart type icon tiles preserve their border, shape and selection colors',
+ },
{
filePath:
'packages/twenty-front/src/modules/spreadsheet-import/components/SpreadSheetImportModalWrapper.tsx',
@@ -182,11 +188,22 @@ export const TWENTY_UI_OVERRIDE_EXEMPTIONS = [
reason:
'Runtime position and stacking of Dialog.Backdrop and Dialog.Viewport',
},
+ {
+ filePath:
+ 'packages/twenty-front/src/modules/ui/layout/draggable-list/components/DraggableListRow.tsx',
+ reason: 'Drag host grip swapping and placement of separate row actions',
+ },
{
filePath:
'packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListRoot.tsx',
reason: 'Tabs.Root rendered as a display contents adapter',
},
+ {
+ filePath:
+ 'packages/twenty-front/src/modules/ui/suggestion/components/SuggestionListItem.tsx',
+ reason:
+ 'Editor integration keeps the active suggestion fill while focus stays in the editor',
+ },
{
filePath:
'packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-edges/components/WorkflowDiagramEdgeButtonGroup.tsx',
diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.ts
index 625ad282578..15f6f34c508 100644
--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts
+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts
@@ -170,8 +170,6 @@ export const DOCUMENTATION_PATHS = {
UI_COMPONENTS_NAVIGATION_DROPDOWN: '/ui/components/navigation/dropdown',
UI_COMPONENTS_NAVIGATION_LIST_ITEM_BUTTON:
'/ui/components/navigation/list-item-button',
- UI_COMPONENTS_NAVIGATION_MENU_ITEMS: '/ui/components/navigation/menu-items',
- UI_COMPONENTS_NAVIGATION_MENU_PICKER: '/ui/components/navigation/menu-picker',
UI_COMPONENTS_NAVIGATION_TAB_BUTTON: '/ui/components/navigation/tab-button',
UI_COMPONENTS_OVERVIEW: '/ui/components/overview',
UI_COMPONENTS_SETTINGS_SETTINGS_ROW: '/ui/components/settings/settings-row',
diff --git a/packages/twenty-ui/CHANGELOG.md b/packages/twenty-ui/CHANGELOG.md
new file mode 100644
index 00000000000..3f2ad65cc2e
--- /dev/null
+++ b/packages/twenty-ui/CHANGELOG.md
@@ -0,0 +1,18 @@
+# Changelog
+
+## Unreleased
+
+### Breaking changes
+
+Removed `MenuItem`, `MenuItemAvatar`, `MenuItemDraggable`, `MenuItemSuggestion` and `MenuPicker` from `twenty-ui/components/navigation` and the aggregate exports. Their props types and `MenuItemDraggableGripMode` are also removed. Applications must migrate these imports before upgrading.
+
+| Removed API | Replacement |
+| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `MenuItem` and `MenuItemProps` | Use `Dropdown.ActionItem` for menu commands, `Dropdown.OptionItem` for menu choices, `ListItemButton` for standalone actions, or `ListItem` for passive content. |
+| `MenuItemAvatar` and `MenuItemAvatarProps` | Compose `Avatar` inside the appropriate canonical row. |
+| `MenuItemDraggable` and `MenuItemDraggableProps` | Compose `ListItem` from `twenty-ui/primitives/navigation` inside the application's drag host. The host owns drag handles and reordering. Keep independent action buttons in `ListItem.actions`. |
+| `MenuItemSuggestion` and `MenuItemSuggestionProps` | Use `Dropdown.ActionItem` or `Dropdown.OptionItem` in a Dropdown page. For editor suggestions, compose `ListItem` or `ListItemButton` with the editor's option IDs and active-descendant state, keeping keyboard navigation in the editor. |
+| `MenuPicker` and `MenuPickerProps` | Use `Button` from `twenty-ui/primitives/input` for standalone actions or pressed toggles. Use a selection owner such as `Dropdown.SelectionGroup` or `RadioGroup` when the workflow requires grouped choice navigation. |
+| `MenuItemDraggableGripMode` | Choose grip presentation in the application's drag host. |
+
+The package remains in alpha and follows the Twenty SDK release version.
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 625213de0fd..3e37ab60e5b 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -31,9 +31,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_DRAGGABLE_PROP_DESCRIPTIONS } from './menuItemDraggablePropDescriptions';
-import { MENU_ITEM_SUGGESTION_PROP_DESCRIPTIONS } from './menuItemSuggestionPropDescriptions';
-import { MENU_PICKER_PROP_DESCRIPTIONS } from './menuPickerPropDescriptions';
import { THEME_PROVIDER_PROP_DESCRIPTIONS } from './themeProviderPropDescriptions';
import { ICON_PROP_DESCRIPTIONS } from './iconPropDescriptions';
import { ICONS_PROVIDER_PROP_DESCRIPTIONS } from './iconsProviderPropDescriptions';
@@ -997,27 +994,6 @@ export const DOCUMENTED_COMPONENTS = [
slug: 'components/layout/animated-icon-crossfade',
propDescriptions: ANIMATED_ICON_CROSSFADE_PROP_DESCRIPTIONS,
},
- {
- name: 'MenuItemDraggable',
- source: 'components/navigation/MenuItemDraggable/MenuItemDraggable.tsx',
- entryPoint: 'twenty-ui/components/navigation',
- slug: 'components/navigation/menu-item-draggable',
- propDescriptions: MENU_ITEM_DRAGGABLE_PROP_DESCRIPTIONS,
- },
- {
- name: 'MenuItemSuggestion',
- source: 'components/navigation/MenuItemSuggestion/MenuItemSuggestion.tsx',
- entryPoint: 'twenty-ui/components/navigation',
- slug: 'components/navigation/menu-item-suggestion',
- propDescriptions: MENU_ITEM_SUGGESTION_PROP_DESCRIPTIONS,
- },
- {
- name: 'MenuPicker',
- source: 'components/navigation/MenuPicker/MenuPicker.tsx',
- entryPoint: 'twenty-ui/components/navigation',
- slug: 'components/navigation/menu-picker',
- propDescriptions: MENU_PICKER_PROP_DESCRIPTIONS,
- },
{
name: 'ThemeProvider',
source: 'theme/ThemeProvider.tsx',
diff --git a/packages/twenty-ui/docs/menuItemDraggablePropDescriptions.ts b/packages/twenty-ui/docs/menuItemDraggablePropDescriptions.ts
deleted file mode 100644
index b24bf911e11..00000000000
--- a/packages/twenty-ui/docs/menuItemDraggablePropDescriptions.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { type ComponentProps } from 'react';
-
-import { type MenuItemDraggable } from '../src/components/navigation/MenuItemDraggable/MenuItemDraggable';
-
-export const MENU_ITEM_DRAGGABLE_PROP_DESCRIPTIONS = {
- LeftIcon: 'Leading icon component.',
- LeftComponent: 'Custom leading content.',
- withIconContainer: 'Places leading content in an icon container.',
- accent: 'Default, danger, or placeholder row styling.',
- iconButtons: 'Trailing action elements.',
- isTooltipOpen: 'Accepted for compatibility; currently has no effect.',
- onClick:
- 'Pointer activation callback. The row itself does not add keyboard or menu semantics.',
- text: 'Main row label.',
- contextualText: 'Supporting text beside the main label.',
- className: 'Class applied to the row.',
- isIconDisplayedOnHoverOnly: 'Reveals trailing action elements only on hover.',
- gripMode:
- 'Grip visibility: never, always, or onHover. always and onHover render a single leading content (LeftComponent when set, otherwise LeftIcon); onHover swaps it for the grip on hover and shows no grip without leading content. Does not implement dragging.',
- isDragDisabled:
- 'Disables drag appearance without installing or removing drag handlers.',
- isHoverDisabled: 'Accepted for compatibility; currently has no effect.',
-} satisfies Partial<
- Record<keyof ComponentProps<typeof MenuItemDraggable>, string>
->;
diff --git a/packages/twenty-ui/docs/menuItemSuggestionPropDescriptions.ts b/packages/twenty-ui/docs/menuItemSuggestionPropDescriptions.ts
deleted file mode 100644
index 81a99fc7d6a..00000000000
--- a/packages/twenty-ui/docs/menuItemSuggestionPropDescriptions.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { type ComponentProps } from 'react';
-
-import { type MenuItemSuggestion } from '../src/components/navigation/MenuItemSuggestion/MenuItemSuggestion';
-
-export const MENU_ITEM_SUGGESTION_PROP_DESCRIPTIONS = {
- LeftIcon: 'Leading icon component.',
- withIconContainer: 'Places leading content in an icon container.',
- text: 'Main row label.',
- contextualText: 'Supporting text beside the main label.',
- contextualTextPosition: 'Position of the supporting text.',
- selected: 'Applies selected styling. The application owns selection.',
- className: 'Class applied to the row.',
- onClick:
- 'Activation callback. When supplied, the row gains button semantics, a tab stop, and Enter/Space activation.',
-} satisfies Partial<
- Record<keyof ComponentProps<typeof MenuItemSuggestion>, string>
->;
diff --git a/packages/twenty-ui/docs/menuPickerPropDescriptions.ts b/packages/twenty-ui/docs/menuPickerPropDescriptions.ts
deleted file mode 100644
index 54d57b07810..00000000000
--- a/packages/twenty-ui/docs/menuPickerPropDescriptions.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { type ComponentProps } from 'react';
-
-import { type MenuPicker } from '../src/components/navigation/MenuPicker/MenuPicker';
-
-export const MENU_PICKER_PROP_DESCRIPTIONS = {
- id: 'Button ID.',
- className: 'Class applied to the button.',
- disabled: 'Disables the button.',
- icon: 'Leading icon component.',
- label: 'Button label and accessible name, including when showLabel is false.',
- onClick: 'Activation callback.',
- selected: 'Controls selected styling and aria-pressed.',
- showLabel: 'Shows the visible label beside the icon.',
- testId: 'Value of the button’s data-testid attribute.',
- tooltipContent: 'Optional tooltip text.',
- tooltipDelay: 'Hover delay in milliseconds.',
- tooltipOffset: 'Distance between the button and tooltip in pixels.',
-} satisfies Partial<Record<keyof ComponentProps<typeof MenuPicker>, string>>;
diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.json
index 055fd47bff3..22e4ba1098d 100644
--- a/packages/twenty-ui/docs/module-ownership.json
+++ b/packages/twenty-ui/docs/module-ownership.json
@@ -63,9 +63,6 @@
"LightIconButton",
"ListItemButton",
"MainButton",
- "MenuItemDraggable",
- "MenuItemSuggestion",
- "MenuPicker",
"MetricRow",
"NumberStepper",
"OverflowingList",
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index edaf90e7001..9df325e94c6 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -151,9 +151,6 @@
"DEFAULT_COLOR_LABELS": "components/navigation/MenuItem/constants/DefaultColorLabels",
"Dropdown": "components/navigation/Dropdown/Dropdown",
"ListItemButton": "components/navigation/ListItemButton/ListItemButton",
- "MenuItemDraggable": "components/navigation/MenuItemDraggable/MenuItemDraggable",
- "MenuItemSuggestion": "components/navigation/MenuItemSuggestion/MenuItemSuggestion",
- "MenuPicker": "components/navigation/MenuPicker/MenuPicker",
"TabButton": "components/navigation/TabButton/TabButton",
"useDropdownPage": "components/navigation/Dropdown/hooks/useDropdownPage"
},
@@ -181,10 +178,6 @@
"DropdownType": "components/navigation/Dropdown/types/DropdownType",
"ListItemButtonProps": "components/navigation/ListItemButton/types/ListItemButtonProps",
"MenuItemAccent": "components/navigation/MenuItem/types/MenuItemAccent",
- "MenuItemDraggableGripMode": "components/navigation/MenuItem/types/MenuItemDraggableGripMode",
- "MenuItemDraggableProps": "components/navigation/MenuItemDraggable/types/MenuItemDraggableProps",
- "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 b7fa3da3393..2624c3aa45e 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -14647,265 +14647,6 @@
}
]
},
- {
- "name": "MenuItemDraggable",
- "entryPoint": "twenty-ui/components/navigation",
- "slug": "components/navigation/menu-item-draggable",
- "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": "gripMode",
- "type": "\"always\" | \"never\" | \"onHover\"",
- "required": false,
- "defaultValue": "never",
- "description": "Grip visibility: never, always, or onHover. always and onHover render a single leading content (LeftComponent when set, otherwise LeftIcon); onHover swaps it for the grip on hover and shows no grip without leading content. Does not implement dragging."
- },
- {
- "name": "iconButtons",
- "type": "ReactNode",
- "required": false,
- "defaultValue": null,
- "description": "Trailing action elements."
- },
- {
- "name": "isDragDisabled",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Disables drag appearance without installing or removing drag handlers."
- },
- {
- "name": "isHoverDisabled",
- "type": "boolean",
- "required": false,
- "defaultValue": null,
- "description": "Accepted for compatibility; currently has no effect."
- },
- {
- "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": "LeftComponent",
- "type": "ReactNode",
- "required": false,
- "defaultValue": null,
- "description": "Custom leading content."
- },
- {
- "name": "LeftIcon",
- "type": "IconComponent",
- "required": false,
- "defaultValue": null,
- "description": "Leading icon component."
- },
- {
- "name": "onClick",
- "type": "(() => void)",
- "required": false,
- "defaultValue": null,
- "description": "Pointer activation callback. The row itself does not add keyboard or menu semantics."
- },
- {
- "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": "MenuItemSuggestion",
- "entryPoint": "twenty-ui/components/navigation",
- "slug": "components/navigation/menu-item-suggestion",
- "props": [
- {
- "name": "className",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Class applied to the row."
- },
- {
- "name": "contextualText",
- "type": "string",
- "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": "LeftIcon",
- "type": "IconComponent | null",
- "required": false,
- "defaultValue": null,
- "description": "Leading icon component."
- },
- {
- "name": "onClick",
- "type": "((event: MouseEvent<HTMLLIElement, MouseEvent>) => void)",
- "required": false,
- "defaultValue": null,
- "description": "Activation callback. When supplied, the row gains button semantics, a tab stop, and Enter/Space activation."
- },
- {
- "name": "selected",
- "type": "boolean",
- "required": false,
- "defaultValue": null,
- "description": "Applies selected styling. The application owns selection."
- },
- {
- "name": "text",
- "type": "string",
- "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": "MenuPicker",
- "entryPoint": "twenty-ui/components/navigation",
- "slug": "components/navigation/menu-picker",
- "props": [
- {
- "name": "className",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Class applied to the button."
- },
- {
- "name": "disabled",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Disables the button."
- },
- {
- "name": "icon",
- "type": "IconComponent",
- "required": true,
- "defaultValue": null,
- "description": "Leading icon component."
- },
- {
- "name": "id",
- "type": "string",
- "required": true,
- "defaultValue": null,
- "description": "Button ID."
- },
- {
- "name": "label",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Button label and accessible name, including when showLabel is false."
- },
- {
- "name": "onClick",
- "type": "(() => void)",
- "required": false,
- "defaultValue": null,
- "description": "Activation callback."
- },
- {
- "name": "selected",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Controls selected styling and aria-pressed."
- },
- {
- "name": "showLabel",
- "type": "boolean",
- "required": false,
- "defaultValue": "true",
- "description": "Shows the visible label beside the icon."
- },
- {
- "name": "testId",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Value of the button’s data-testid attribute."
- },
- {
- "name": "tooltipContent",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Optional tooltip text."
- },
- {
- "name": "tooltipDelay",
- "type": "number",
- "required": false,
- "defaultValue": "0",
- "description": "Hover delay in milliseconds."
- },
- {
- "name": "tooltipOffset",
- "type": "number",
- "required": false,
- "defaultValue": "5",
- "description": "Distance between the button and tooltip in pixels."
- }
- ]
- },
{
"name": "ThemeProvider",
"entryPoint": "twenty-ui/theme",
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.module.scss.d.ts b/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.module.scss.d.ts
deleted file mode 100644
index 4e0a52fa2a0..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.module.scss.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-declare const classNames: {
- readonly subMenuIcon: 'subMenuIcon';
- readonly subMenuIconOpened: 'subMenuIconOpened';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIcon.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIcon.tsx
deleted file mode 100644
index 3f9bc2aab7b..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIcon.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { MenuItemIconBoxContainer } from '@ui/components/navigation/MenuItem/parts/MenuItemIconBoxContainer';
-import { TintedIconTile } from '@ui/components/data-display/TintedIconTile/TintedIconTile';
-import { type IconComponent } from '@ui/icon';
-import { type ThemeColor, useTheme } from '@ui/theme';
-
-import { isDefined } from '@ui/utilities/utils/isDefined';
-
-export type MenuItemIconProps = {
- Icon: IconComponent | null | undefined;
- iconThemeColor?: ThemeColor | null;
- withContainer?: boolean;
- withContainerBackground?: boolean;
-};
-
-export const MenuItemIcon = ({
- Icon,
- iconThemeColor,
- withContainer = false,
- withContainerBackground = true,
-}: MenuItemIconProps) => {
- const theme = useTheme();
-
- if (!Icon) {
- return null;
- }
-
- if (isDefined(iconThemeColor)) {
- return (
- <TintedIconTile
- icon={<Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />}
- color={iconThemeColor}
- />
- );
- }
-
- const iconElement = (
- <Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
- );
-
- if (withContainer) {
- return (
- <MenuItemIconBoxContainer hasBackground={withContainerBackground}>
- {iconElement}
- </MenuItemIconBoxContainer>
- );
- }
-
- return iconElement;
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.module.scss b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.module.scss
deleted file mode 100644
index de468042d52..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.module.scss
+++ /dev/null
@@ -1,11 +0,0 @@
-.iconContainer {
- align-items: flex-start;
- border-radius: var(--t-border-radius-sm);
- display: flex;
- flex-direction: column;
- padding: var(--t-spacing-1);
-}
-
-.withBackground {
- background: var(--t-background-transparent-light);
-}
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.module.scss.d.ts b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.module.scss.d.ts
deleted file mode 100644
index 43552f182f8..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.module.scss.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-declare const classNames: {
- readonly iconContainer: 'iconContainer';
- readonly withBackground: 'withBackground';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.tsx
deleted file mode 100644
index b3156f94388..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconBoxContainer.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { clsx } from 'clsx';
-import { type ReactNode } from 'react';
-
-import styles from './MenuItemIconBoxContainer.module.scss';
-
-export const StyledIconContainer = ({
- children,
- className,
- hasBackground = true,
-}: {
- children?: ReactNode;
- className?: string;
- hasBackground?: boolean;
-}) => (
- <div
- className={clsx(
- styles.iconContainer,
- hasBackground && styles.withBackground,
- className,
- )}
- >
- {children}
- </div>
-);
-
-export { StyledIconContainer as MenuItemIconBoxContainer };
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.module.scss b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.module.scss
deleted file mode 100644
index f1fbda33baa..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.module.scss
+++ /dev/null
@@ -1,18 +0,0 @@
-.iconSwapContainer {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.defaultIcon {
- display: flex;
- transition: opacity duration(instant) ease;
-}
-
-.hoverIcon {
- position: absolute;
- display: flex;
- opacity: 0;
- transition: opacity duration(instant) ease;
-}
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.module.scss.d.ts b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.module.scss.d.ts
deleted file mode 100644
index 154f9d61098..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.module.scss.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare const classNames: {
- readonly iconSwapContainer: 'iconSwapContainer';
- readonly defaultIcon: 'defaultIcon';
- readonly hoverIcon: 'hoverIcon';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.tsx
deleted file mode 100644
index 54c105f91ff..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { MenuItemIconBoxContainer } from '@ui/components/navigation/MenuItem/parts/MenuItemIconBoxContainer';
-import { IconGripVertical } from '@ui/icon';
-import { useTheme } from '@ui/theme';
-
-import { isDefined } from '@ui/utilities/utils/isDefined';
-import { clsx } from 'clsx';
-import { type ReactNode } from 'react';
-
-import styles from './MenuItemIconWithGripSwap.module.scss';
-
-export type MenuItemIconWithGripSwapProps = {
- leadingContent?: ReactNode;
- withIconContainer?: boolean;
- withIconContainerBackground?: boolean;
- gripIconColor: string;
-};
-
-export const MenuItemIconWithGripSwap = ({
- leadingContent,
- withIconContainer = false,
- withIconContainerBackground = true,
- gripIconColor,
-}: MenuItemIconWithGripSwapProps) => {
- const theme = useTheme();
-
- if (!isDefined(leadingContent)) {
- return null;
- }
-
- const iconContent = (
- <div className={styles.iconSwapContainer}>
- <div className={clsx(styles.defaultIcon, 'grip-swap-default-icon')}>
- {leadingContent}
- </div>
- <div className={clsx(styles.hoverIcon, 'grip-swap-hover-icon')}>
- <IconGripVertical
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
- color={gripIconColor}
- />
- </div>
- </div>
- );
-
- if (withIconContainer) {
- return (
- <MenuItemIconBoxContainer hasBackground={withIconContainerBackground}>
- {iconContent}
- </MenuItemIconBoxContainer>
- );
- }
-
- return iconContent;
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.module.scss b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.module.scss
deleted file mode 100644
index b3018dd7746..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.module.scss
+++ /dev/null
@@ -1,17 +0,0 @@
-.mainText {
- flex-shrink: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- max-width: 100%;
-}
-
-.menuItemLabelRight {
- display: flex;
- flex-direction: row;
- font-size: var(--t-font-size-md);
- font-weight: var(--t-font-weight-regular);
- overflow: hidden;
- white-space: nowrap;
- margin-left: auto;
-}
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.module.scss.d.ts b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.module.scss.d.ts
deleted file mode 100644
index 7ec8d6bf739..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.module.scss.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-declare const classNames: {
- readonly mainText: 'mainText';
- readonly menuItemLabelRight: 'menuItemLabelRight';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.tsx
deleted file mode 100644
index 1f6453e1ed3..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemLeftContent.tsx
+++ /dev/null
@@ -1,170 +0,0 @@
-import { isNonEmptyString, isString } from '@sniptt/guards';
-import { type ReactNode } from 'react';
-
-import { MenuItemIcon } from '@ui/components/navigation/MenuItem/parts/MenuItemIcon';
-import { MenuItemIconBoxContainer } from '@ui/components/navigation/MenuItem/parts/MenuItemIconBoxContainer';
-import { MenuItemIconWithGripSwap } from '@ui/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap';
-import {
- StyledDraggableItem,
- StyledMenuItemContextualText,
- StyledMenuItemLabel,
- StyledMenuItemLeftContent,
- StyledRightMenuItemContextualText,
-} from '@ui/components/navigation/MenuItem/parts/StyledMenuItemBase';
-import { type MenuItemDraggableGripMode } from '@ui/components/navigation/MenuItem/types/MenuItemDraggableGripMode';
-import { OverflowingTextWithTooltip } from '@ui/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
-import { IconGripVertical, type IconComponent } from '@ui/icon';
-import { type ThemeColor, themeCssVariables, useTheme } from '@ui/theme';
-import { isDefined } from '@ui/utilities/utils/isDefined';
-
-import styles from './MenuItemLeftContent.module.scss';
-
-type MenuItemLeftContentProps = {
- className?: string;
- LeftComponent?: ReactNode;
- LeftIcon: IconComponent | null | undefined;
- iconThemeColor?: ThemeColor | null;
- withIconContainer?: boolean;
- withIconContainerBackground?: boolean;
- gripMode?: MenuItemDraggableGripMode;
- disabled?: boolean;
- text: ReactNode;
- contextualText?: ReactNode;
- contextualTextPosition?: 'left' | 'right';
-};
-
-const getLeadingContent = ({
- LeftComponent,
- LeftIcon,
- iconThemeColor,
-}: Pick<
- MenuItemLeftContentProps,
- 'LeftComponent' | 'LeftIcon' | 'iconThemeColor'
->): ReactNode => {
- if (isDefined(LeftComponent)) {
- return LeftComponent;
- }
-
- if (isDefined(LeftIcon)) {
- return <MenuItemIcon Icon={LeftIcon} iconThemeColor={iconThemeColor} />;
- }
-
- return undefined;
-};
-
-export const MenuItemLeftContent = ({
- className,
- LeftComponent,
- LeftIcon,
- iconThemeColor,
- withIconContainer = false,
- withIconContainerBackground = true,
- text,
- contextualText,
- contextualTextPosition = 'left',
- gripMode = 'never',
- disabled = false,
-}: MenuItemLeftContentProps) => {
- const theme = useTheme();
-
- const gripIconColor = withIconContainer
- ? themeCssVariables.font.color.tertiary
- : disabled
- ? themeCssVariables.font.color.extraLight
- : themeCssVariables.font.color.light;
-
- const leadingContent = getLeadingContent({
- LeftComponent,
- LeftIcon,
- iconThemeColor,
- });
-
- const withLeadingContentContainer =
- withIconContainer && !isDefined(iconThemeColor);
-
- return (
- <StyledMenuItemLeftContent className={className}>
- {gripMode === 'always' &&
- (withIconContainer ? (
- <MenuItemIconBoxContainer hasBackground={withIconContainerBackground}>
- <StyledDraggableItem>
- <IconGripVertical
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
- color={gripIconColor}
- />
- </StyledDraggableItem>
- </MenuItemIconBoxContainer>
- ) : (
- <StyledDraggableItem>
- <IconGripVertical
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
- color={gripIconColor}
- />
- </StyledDraggableItem>
- ))}
- {gripMode === 'always' &&
- (withLeadingContentContainer && isDefined(leadingContent) ? (
- <MenuItemIconBoxContainer hasBackground={withIconContainerBackground}>
- {leadingContent}
- </MenuItemIconBoxContainer>
- ) : (
- leadingContent
- ))}
- {gripMode === 'onHover' && (
- <MenuItemIconWithGripSwap
- leadingContent={leadingContent}
- withIconContainer={withLeadingContentContainer}
- withIconContainerBackground={withIconContainerBackground}
- gripIconColor={gripIconColor}
- />
- )}
- {gripMode === 'never' && (
- <>
- <MenuItemIcon
- Icon={LeftIcon}
- iconThemeColor={iconThemeColor}
- withContainer={withIconContainer}
- withContainerBackground={withIconContainerBackground}
- />
- {LeftComponent}
- </>
- )}
- <StyledMenuItemLabel>
- {isString(text) ? (
- <div className={styles.mainText}>
- <OverflowingTextWithTooltip text={text} />
- </div>
- ) : (
- text
- )}
- {contextualTextPosition === 'left' && (
- <>
- {isString(contextualText)
- ? isNonEmptyString(contextualText) && (
- <StyledMenuItemContextualText>
- <OverflowingTextWithTooltip
- text={`· ${contextualText}`}
- tooltipContent={contextualText}
- />
- </StyledMenuItemContextualText>
- )
- : contextualText}
- </>
- )}
- </StyledMenuItemLabel>
- {contextualTextPosition === 'right' && (
- <div className={styles.menuItemLabelRight}>
- <StyledRightMenuItemContextualText>
- {isString(contextualText) ? (
- <OverflowingTextWithTooltip text={contextualText} />
- ) : (
- contextualText
- )}
- </StyledRightMenuItemContextualText>
- </div>
- )}
- </StyledMenuItemLeftContent>
- );
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.module.scss b/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.module.scss
deleted file mode 100644
index 8183b575eed..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.module.scss
+++ /dev/null
@@ -1,204 +0,0 @@
-// Shared base replicating the deprecated Linaria StyledMenuItemBase /
-// StyledHoverableMenuItemBase static rules.
-@mixin menu-item-base {
- --horizontal-padding: var(--t-spacing-1);
- --vertical-padding: var(--t-spacing-2);
-
- // Height and width below are sized against the content box.
- box-sizing: content-box;
- align-items: center;
- // Concentric with the md dropdown container: parent radius minus its inset.
- border-radius: calc(var(--t-border-radius-md) - var(--t-spacing-1));
- display: flex;
- flex-direction: row;
- font-size: var(--t-font-size-sm);
- gap: var(--t-spacing-2);
- height: calc(32px - 2 * var(--vertical-padding));
- justify-content: space-between;
- padding: var(--vertical-padding) var(--horizontal-padding);
- position: relative;
- user-select: none;
- width: calc(100% - 2 * var(--horizontal-padding));
- background: transparent;
- transition: background 0.1s ease;
- color: var(--t-font-color-secondary);
-}
-
-// Cascade order mirrors the deprecated Linaria ternaries:
-// color: disabled > accent > base; hover background: disabled (with
-// key-selected/focused exception) > danger > hover-background-disabled > base.
-@mixin menu-item-base-states {
- &[data-key-selected],
- &[data-focused] {
- background: var(--t-background-transparent-light);
- }
-
- &[data-accent='danger'] {
- color: var(--t-font-color-danger);
- }
-
- &[data-accent='placeholder'] {
- color: var(--t-font-color-tertiary);
- }
-
- &[data-hover-background-disabled] {
- transition: none;
- }
-
- &[data-disabled] {
- color: var(--t-font-color-tertiary);
- transition: none;
- }
-
- &:hover {
- background: var(--t-background-transparent-light);
- }
-
- &[data-hover-background-disabled]:hover {
- background: transparent;
- }
-
- &[data-accent='danger']:hover {
- background: var(--t-background-transparent-danger);
- }
-
- &[data-disabled]:hover {
- background: transparent;
- }
-
- &[data-disabled][data-key-selected]:hover,
- &[data-disabled][data-focused]:hover {
- background: var(--t-background-transparent-light);
- }
-}
-
-.menuItemBase {
- @include menu-item-base;
-
- cursor: pointer;
-
- @include menu-item-base-states;
-}
-
-.hoverableMenuItemBase {
- @include menu-item-base;
-
- cursor: pointer;
-
- @include menu-item-base-states;
-
- &[data-cursor='drag'] {
- cursor: grab;
- }
-
- &[data-disabled] {
- cursor: default;
- }
-}
-
-// `.hoverable-buttons`, `.grip-swap-default-icon` and `.grip-swap-hover-icon`
-// are global hooks: consumers pass them as string classNames.
-.hoverableMenuItemBase :global(.hoverable-buttons) {
- opacity: 1;
- right: auto;
- transition: opacity duration(instant) ease;
-}
-
-.hoverableMenuItemBase[data-icon-displayed-on-hover-only]
- :global(.hoverable-buttons) {
- opacity: 0;
- right: var(--t-spacing-2);
-}
-
-.hoverableMenuItemBase:hover :global(.hoverable-buttons) {
- opacity: 1;
-}
-
-.hoverableMenuItemBase:hover :global(.grip-swap-default-icon) {
- opacity: 0;
-}
-
-.hoverableMenuItemBase:hover :global(.grip-swap-hover-icon) {
- opacity: 1;
-}
-
-.menuItemLabel {
- display: flex;
- flex-direction: row;
- font-size: var(--t-font-size-md);
- font-weight: var(--t-font-weight-regular);
- overflow: hidden;
- white-space: nowrap;
-}
-
-.menuItemLabelLight {
- color: var(--t-font-color-light);
- display: flex;
- flex-direction: row;
- font-size: var(--t-font-size-md);
- font-weight: var(--t-font-weight-regular);
- overflow: hidden;
- white-space: nowrap;
-}
-
-.noIconFiller {
- width: var(--t-spacing-1);
-}
-
-.menuItemLeftContent {
- align-items: center;
- display: flex;
- flex-direction: row;
- gap: var(--t-spacing-2);
- min-width: 0;
- width: 100%;
-}
-
-.menuItemLeftContent svg {
- flex-shrink: 0;
-}
-
-.menuItemRightContent {
- align-items: center;
- display: flex;
- flex-direction: row;
- gap: var(--t-spacing-2);
-}
-
-.menuItemRightContent svg {
- flex-shrink: 0;
-}
-
-.draggableItem {
- cursor: grab;
- align-items: center;
- display: flex;
-}
-
-.menuItemIconCheckContainer {
- align-items: center;
- display: flex;
- flex-shrink: 0;
- margin-right: var(--t-spacing-1);
-}
-
-.menuItemContextualText {
- color: var(--t-font-color-light);
- font-family: inherit;
- font-size: inherit;
- font-weight: inherit;
- padding-left: var(--t-spacing-1);
- flex-shrink: 1;
- overflow: hidden;
-}
-
-.rightMenuItemContextualText {
- color: var(--t-font-color-light);
- font-family: inherit;
- font-size: inherit;
- font-weight: inherit;
- padding-left: var(--t-spacing-1);
- flex-shrink: 1;
- overflow: hidden;
- text-align: right;
-}
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.module.scss.d.ts b/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.module.scss.d.ts
deleted file mode 100644
index 32d6bcbcfef..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.module.scss.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-declare const classNames: {
- readonly menuItemBase: 'menuItemBase';
- readonly hoverableMenuItemBase: 'hoverableMenuItemBase';
- readonly menuItemLabel: 'menuItemLabel';
- readonly menuItemLabelLight: 'menuItemLabelLight';
- readonly noIconFiller: 'noIconFiller';
- readonly menuItemLeftContent: 'menuItemLeftContent';
- readonly menuItemRightContent: 'menuItemRightContent';
- readonly draggableItem: 'draggableItem';
- readonly menuItemIconCheckContainer: 'menuItemIconCheckContainer';
- readonly menuItemContextualText: 'menuItemContextualText';
- readonly rightMenuItemContextualText: 'rightMenuItemContextualText';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.tsx
deleted file mode 100644
index 336a37df6bb..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/StyledMenuItemBase.tsx
+++ /dev/null
@@ -1,167 +0,0 @@
-import { clsx } from 'clsx';
-import { type ComponentPropsWithoutRef, forwardRef } from 'react';
-
-import { type MenuItemAccent } from '@ui/components/navigation/MenuItem/types/MenuItemAccent';
-import { IconCheck } from '@ui/icon';
-
-import styles from './StyledMenuItemBase.module.scss';
-
-export type MenuItemBaseProps = {
- accent?: MenuItemAccent;
- isKeySelected?: boolean;
- isHoverBackgroundDisabled?: boolean;
- hovered?: boolean;
- disabled?: boolean;
- focused?: boolean;
-};
-
-// The deprecated Linaria styled components forwarded refs and arbitrary
-// native props, so the ports preserve that contract.
-type StyledMenuItemBaseElementProps = MenuItemBaseProps &
- ComponentPropsWithoutRef<'div'>;
-
-export const StyledMenuItemBase = forwardRef<
- HTMLDivElement,
- StyledMenuItemBaseElementProps
->(
- (
- {
- accent,
- isKeySelected,
- isHoverBackgroundDisabled,
- hovered: _hovered,
- disabled,
- focused,
- className,
- children,
- ...rest
- },
- ref,
- ) => (
- <div
- ref={ref}
- className={clsx(styles.menuItemBase, className)}
- data-accent={accent}
- data-key-selected={isKeySelected || undefined}
- data-hover-background-disabled={isHoverBackgroundDisabled || undefined}
- data-disabled={disabled || undefined}
- data-focused={focused || undefined}
- {...rest}
- >
- {children}
- </div>
- ),
-);
-
-StyledMenuItemBase.displayName = 'StyledMenuItemBase';
-
-type StyledStaticDivProps = ComponentPropsWithoutRef<'div'>;
-
-const createStyledDiv = (classNameFromModule: string, displayName: string) => {
- const StyledDiv = forwardRef<HTMLDivElement, StyledStaticDivProps>(
- ({ className, children, ...rest }, ref) => (
- <div ref={ref} className={clsx(classNameFromModule, className)} {...rest}>
- {children}
- </div>
- ),
- );
-
- StyledDiv.displayName = displayName;
-
- return StyledDiv;
-};
-
-export const StyledMenuItemLabel = createStyledDiv(
- styles.menuItemLabel,
- 'StyledMenuItemLabel',
-);
-
-export const StyledMenuItemLabelLight = createStyledDiv(
- styles.menuItemLabelLight,
- 'StyledMenuItemLabelLight',
-);
-
-export const StyledNoIconFiller = createStyledDiv(
- styles.noIconFiller,
- 'StyledNoIconFiller',
-);
-
-export const StyledMenuItemLeftContent = createStyledDiv(
- styles.menuItemLeftContent,
- 'StyledMenuItemLeftContent',
-);
-
-export const StyledMenuItemRightContent = createStyledDiv(
- styles.menuItemRightContent,
- 'StyledMenuItemRightContent',
-);
-
-export const StyledDraggableItem = createStyledDiv(
- styles.draggableItem,
- 'StyledDraggableItem',
-);
-
-type HoverableMenuItemBaseProps = {
- isIconDisplayedOnHoverOnly?: boolean;
- cursor?: 'drag' | 'default';
-} & MenuItemBaseProps;
-
-type StyledHoverableMenuItemBaseElementProps = HoverableMenuItemBaseProps &
- ComponentPropsWithoutRef<'div'>;
-
-export const StyledHoverableMenuItemBase = forwardRef<
- HTMLDivElement,
- StyledHoverableMenuItemBaseElementProps
->(
- (
- {
- accent,
- isKeySelected,
- isHoverBackgroundDisabled,
- hovered: _hovered,
- disabled,
- focused,
- isIconDisplayedOnHoverOnly,
- cursor,
- className,
- children,
- ...rest
- },
- ref,
- ) => (
- <div
- ref={ref}
- className={clsx(styles.hoverableMenuItemBase, className)}
- data-accent={accent}
- data-key-selected={isKeySelected || undefined}
- data-hover-background-disabled={isHoverBackgroundDisabled || undefined}
- data-disabled={disabled || undefined}
- data-focused={focused || undefined}
- data-icon-displayed-on-hover-only={
- isIconDisplayedOnHoverOnly || undefined
- }
- data-cursor={cursor}
- {...rest}
- >
- {children}
- </div>
- ),
-);
-
-StyledHoverableMenuItemBase.displayName = 'StyledHoverableMenuItemBase';
-
-export const StyledMenuItemIconCheck = ({ size }: { size?: number }) => (
- <div className={styles.menuItemIconCheckContainer}>
- <IconCheck size={size} />
- </div>
-);
-
-export const StyledMenuItemContextualText = createStyledDiv(
- styles.menuItemContextualText,
- 'StyledMenuItemContextualText',
-);
-
-export const StyledRightMenuItemContextualText = createStyledDiv(
- styles.rightMenuItemContextualText,
- 'StyledRightMenuItemContextualText',
-);
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemDraggableGripMode.ts b/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemDraggableGripMode.ts
deleted file mode 100644
index 11b5df8a094..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemDraggableGripMode.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type MenuItemDraggableGripMode = 'always' | 'onHover' | 'never';
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemDraggable/MenuItemDraggable.tsx b/packages/twenty-ui/src/components/navigation/MenuItemDraggable/MenuItemDraggable.tsx
deleted file mode 100644
index 8ac315c856e..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemDraggable/MenuItemDraggable.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { MenuItemLeftContent } from '@ui/components/navigation/MenuItem/parts/MenuItemLeftContent';
-import {
- StyledHoverableMenuItemBase,
- StyledMenuItemRightContent,
-} from '@ui/components/navigation/MenuItem/parts/StyledMenuItemBase';
-import { type MenuItemDraggableProps } from './types/MenuItemDraggableProps';
-
-export const MenuItemDraggable = ({
- LeftIcon,
- LeftComponent,
- withIconContainer = false,
- accent = 'default',
- iconButtons,
- onClick,
- text,
- contextualText,
- isDragDisabled = false,
- className,
- isIconDisplayedOnHoverOnly = true,
- gripMode = 'never',
-}: MenuItemDraggableProps) => {
- const cursorType =
- gripMode !== 'never' ? (isDragDisabled ? 'default' : 'drag') : 'default';
-
- return (
- <StyledHoverableMenuItemBase
- onClick={onClick}
- accent={accent}
- className={className}
- isIconDisplayedOnHoverOnly={isIconDisplayedOnHoverOnly}
- cursor={cursorType}
- >
- <MenuItemLeftContent
- LeftIcon={LeftIcon}
- LeftComponent={LeftComponent}
- text={text}
- contextualText={contextualText}
- withIconContainer={withIconContainer}
- disabled={isDragDisabled}
- gripMode={gripMode}
- />
- {iconButtons && (
- <StyledMenuItemRightContent className="hoverable-buttons">
- {iconButtons}
- </StyledMenuItemRightContent>
- )}
- </StyledHoverableMenuItemBase>
- );
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemDraggable/__stories__/MenuItemDraggable.stories.tsx b/packages/twenty-ui/src/components/navigation/MenuItemDraggable/__stories__/MenuItemDraggable.stories.tsx
deleted file mode 100644
index 4d4d5e9d838..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemDraggable/__stories__/MenuItemDraggable.stories.tsx
+++ /dev/null
@@ -1,191 +0,0 @@
-import { LightIconButton } from '@ui/components/input/LightIconButton/LightIconButton';
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { action } from 'storybook/actions';
-import { expect, within } from 'storybook/test';
-
-import { TintedIconTile } from '@ui/components/data-display/TintedIconTile/TintedIconTile';
-import { type MenuItemAccent } from '@ui/components/navigation/MenuItem/types/MenuItemAccent';
-import { MenuItemDraggable } from '@ui/components/navigation/MenuItemDraggable/MenuItemDraggable';
-import { IconBell, IconMinus } from '@ui/icon';
-import {
- A11Y_DEFER_COLOR_CONTRAST,
- CatalogDecorator,
- ComponentDecorator,
- type CatalogDimension,
- type CatalogOptions,
-} from '@ui/testing';
-
-const meta: Meta<typeof MenuItemDraggable> = {
- id: 'ui-navigation-menu-menuitem-menuitemdraggable',
- title: 'UI/Components/Navigation/MenuItemDraggable',
- component: MenuItemDraggable,
-};
-
-export default meta;
-
-type Story = StoryObj<typeof MenuItemDraggable>;
-
-export const Display: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: { text: 'Company name', gripMode: 'always' },
- decorators: [ComponentDecorator],
-};
-
-export const WithActions: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: {
- LeftIcon: IconBell,
- accent: 'default',
- iconButtons: (
- <LightIconButton aria-label={'Remove'} onClick={action('Clicked')}>
- <IconMinus />
- </LightIconButton>
- ),
- onClick: action('Clicked'),
- text: 'Menu item draggable',
- isDragDisabled: false,
- },
- decorators: [ComponentDecorator],
-};
-
-export const Catalog: Story = {
- args: { ...WithActions.args },
- argTypes: {
- accent: { control: false },
- iconButtons: { control: false },
- },
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- pseudo: { hover: ['.hover'] },
- catalog: {
- dimensions: [
- {
- name: 'withIconContainer',
- values: [true, false],
- props: (withIconContainer: boolean) => ({ withIconContainer }),
- labels: (withIconContainer: boolean) =>
- withIconContainer
- ? 'With icon container'
- : 'Without icon container',
- },
- {
- name: 'isDragDisabled',
- values: [true, false],
- props: (isDragDisabled: boolean) => ({
- isDragDisabled: isDragDisabled,
- }),
- labels: (isDragDisabled: boolean) =>
- isDragDisabled ? 'Without drag icon' : 'With drag icon',
- },
- {
- name: 'accents',
- values: ['default', 'danger', 'placeholder'] as 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', 'minus icon buttons'],
- props: (choice: string) => {
- switch (choice) {
- case 'no icon button': {
- return {
- iconButtons: null,
- };
- }
- case 'minus icon buttons': {
- return {
- iconButtons: (
- <LightIconButton
- aria-label={'Remove'}
- onClick={action('Clicked on minus icon button')}
- >
- <IconMinus />
- </LightIconButton>
- ),
- };
- }
- }
- },
- },
- ] as CatalogDimension[],
- options: {
- elementContainer: {
- width: 200,
- },
- } as CatalogOptions,
- },
- },
- decorators: [CatalogDecorator],
-};
-
-export const Grip: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: { ...WithActions.args, gripMode: 'always', isDragDisabled: false },
-};
-
-export const GripOnHover: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: { ...WithActions.args, gripMode: 'onHover', isDragDisabled: false },
-};
-
-export const GripOnHoverWithIconContainer: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: {
- ...WithActions.args,
- gripMode: 'onHover',
- withIconContainer: true,
- isDragDisabled: false,
- },
-};
-
-export const GripOnHoverWithLeftComponent: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: {
- ...WithActions.args,
- LeftIcon: undefined,
- LeftComponent: (
- <TintedIconTile
- icon={<IconBell size={16} />}
- color="blue"
- role="img"
- aria-label="Custom leading content"
- />
- ),
- gripMode: 'onHover',
- withIconContainer: true,
- isDragDisabled: false,
- },
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
- const leadingContent = canvas.getByRole('img', {
- name: 'Custom leading content',
- });
- const defaultSlot = canvasElement.querySelector('.grip-swap-default-icon');
- const grip = canvasElement.querySelector('.grip-swap-hover-icon');
-
- await expect(leadingContent).toBeVisible();
- await expect(defaultSlot).toContainElement(leadingContent);
- await expect(grip).toBeInTheDocument();
- await expect(grip!.querySelector('svg')).toBeInTheDocument();
- await expect(grip).toHaveStyle({ opacity: '0' });
- },
-};
-
-export const HoverDisabled: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: { ...WithActions.args, isHoverDisabled: true },
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemDraggable/__tests__/MenuItemDraggableIconButtons.test.tsx b/packages/twenty-ui/src/components/navigation/MenuItemDraggable/__tests__/MenuItemDraggableIconButtons.test.tsx
deleted file mode 100644
index 775b50348be..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemDraggable/__tests__/MenuItemDraggableIconButtons.test.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import { render, screen } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-import { describe, expect, it, vi } from 'vitest';
-
-import { LightIconButton } from '@ui/components/input/LightIconButton/LightIconButton';
-import { MenuItemDraggable } from '@ui/components/navigation/MenuItemDraggable/MenuItemDraggable';
-import { IconSearch, IconTrash } from '@ui/icon';
-import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';
-
-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(
- <MenuItemDraggable
- text="Record"
- iconButtons={
- <ButtonGroup attached={false} onClick={onSearch}>
- <LightIconButton aria-label="Delete" disabled onClick={onDelete}>
- <IconTrash />
- </LightIconButton>
- <LightIconButton aria-label="Search">
- <IconSearch />
- </LightIconButton>
- </ButtonGroup>
- }
- />,
- );
-
- const disabled = screen.getByRole('button', { name: 'Delete' });
- expect(disabled).toBeDisabled();
- await user.click(disabled);
- expect(onDelete).not.toHaveBeenCalled();
-
- const search = screen.getByRole('button', { name: 'Search' });
- expect(search).toBeEnabled();
- await user.click(search);
- expect(onSearch).toHaveBeenCalledOnce();
- });
-
- it('preserves click propagation control and avoids form submission', async () => {
- const user = userEvent.setup();
- const onParentClick = vi.fn();
- const onSubmit = vi.fn((event) => event.preventDefault());
- const onClick = vi.fn((event) => event.stopPropagation());
- render(
- <form onSubmit={onSubmit}>
- <MenuItemDraggable
- text="Record"
- onClick={onParentClick}
- iconButtons={
- <LightIconButton aria-label="Search" onClick={onClick}>
- <IconSearch />
- </LightIconButton>
- }
- />
- </form>,
- );
-
- await user.click(screen.getByRole('button', { name: 'Search' }));
- expect(onClick).toHaveBeenCalledOnce();
- expect(onParentClick).not.toHaveBeenCalled();
- expect(onSubmit).not.toHaveBeenCalled();
- });
-});
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemDraggable/types/MenuItemDraggableProps.ts b/packages/twenty-ui/src/components/navigation/MenuItemDraggable/types/MenuItemDraggableProps.ts
deleted file mode 100644
index b24cbf1fa67..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemDraggable/types/MenuItemDraggableProps.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { type MenuItemAccent } from '@ui/components/navigation/MenuItem/types/MenuItemAccent';
-import { type MenuItemDraggableGripMode } from '@ui/components/navigation/MenuItem/types/MenuItemDraggableGripMode';
-import { type IconComponent } from '@ui/icon';
-import { type ReactNode } from 'react';
-
-export type MenuItemDraggableProps = {
- LeftIcon?: IconComponent | undefined;
- LeftComponent?: ReactNode;
- withIconContainer?: boolean;
- accent?: MenuItemAccent;
- iconButtons?: ReactNode;
- isTooltipOpen?: boolean;
- onClick?: () => void;
- text: ReactNode;
- contextualText?: ReactNode;
- className?: string;
- isIconDisplayedOnHoverOnly?: boolean;
- gripMode?: MenuItemDraggableGripMode;
- isDragDisabled?: boolean;
- isHoverDisabled?: boolean;
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.module.scss b/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.module.scss
deleted file mode 100644
index 32dc0c98df6..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.module.scss
+++ /dev/null
@@ -1,32 +0,0 @@
-.suggestionMenuItem {
- --horizontal-padding: var(--t-spacing-1);
- --vertical-padding: var(--t-spacing-2);
-
- // Height below is sized against the content box.
- box-sizing: content-box;
- align-items: center;
- // Concentric with the md dropdown container: parent radius minus its inset.
- border-radius: calc(var(--t-border-radius-md) - var(--t-spacing-1));
- cursor: pointer;
- display: flex;
- flex-direction: row;
- font-size: var(--t-font-size-sm);
- gap: var(--t-spacing-2);
- height: calc(32px - 2 * var(--vertical-padding));
- justify-content: space-between;
- padding: var(--vertical-padding) var(--horizontal-padding);
- background: transparent;
- color: var(--t-font-color-secondary);
- transition: background 0.1s ease;
- position: relative;
- user-select: none;
- width: calc(100% - 2 * var(--horizontal-padding));
-}
-
-.suggestionMenuItem[data-selected] {
- background: var(--t-background-transparent-medium);
-}
-
-.suggestionMenuItem:hover {
- background: var(--t-background-transparent-light);
-}
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.module.scss.d.ts b/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.module.scss.d.ts
deleted file mode 100644
index c4bfd7e099b..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.module.scss.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare const classNames: {
- readonly suggestionMenuItem: 'suggestionMenuItem';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.tsx b/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.tsx
deleted file mode 100644
index c68d48a3443..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/MenuItemSuggestion.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { clsx } from 'clsx';
-import { type MouseEvent } from 'react';
-import { type MenuItemSuggestionProps } from './types/MenuItemSuggestionProps';
-
-import { MenuItemLeftContent } from '@ui/components/navigation/MenuItem/parts/MenuItemLeftContent';
-import { StyledMenuItemLeftContent } from '@ui/components/navigation/MenuItem/parts/StyledMenuItemBase';
-import { handleClickableElementKeyDown } from '@ui/primitives/accessibility/utils/handleClickableElementKeyDown';
-import { isDefined } from '@ui/utilities/utils/isDefined';
-
-import styles from './MenuItemSuggestion.module.scss';
-
-export const MenuItemSuggestion = ({
- LeftIcon,
- withIconContainer = false,
- text,
- contextualText = undefined,
- contextualTextPosition = 'left',
- className,
- selected,
- onClick,
-}: MenuItemSuggestionProps) => {
- const handleMenuItemClick = (event: MouseEvent<HTMLLIElement>) => {
- if (!onClick) return;
- event.preventDefault();
- event.stopPropagation();
-
- onClick?.(event);
- };
-
- return (
- <li
- className={clsx(styles.suggestionMenuItem, className)}
- data-selected={selected || undefined}
- role={isDefined(onClick) ? 'button' : undefined}
- tabIndex={isDefined(onClick) ? 0 : undefined}
- onClick={handleMenuItemClick}
- onKeyDown={handleClickableElementKeyDown}
- >
- <StyledMenuItemLeftContent>
- <MenuItemLeftContent
- LeftIcon={LeftIcon ?? undefined}
- text={text}
- contextualText={contextualText}
- contextualTextPosition={contextualTextPosition}
- withIconContainer={withIconContainer}
- />
- </StyledMenuItemLeftContent>
- </li>
- );
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/__stories__/MenuItemSuggestion.stories.tsx b/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/__stories__/MenuItemSuggestion.stories.tsx
deleted file mode 100644
index cbe6d665ee4..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/__stories__/MenuItemSuggestion.stories.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { Text } from '@ui/primitives/typography/Text/Text';
-import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
-import { MenuItemSuggestion } from '../MenuItemSuggestion';
-
-const meta: Meta<typeof MenuItemSuggestion> = {
- title: 'UI/Components/Navigation/MenuItemSuggestion',
- component: MenuItemSuggestion,
- decorators: [ComponentDecorator],
- parameters: {
- container: { width: 280 },
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- },
-};
-
-export default meta;
-type Story = StoryObj<typeof MenuItemSuggestion>;
-
-export const Display: Story = {
- args: { text: 'Acme', contextualText: 'Company', selected: false },
- argTypes: { onClick: { control: false } },
- render: (args) => (
- <Text
- render={<ul />}
- style={{ margin: 0, padding: 0, listStyle: 'none', width: '100%' }}
- >
- <MenuItemSuggestion {...args} />
- </Text>
- ),
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/types/MenuItemSuggestionProps.ts b/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/types/MenuItemSuggestionProps.ts
deleted file mode 100644
index 8b1a2e9d664..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuItemSuggestion/types/MenuItemSuggestionProps.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { type IconComponent } from '@ui/icon';
-import { type MouseEvent } from 'react';
-
-export type MenuItemSuggestionProps = {
- LeftIcon?: IconComponent | null;
- withIconContainer?: boolean;
- text: string;
- contextualText?: string;
- contextualTextPosition?: 'left' | 'right';
- selected?: boolean;
- className?: string;
- onClick?: (event: MouseEvent<HTMLLIElement>) => void;
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.module.scss b/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.module.scss
deleted file mode 100644
index 10932c35add..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.module.scss
+++ /dev/null
@@ -1,74 +0,0 @@
-.menuPicker {
- box-sizing: border-box;
- background: transparent;
- font: inherit;
- outline: inherit;
- align-items: center;
- border: 1px solid var(--t-border-color-medium);
- // Concentric with the md dropdown container: parent radius minus its inset.
- border-radius: calc(var(--t-border-radius-md) - var(--t-spacing-1));
- color: var(--t-font-color-tertiary);
- cursor: pointer;
- display: flex;
- flex-direction: column;
- gap: var(--t-spacing-1);
- justify-content: center;
- min-height: var(--t-spacing-8);
- padding: var(--t-spacing-1_5) var(--t-spacing-1);
- transition: all duration(instant) ease;
- user-select: none;
- width: 100%;
-
- &:hover {
- background: var(--t-background-transparent-light);
- }
-
- &[data-selected] {
- border-color: var(--t-color-blue);
- color: var(--t-color-blue);
-
- &:hover {
- background: var(--t-background-transparent-primary);
- }
- }
-
- &:disabled {
- background: var(--t-background-secondary);
- border-color: var(--t-border-color-medium);
- color: var(--t-font-color-extra-light);
- cursor: default;
-
- &:hover {
- background: var(--t-background-secondary);
- }
- }
-}
-
-.iconContainer {
- align-items: center;
- display: flex;
- flex-shrink: 0;
- height: calc(var(--t-icon-size-md) * 1px);
- justify-content: center;
- width: calc(var(--t-icon-size-md) * 1px);
-}
-
-.label {
- color: var(--t-font-color-tertiary);
- font-family: var(--t-font-family);
- font-size: var(--t-font-size-xs);
- font-weight: var(--t-font-weight-semi-bold);
- max-width: 100%;
- overflow: hidden;
- text-align: center;
- text-overflow: ellipsis;
- white-space: nowrap;
-
- &[data-selected] {
- color: var(--t-color-blue);
- }
-
- &[data-disabled] {
- color: var(--t-font-color-extra-light);
- }
-}
diff --git a/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.module.scss.d.ts b/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.module.scss.d.ts
deleted file mode 100644
index 9cf40d807d1..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.module.scss.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare const classNames: {
- readonly menuPicker: 'menuPicker';
- readonly iconContainer: 'iconContainer';
- readonly label: 'label';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.tsx b/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.tsx
deleted file mode 100644
index e6149916e12..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuPicker/MenuPicker.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { isNonEmptyString } from '@sniptt/guards';
-import { isDefined } from '@ui/utilities/utils/isDefined';
-import { clsx } from 'clsx';
-
-import { Tooltip } from '@ui/primitives/surfaces/Tooltip/Tooltip';
-import { useTheme } from '@ui/theme';
-
-import styles from './MenuPicker.module.scss';
-
-import { type MenuPickerProps } from './types/MenuPickerProps';
-
-export const MenuPicker = ({
- id,
- icon: Icon,
- label,
- selected = false,
- disabled = false,
- showLabel = true,
- onClick,
- className,
- testId,
- tooltipContent,
- tooltipDelay = 0,
- tooltipOffset = 5,
-}: MenuPickerProps) => {
- const theme = useTheme();
-
- return (
- <Tooltip
- content={tooltipContent}
- disabled={!isNonEmptyString(tooltipContent)}
- sideOffset={tooltipOffset}
- side="bottom"
- positionMethod="fixed"
- delay={tooltipDelay}
- >
- <button
- id={id}
- disabled={disabled}
- onClick={onClick}
- className={clsx(styles.menuPicker, className)}
- data-testid={testId}
- data-selected={selected ? '' : undefined}
- aria-pressed={selected}
- aria-disabled={disabled}
- aria-label={label}
- >
- <div className={styles.iconContainer}>
- <Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
- </div>
-
- {isDefined(label) && showLabel && (
- <div
- className={styles.label}
- data-selected={selected ? '' : undefined}
- data-disabled={disabled ? '' : undefined}
- >
- {label}
- </div>
- )}
- </button>
- </Tooltip>
- );
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.module.scss b/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.module.scss
deleted file mode 100644
index 205863ae961..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.module.scss
+++ /dev/null
@@ -1,4 +0,0 @@
-.title {
- line-height: inherit;
- margin-bottom: var(--t-spacing-2);
-}
diff --git a/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.module.scss.d.ts b/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.module.scss.d.ts
deleted file mode 100644
index 08ba7f87baf..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.module.scss.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare const classNames: {
- readonly title: 'title';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.tsx b/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.tsx
deleted file mode 100644
index 326cf50b7f1..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuPicker/__stories__/MenuPicker.stories.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { MenuPicker } from '@ui/components/navigation/MenuPicker/MenuPicker';
-import { IconChartPie, IconLayoutKanban } from '@ui/icon';
-import { Heading } from '@ui/primitives/typography/Heading/Heading';
-import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
-import { type ReactNode, useState } from 'react';
-
-import styles from './MenuPicker.stories.module.scss';
-
-const meta: Meta<typeof MenuPicker> = {
- id: 'ui-navigation-menu-menupicker',
- title: 'UI/Components/Navigation/MenuPicker',
- component: MenuPicker,
- decorators: [ComponentDecorator],
- args: {
- icon: IconChartPie,
- label: 'Chart',
- selected: false,
- disabled: false,
- showLabel: true,
- },
- argTypes: {
- icon: {
- control: false,
- },
- onClick: {
- action: 'clicked',
- },
- },
-};
-
-export default meta;
-type Story = StoryObj<typeof MenuPicker>;
-
-export const Display: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- args: { icon: IconLayoutKanban, label: 'Board view' },
- argTypes: { selected: { control: false }, onClick: { control: false } },
- render: function Render(args) {
- const [selected, setSelected] = useState(false);
-
- return (
- <MenuPicker
- {...args}
- selected={selected}
- onClick={() => setSelected(!selected)}
- />
- );
- },
-};
-
-export const Selected: Story = {
- args: {
- selected: true,
- },
-};
-
-export const Disabled: Story = {
- args: {
- disabled: true,
- },
-};
-
-export const WithoutLabel: Story = {
- args: {
- showLabel: false,
- },
-};
-
-const SectionTitle = ({ children }: { children?: ReactNode }) => {
- return (
- <Heading className={styles.title} level={3} size="lg">
- {children}
- </Heading>
- );
-};
-
-export const AllStates: Story = {
- parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
- render: () => (
- <div
- style={{
- display: 'grid',
- gridTemplateColumns: 'repeat(4, 1fr)',
- width: '100%',
- gap: '16px',
- }}
- >
- <div>
- <SectionTitle>Default</SectionTitle>
- <MenuPicker id="default" icon={IconChartPie} label="Default" />
- </div>
- <div>
- <SectionTitle>Selected</SectionTitle>
- <MenuPicker
- id="selected"
- icon={IconChartPie}
- label="Selected"
- selected
- />
- </div>
- <div>
- <SectionTitle>Disabled</SectionTitle>
- <MenuPicker
- id="disabled"
- icon={IconChartPie}
- label="Disabled"
- disabled
- />
- </div>
- <div>
- <SectionTitle>No Label</SectionTitle>
- <MenuPicker
- id="no-label"
- icon={IconChartPie}
- label="No Label"
- showLabel={false}
- />
- </div>
- <div>
- <SectionTitle>With Tooltip</SectionTitle>
- <MenuPicker
- id="tooltip"
- icon={IconChartPie}
- label="Tooltip"
- tooltipContent="Tooltip"
- tooltipDelay={500}
- />
- </div>
- </div>
- ),
-};
diff --git a/packages/twenty-ui/src/components/navigation/MenuPicker/types/MenuPickerProps.ts b/packages/twenty-ui/src/components/navigation/MenuPicker/types/MenuPickerProps.ts
deleted file mode 100644
index ee29ffff431..00000000000
--- a/packages/twenty-ui/src/components/navigation/MenuPicker/types/MenuPickerProps.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { type IconComponent } from '@ui/icon';
-
-export type MenuPickerProps = {
- id: string;
- className?: string;
- disabled?: boolean;
- icon: IconComponent;
- label?: string;
- onClick?: () => void;
- selected?: boolean;
- showLabel?: boolean;
- testId?: string;
- tooltipContent?: string;
- tooltipDelay?: number;
- tooltipOffset?: number;
-};
diff --git a/packages/twenty-ui/src/components/navigation/index.ts b/packages/twenty-ui/src/components/navigation/index.ts
index 8549090e9f1..8e7eae5dcde 100644
--- a/packages/twenty-ui/src/components/navigation/index.ts
+++ b/packages/twenty-ui/src/components/navigation/index.ts
@@ -34,12 +34,5 @@ export type { ListItemButtonProps } from './ListItemButton/types/ListItemButtonP
export { DEFAULT_COLOR_LABELS } from './MenuItem/constants/DefaultColorLabels';
export type { ColorLabels } from './MenuItem/types/ColorLabels';
export type { MenuItemAccent } from './MenuItem/types/MenuItemAccent';
-export type { MenuItemDraggableGripMode } from './MenuItem/types/MenuItemDraggableGripMode';
-export { MenuItemDraggable } from './MenuItemDraggable/MenuItemDraggable';
-export type { MenuItemDraggableProps } from './MenuItemDraggable/types/MenuItemDraggableProps';
-export { MenuItemSuggestion } from './MenuItemSuggestion/MenuItemSuggestion';
-export type { MenuItemSuggestionProps } from './MenuItemSuggestion/types/MenuItemSuggestionProps';
-export { MenuPicker } from './MenuPicker/MenuPicker';
-export type { MenuPickerProps } from './MenuPicker/types/MenuPickerProps';
export { TabButton } from './TabButton/TabButton';
export type { TabButtonProps } from './TabButton/types/TabButtonProps';