Skip to content

The open alternative to Salesforce, designed for AI.

Move ExpandableList into Twenty UI as OverflowingList (#27040)

Raphaël Bosi477717caf37f
diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.json
index c4a26407170..3a414c81004 100644
--- a/packages/twenty-docs/docs.json
+++ b/packages/twenty-docs/docs.json
@@ -627,6 +627,7 @@
"ui/components/input/icon-button",
"ui/components/input/light-icon-button",
"ui/components/section",
+ "ui/components/overflowing-list",
"ui/components/settings-row",
"ui/components/dropdown",
"ui/components/tab-button",
diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.json
index 7418dcab95a..f4a1f0580d9 100644
--- a/packages/twenty-docs/navigation/base-structure.json
+++ b/packages/twenty-docs/navigation/base-structure.json
@@ -645,6 +645,7 @@
"ui/components/input/icon-button",
"ui/components/input/light-icon-button",
"ui/components/section",
+ "ui/components/overflowing-list",
"ui/components/settings-row",
"ui/components/dropdown",
"ui/components/tab-button",
diff --git a/packages/twenty-docs/snippets/ui/generated/components/overflowing-list.mdx b/packages/twenty-docs/snippets/ui/generated/components/overflowing-list.mdx
new file mode 100644
index 00000000000..ad49ff12fc7
--- /dev/null
+++ b/packages/twenty-docs/snippets/ui/generated/components/overflowing-list.mdx
@@ -0,0 +1,28 @@
+{/*
+ * _____ _
+ *|_ _|_ _____ _ __ | |_ _ _
+ * | | \ \ /\ / / _ \ '_ \| __| | | | 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="children" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt;[]" required>
+ Complete ordered list of elements, each with a stable key.
+</ParamField>
+
+<ParamField body="maxInlineCount" type="number">
+ Maximum number of items mounted in the compact row. The popup still contains every item.
+</ParamField>
+
+<ParamField body="overflowLabel" type="string" default="Show all items">
+ Accessible label for the popup. The overflow button is named by its visible count followed by this label. Defaults to Show all items.
+</ParamField>
+
+<ParamField body="showOverflowCount" type="boolean">
+ Shows the overflow count on hover and keyboard focus by default. Use true to show it whenever items overflow, or false to omit the trigger. An open popup stays open until it is dismissed.
+</ParamField>
diff --git a/packages/twenty-docs/ui/components/overflowing-list.mdx b/packages/twenty-docs/ui/components/overflowing-list.mdx
new file mode 100644
index 00000000000..be006cac11b
--- /dev/null
+++ b/packages/twenty-docs/ui/components/overflowing-list.mdx
@@ -0,0 +1,54 @@
+---
+title: OverflowingList
+description: Fit a row of items into the available space and reveal the complete list in a popup.
+---
+
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
+import OverflowingListReference from '/snippets/ui/generated/components/overflowing-list.mdx';
+
+`OverflowingList` measures its available width, keeps the fitting items in a compact row, and offers a `+N` button for the remaining items. It updates when the container or item content changes.
+
+Supply the complete ordered list as keyed elements. Your application owns each item's content, actions, and data.
+
+```tsx
+import { OverflowingList } from 'twenty-ui/components';
+import { Tag } from 'twenty-ui/primitives/data-display';
+
+const TEAMS = ['Design', 'Engineering', 'Support', 'Operations'];
+
+export const TeamList = () => (
+ <OverflowingList
+ style={{ width: 220 }}
+ showOverflowCount
+ overflowLabel="Show all teams"
+ >
+ {TEAMS.map((team) => (
+ <Tag key={team} color="blue">{team}</Tag>
+ ))}
+ </OverflowingList>
+);
+```
+
+<StoryEmbed
+ storyId="ui-components-overflowinglist--documentation"
+ title="Overflowing list example"
+ height={280}
+/>
+
+## Count visibility
+
+The overflow button appears on pointer hover or keyboard focus by default. Set `showOverflowCount` to `true` to keep it visible whenever items overflow. Set it to `false` only when the surrounding interface provides another way to access the complete list. A popup that is already open stays open until it is dismissed, even if `showOverflowCount` changes to `false`.
+
+## Limit inline mounting
+
+Use `maxInlineCount` when rendering a large collection or expensive item content. This caps only the compact row. The popup receives the complete list, including items beyond the cap. It does not fetch missing items or virtualize the popup.
+
+## Popup behavior
+
+Enter, Space, and pointer activation open a non-modal popup with the complete list. Escape closes it and restores focus to the overflow button. Assistive technologies announce the button by its visible count followed by `overflowLabel`, for example "+3 Show all teams". An outside interaction also closes it. The popup uses the surrounding theme and supports ordinary content, links, and buttons without turning them into menu items.
+
+Overflow-trigger and popup interactions do not activate a clickable field host. Each list owns its measurement and popup state independently. Native `div` attributes, styles, class names, and refs apply to the compact row.
+
+## Props
+
+<OverflowingListReference />
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 1384b33b35d..9f40f80d4c9 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -1,5 +1,8 @@
import { breadcrumbTest } from '@/__stories__/twenty-ui-gallery/utils/breadcrumbTest';
import { imageInputTest } from '@/__stories__/twenty-ui-gallery/utils/imageInputTest';
+import { overflowingListEventIsolationFailureTest } from '@/__stories__/twenty-ui-gallery/utils/overflowingListEventIsolationFailureTest';
+import { overflowingListGeometryTest } from '@/__stories__/twenty-ui-gallery/utils/overflowingListGeometryTest';
+import { overflowingListSandboxFailureTest } from '@/__stories__/twenty-ui-gallery/utils/overflowingListSandboxFailureTest';
import { jsonTreeTest } from '@/__stories__/twenty-ui-gallery/utils/jsonTreeTest';
import { inlineBannerSandboxTest } from '@/__stories__/twenty-ui-gallery/utils/inlineBannerSandboxTest';
import { themeTokenTest } from '@/__stories__/twenty-ui-gallery/utils/themeTokenTest';
@@ -591,6 +594,44 @@ export const InlineBannerPreactFocusFailure: Story = createGalleryStory({
play: inlineBannerSandboxTest,
});
+export const OverflowingListReactPopupFailure: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-overflowing-list',
+ runtime: 'react',
+ play: overflowingListSandboxFailureTest,
+});
+
+export const OverflowingListPreactPopupFailure: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-overflowing-list',
+ runtime: 'preact',
+ play: overflowingListSandboxFailureTest,
+});
+
+export const OverflowingListGeometryReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-overflowing-list',
+ runtime: 'react',
+ play: overflowingListGeometryTest,
+});
+
+export const OverflowingListGeometryPreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-overflowing-list',
+ runtime: 'preact',
+ play: overflowingListGeometryTest,
+});
+
+export const OverflowingListEventIsolationReactFailure: Story =
+ createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-overflowing-list',
+ runtime: 'react',
+ play: overflowingListEventIsolationFailureTest,
+ });
+
+export const OverflowingListEventIsolationPreactFailure: Story =
+ createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-overflowing-list',
+ runtime: 'preact',
+ play: overflowingListEventIsolationFailureTest,
+ });
+
export const ImageInputReact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-image-input',
runtime: 'react',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
index 77f29b2c633..5db9f653bb0 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
@@ -21,6 +21,7 @@ requiring them to occur.
| `twenty-ui-image-input` | ImageInput |
| `twenty-ui-list-item` | ListItem |
| `twenty-ui-tabs` | Tabs |
+| `twenty-ui-overflowing-list` | OverflowingList |
| `twenty-ui-popover` | Popover |
| `twenty-ui-menu` | Menu |
| `twenty-ui-select` | Select |
@@ -57,6 +58,7 @@ No stories are skipped or marked as expected-to-fail by the runner.
| ImageInput | Native file picker activation and usable file contents are unavailable in the sandbox. The fixture checks forwarded file metadata, preview recovery, action callbacks, and supplied error changes. See the [ImageInput documentation](../../../../twenty-docs/ui/components/image-input.mdx). |
| Tabs | Activation fails on the missing `nativeEvent` for `composedPath` in both runtimes. |
| Popover, Dialog, AlertDialog | Opening fails while reading pointer contact data from the missing `nativeEvent`. |
+| OverflowingList | Both runtimes measure, resize, and unmount the inline list, and keep rendering afterwards. A scoped light provider keeps popup portals inside the connected remote root and matches the gallery theme. Popup lifecycle checks verify selection, dismissal, focus restoration, and independent lists while requiring the missing native pointer width error; missing native `defaultPrevented` data and event constructor errors are optional. Focus restoration can also call a stale host listener, which is checked with the existing exact host-error assertion. Separate event isolation failure stories verify that opening the trigger activates the surrounding host, then check that popup selection adds no host activation. Full popup compatibility remains blocked on the event bridge work in [#26356](https://github.com/twentyhq/twenty/pull/26356). |
| Menu | Opening fails on the missing `nativeEvent.pointerType` and pointer contact data. |
| Select | Opening fails on missing native event data and focus support. Preact can report only the last of these failures when the host coalesces sandbox errors. |
| Switch, Checkbox, Radio (standard and card), SegmentedControl | Activation attempts to construct an unavailable `PointerEvent`. `RadioCardReact` never gets that far: React drops the click handler Base UI adds through `React.cloneElement`, so only the group's focus handling fails on the missing `nativeEvent` for `composedPath`. |
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS.ts
index d43db3345b4..0821fd968e0 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS.ts
@@ -5,6 +5,8 @@ export const SANDBOX_ERROR_PATTERNS = {
"Uncaught TypeError: Cannot read properties of undefined (reading 'width')",
NATIVE_EVENT_DEFAULT_PREVENTED:
"Uncaught TypeError: Cannot read properties of undefined (reading 'defaultPrevented')",
+ MISSING_EVENT_CONSTRUCTOR:
+ "Uncaught TypeError: Right-hand side of 'instanceof' is not an object",
POINTER_TYPE:
"Uncaught TypeError: Cannot read properties of undefined (reading 'pointerType')",
ELEMENT_CONTAINS:
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-overflowing-list.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-overflowing-list.front-component.tsx
new file mode 100644
index 00000000000..de499f0d8b5
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-overflowing-list.front-component.tsx
@@ -0,0 +1,82 @@
+import { useState } from 'react';
+import { defineFrontComponent } from 'twenty-sdk/define';
+import { OverflowingList } from 'twenty-ui/components';
+import { Button } from 'twenty-ui/primitives/input';
+import { ThemeProvider } from 'twenty-ui/theme';
+import 'twenty-ui/style.css';
+
+import { TwentyUiGalleryCard } from '../shared/front-components/twenty-ui-gallery-card';
+
+const INITIAL_TARGETS = ['Alpha', 'Bravo', 'Charlie', 'Delta'];
+const REVIEWERS = ['Morgan', 'Taylor'];
+
+const OverflowingListExample = () => {
+ const [targets, setTargets] = useState(INITIAL_TARGETS);
+ const [selectedTarget, setSelectedTarget] = useState('None');
+ const [hostActivations, setHostActivations] = useState(0);
+ const [listWidth, setListWidth] = useState(130);
+ const [isMeasuredListMounted, setIsMeasuredListMounted] = useState(true);
+
+ return (
+ <TwentyUiGalleryCard title="Overflowing list">
+ <ThemeProvider colorScheme="light" applyToRoot={false}>
+ <div
+ onClick={() => setHostActivations((count) => count + 1)}
+ style={{ width: 300 }}
+ >
+ <OverflowingList
+ showOverflowCount
+ maxInlineCount={2}
+ overflowLabel="Show all targets"
+ >
+ {targets.map((target) => (
+ <Button key={target} onClick={() => setSelectedTarget(target)}>
+ {target}
+ </Button>
+ ))}
+ </OverflowingList>
+ </div>
+ <OverflowingList
+ showOverflowCount
+ maxInlineCount={1}
+ overflowLabel="Show all reviewers"
+ style={{ width: 300 }}
+ >
+ {REVIEWERS.map((reviewer) => (
+ <Button key={reviewer}>{reviewer}</Button>
+ ))}
+ </OverflowingList>
+ </ThemeProvider>
+ <Button onClick={() => setTargets([...INITIAL_TARGETS, 'Echo'])}>
+ Add target
+ </Button>
+ <Button>Outside list</Button>
+ {isMeasuredListMounted && (
+ <OverflowingList
+ showOverflowCount
+ overflowLabel="Show all measured items"
+ style={{ width: listWidth }}
+ >
+ {INITIAL_TARGETS.map((target) => (
+ <Button key={target} style={{ width: 90 }}>
+ Measured {target}
+ </Button>
+ ))}
+ </OverflowingList>
+ )}
+ <Button onClick={() => setListWidth(500)}>Widen measured list</Button>
+ <Button onClick={() => setIsMeasuredListMounted(false)}>
+ Remove measured list
+ </Button>
+ <output aria-label="Selected target">{selectedTarget}</output>
+ <output aria-label="Host activations">{hostActivations}</output>
+ </TwentyUiGalleryCard>
+ );
+};
+
+export default defineFrontComponent({
+ universalIdentifier: 'c48a753e-24ce-4e43-8122-2c5d4568ae01',
+ name: 'twenty-ui-overflowing-list',
+ description: 'Overflow measurement and complete popup lists in the sandbox',
+ component: OverflowingListExample,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/createListItemSandboxFailureTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/createListItemSandboxFailureTest.ts
index 9675ae5fe40..51668a15682 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/createListItemSandboxFailureTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/createListItemSandboxFailureTest.ts
@@ -4,12 +4,12 @@ import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/mat
import { SANDBOX_ERROR_PATTERNS } from '@/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS';
import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
import { expectSandboxErrors } from '@/__stories__/twenty-ui-gallery/utils/expectSandboxErrors';
-import { withKnownListItemHostErrors } from '@/__stories__/twenty-ui-gallery/utils/withKnownListItemHostErrors';
+import { withKnownHostEventErrors } from '@/__stories__/twenty-ui-gallery/utils/withKnownHostEventErrors';
export const createListItemSandboxFailureTest =
(runtime: 'react' | 'preact'): TwentyUiGalleryPlayFunction =>
async ({ canvasElement }) =>
- withKnownListItemHostErrors(async () => {
+ withKnownHostEventErrors(async () => {
const user = userEvent.setup();
const canvas = within(canvasElement);
await expectFrontComponentMounted(canvas);
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListEventIsolationFailureTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListEventIsolationFailureTest.ts
new file mode 100644
index 00000000000..299ce3a5248
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListEventIsolationFailureTest.ts
@@ -0,0 +1,49 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { SANDBOX_ERROR_PATTERNS } from '@/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS';
+import { expectSandboxErrors } from '@/__stories__/twenty-ui-gallery/utils/expectSandboxErrors';
+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const overflowingListEventIsolationFailureTest: TwentyUiGalleryPlayFunction =
+ async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ await expectFrontComponentMounted(canvas);
+
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all targets$/,
+ });
+ trigger.focus();
+ await userEvent.keyboard('{Enter}');
+ const popup = await page.findByRole('dialog', { name: 'Show all targets' });
+ const lastTarget = within(popup).getByRole('button', { name: 'Delta' });
+ await waitFor(() => expect(lastTarget).toBeVisible());
+ await waitFor(() =>
+ expect(
+ Number(canvas.getByLabelText('Host activations').textContent),
+ ).toBeGreaterThan(0),
+ );
+ const hostActivationsBeforeSelection = Number(
+ canvas.getByLabelText('Host activations').textContent,
+ );
+
+ await userEvent.click(lastTarget);
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Selected target')).toHaveTextContent(
+ 'Delta',
+ ),
+ );
+ await waitFor(() =>
+ expect(
+ Number(canvas.getByLabelText('Host activations').textContent),
+ ).toBe(hostActivationsBeforeSelection),
+ );
+ await expectSandboxErrors({
+ requiredErrors: [SANDBOX_ERROR_PATTERNS.NATIVE_EVENT_DEFAULT_PREVENTED],
+ allowedAdditionalErrors: [
+ SANDBOX_ERROR_PATTERNS.VIEWPORT_WIDTH,
+ SANDBOX_ERROR_PATTERNS.MISSING_EVENT_CONSTRUCTOR,
+ ],
+ });
+ };
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListGeometryTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListGeometryTest.ts
new file mode 100644
index 00000000000..9c88f7f32b4
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListGeometryTest.ts
@@ -0,0 +1,49 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const overflowingListGeometryTest: TwentyUiGalleryPlayFunction = async ({
+ canvasElement,
+}) => {
+ const canvas = within(canvasElement);
+ await expectFrontComponentMounted(canvas);
+
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all measured items$/,
+ });
+ await waitFor(() => expect(trigger).toHaveTextContent('+3'));
+ await expect(
+ canvas.getByRole('button', { name: 'Measured Alpha' }),
+ ).toBeVisible();
+ await expect(
+ canvas.queryByRole('button', { name: 'Measured Delta' }),
+ ).toBeNull();
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Widen measured list' }),
+ );
+ await waitFor(() =>
+ expect(
+ canvas.queryByRole('button', { name: /Show all measured items$/ }),
+ ).toBeNull(),
+ );
+ await expect(
+ canvas.getByRole('button', { name: 'Measured Delta' }),
+ ).toBeVisible();
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Remove measured list' }),
+ );
+ await waitFor(() =>
+ expect(canvas.queryByRole('button', { name: 'Measured Alpha' })).toBeNull(),
+ );
+ await userEvent.click(canvas.getByRole('button', { name: 'Add target' }));
+ await waitFor(() =>
+ expect(
+ canvas.getByRole('button', { name: /Show all targets$/ }),
+ ).toHaveTextContent('+3'),
+ );
+ await expect(errorHandler).not.toHaveBeenCalled();
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListSandboxFailureTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListSandboxFailureTest.ts
new file mode 100644
index 00000000000..a89fca829b2
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListSandboxFailureTest.ts
@@ -0,0 +1,107 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { THEME_LIGHT } from 'twenty-ui/theme';
+
+import { SANDBOX_ERROR_PATTERNS } from '@/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS';
+import { expectSandboxErrors } from '@/__stories__/twenty-ui-gallery/utils/expectSandboxErrors';
+import { withKnownHostEventErrors } from '@/__stories__/twenty-ui-gallery/utils/withKnownHostEventErrors';
+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+
+export const overflowingListSandboxFailureTest: TwentyUiGalleryPlayFunction =
+ async ({ canvasElement }) =>
+ withKnownHostEventErrors(async () => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ await expectFrontComponentMounted(canvas);
+
+ const targetsTrigger = await canvas.findByRole('button', {
+ name: /Show all targets$/,
+ });
+ const reviewersTrigger = canvas.getByRole('button', {
+ name: /Show all reviewers$/,
+ });
+
+ await waitFor(() => expect(targetsTrigger).toHaveTextContent('+2'));
+ await expect(reviewersTrigger).toHaveTextContent('+1');
+ await expect(canvas.queryByRole('button', { name: 'Delta' })).toBeNull();
+
+ targetsTrigger.focus();
+ await userEvent.keyboard('{Enter}');
+
+ const targetsPopup = await page.findByRole('dialog', {
+ name: 'Show all targets',
+ });
+ const portalScope = targetsTrigger.closest<HTMLDivElement>('.light');
+ await expect(canvasElement).toContainElement(portalScope);
+ await expect(portalScope).toContainElement(targetsPopup);
+ await waitFor(() =>
+ expect(getComputedStyle(targetsPopup).color).toBe(
+ THEME_LIGHT.font.color.primary,
+ ),
+ );
+ const targets = within(targetsPopup);
+ for (const name of ['Alpha', 'Bravo', 'Charlie', 'Delta']) {
+ await waitFor(() =>
+ expect(targets.getByRole('button', { name })).toBeVisible(),
+ );
+ }
+ await expect(reviewersTrigger).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.click(targets.getByRole('button', { name: 'Delta' }));
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Selected target')).toHaveTextContent(
+ 'Delta',
+ ),
+ );
+
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(targetsPopup).not.toBeInTheDocument());
+ await waitFor(() => expect(targetsTrigger).toHaveFocus());
+
+ await userEvent.keyboard(' ');
+ await page.findByRole('dialog', { name: 'Show all targets' });
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Outside list' }),
+ );
+ await waitFor(() =>
+ expect(
+ page.queryByRole('dialog', { name: 'Show all targets' }),
+ ).toBeNull(),
+ );
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Add target' }));
+ await waitFor(() => expect(targetsTrigger).toHaveTextContent('+3'));
+ await userEvent.click(targetsTrigger);
+ const updatedTargetsPopup = await page.findByRole('dialog', {
+ name: 'Show all targets',
+ });
+ await waitFor(() =>
+ expect(
+ within(updatedTargetsPopup).getByRole('button', { name: 'Echo' }),
+ ).toBeVisible(),
+ );
+ await expect(
+ within(updatedTargetsPopup).getAllByRole('button'),
+ ).toHaveLength(5);
+ await userEvent.keyboard('{Escape}');
+
+ await userEvent.click(reviewersTrigger);
+ const reviewersPopup = await page.findByRole('dialog', {
+ name: 'Show all reviewers',
+ });
+ await waitFor(() =>
+ expect(
+ within(reviewersPopup).getByRole('button', { name: 'Taylor' }),
+ ).toBeVisible(),
+ );
+ await expect(targetsTrigger).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(reviewersPopup).not.toBeInTheDocument());
+ await waitFor(() => expect(reviewersTrigger).toHaveFocus());
+ await expectSandboxErrors({
+ requiredErrors: [SANDBOX_ERROR_PATTERNS.VIEWPORT_WIDTH],
+ allowedAdditionalErrors: [
+ SANDBOX_ERROR_PATTERNS.NATIVE_EVENT_DEFAULT_PREVENTED,
+ SANDBOX_ERROR_PATTERNS.MISSING_EVENT_CONSTRUCTOR,
+ ],
+ });
+ });
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withKnownListItemHostErrors.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withKnownHostEventErrors.ts
similarity index 94%
rename from packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withKnownListItemHostErrors.ts
rename to packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withKnownHostEventErrors.ts
index b3e88511b67..69c6630f8e6 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withKnownListItemHostErrors.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withKnownHostEventErrors.ts
@@ -2,7 +2,7 @@ import { expect } from 'storybook/test';
import { SANDBOX_ERROR_PATTERNS } from '@/__stories__/twenty-ui-gallery/constants/SANDBOX_ERROR_PATTERNS';
-export const withKnownListItemHostErrors = async (
+export const withKnownHostEventErrors = async (
runTest: () => Promise<void>,
) => {
const hostErrors: ErrorEvent[] = [];
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerTargetsInput.tsx b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerTargetsInput.tsx
index af543d53457..bd106444fc2 100644
--- a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerTargetsInput.tsx
+++ b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerTargetsInput.tsx
@@ -7,11 +7,16 @@ import { type RecordPickerPickableMorphItem } from '@/object-record/record-picke
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';
import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { useToggleDropdown } from '@/ui/layout/dropdown/hooks/useToggleDropdown';
+import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
+import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
+import { OverflowingList, IconButton } from 'twenty-ui/components';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
-import { useId } from 'react';
-import { isDefined } from 'twenty-shared/utils';
+import { type MouseEvent, useId, useState } from 'react';
+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
+import { IconPlus } from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
import { themeCssVariables } from 'twenty-ui/theme';
const StyledClickableContainer = styled.div`
@@ -21,7 +26,6 @@ const StyledClickableContainer = styled.div`
gap: ${themeCssVariables.spacing[1]};
min-height: 24px;
min-width: 0;
- overflow: hidden;
width: 100%;
`;
@@ -42,7 +46,14 @@ export const CalendarEventComposerTargetsInput = ({
const componentId = useId();
const dropdownId = `calendar-event-composer-targets-${componentId}`;
+ const [containerElement, setContainerElement] =
+ useState<HTMLDivElement | null>(null);
+ const isDropdownOpen = useAtomComponentStateValue(
+ isDropdownOpenComponentState,
+ dropdownId,
+ );
const { closeDropdown } = useCloseDropdown();
+ const { toggleDropdown } = useToggleDropdown();
const { openCalendarEventTargetsPicker } =
useOpenCalendarEventTargetsPicker();
@@ -53,6 +64,12 @@ export const CalendarEventComposerTargetsInput = ({
return null;
}
+ const handleToggleDropdown = (event: MouseEvent) => {
+ event.stopPropagation();
+ event.preventDefault();
+ toggleDropdown({ dropdownComponentInstanceIdFromProps: dropdownId });
+ };
+
const handleOpenDropdown = () => {
openCalendarEventTargetsPicker({
pickerInstanceId: dropdownId,
@@ -81,32 +98,67 @@ export const CalendarEventComposerTargetsInput = ({
);
})
.filter(isDefined);
+ const hasChips = isNonEmptyArray(chips);
+ const pickerLabel = t`Add a related record`;
+ const pickerOptionsId = `${dropdownId}-options`;
return (
- <Dropdown
- dropdownId={dropdownId}
- dropdownPlacement="bottom-start"
- clickableComponentWidth="100%"
- onOpen={handleOpenDropdown}
- clickableComponent={
- <StyledClickableContainer>
- {chips.length > 0 ? (
- <ExpandableList isChipCountDisplayed>{chips}</ExpandableList>
- ) : (
- <StyledPlaceholder>{t`Add a related record`}</StyledPlaceholder>
- )}
- </StyledClickableContainer>
- }
- dropdownComponents={
- <MultipleRecordPicker
- componentInstanceId={dropdownId}
- focusId={dropdownId}
- onChange={onTargetChange}
- onSubmit={() => closeDropdown(dropdownId)}
- onClickOutside={() => closeDropdown(dropdownId)}
- dropdownWidth={GenericDropdownContentWidth.ExtraLarge}
- />
- }
- />
+ <>
+ <StyledClickableContainer
+ ref={setContainerElement}
+ onClick={handleToggleDropdown}
+ data-click-outside-id={dropdownId}
+ >
+ {hasChips ? (
+ <>
+ <OverflowingList
+ overflowLabel={t`Show all items`}
+ showOverflowCount
+ >
+ {chips}
+ </OverflowingList>
+ <IconButton
+ type="button"
+ size="sm"
+ variant="ghost"
+ aria-label={pickerLabel}
+ aria-controls={pickerOptionsId}
+ aria-expanded={isDropdownOpen}
+ aria-haspopup="listbox"
+ >
+ <IconPlus />
+ </IconButton>
+ </>
+ ) : (
+ <Button
+ type="button"
+ size="sm"
+ variant="ghost"
+ aria-controls={pickerOptionsId}
+ aria-expanded={isDropdownOpen}
+ aria-haspopup="listbox"
+ >
+ <StyledPlaceholder>{pickerLabel}</StyledPlaceholder>
+ </Button>
+ )}
+ </StyledClickableContainer>
+ <Dropdown
+ dropdownId={dropdownId}
+ dropdownPlacement="bottom-start"
+ positionReference={containerElement}
+ excludedClickOutsideIds={[dropdownId]}
+ onOpen={handleOpenDropdown}
+ dropdownComponents={
+ <MultipleRecordPicker
+ componentInstanceId={dropdownId}
+ focusId={dropdownId}
+ onChange={onTargetChange}
+ onSubmit={() => closeDropdown(dropdownId)}
+ onClickOutside={() => closeDropdown(dropdownId)}
+ dropdownWidth={GenericDropdownContentWidth.ExtraLarge}
+ />
+ }
+ />
+ </>
);
};
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/__stories__/CalendarEventComposerTargetsInput.stories.tsx b/packages/twenty-front/src/modules/activities/calendar/components/__stories__/CalendarEventComposerTargetsInput.stories.tsx
new file mode 100644
index 00000000000..d348613778e
--- /dev/null
+++ b/packages/twenty-front/src/modules/activities/calendar/components/__stories__/CalendarEventComposerTargetsInput.stories.tsx
@@ -0,0 +1,117 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+import { Button } from 'twenty-ui/primitives/input';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+import { CalendarEventComposerTargetsInput } from '@/activities/calendar/components/CalendarEventComposerTargetsInput';
+import { CalendarEventTargetsStoryMetadataEffect } from '@/activities/calendar/components/__stories__/CalendarEventTargetsStoryMetadataEffect';
+import { getCalendarEventTargetsStoryMetadata } from '@/activities/calendar/components/__stories__/getCalendarEventTargetsStoryMetadata';
+import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
+import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
+import { ToastDecorator } from '~/testing/decorators/ToastDecorator';
+import { graphqlMocks } from '~/testing/graphqlMocks';
+import { mockedPersonRecords } from '~/testing/mock-data/generated/data/people/mock-people-data';
+import { getTestEnrichedObjectMetadataItemsMock } from '~/testing/utils/getTestEnrichedObjectMetadataItemsMock';
+
+const PERSON_OBJECT_METADATA_ID = getTestEnrichedObjectMetadataItemsMock().find(
+ ({ nameSingular }) => nameSingular === 'person',
+)?.id;
+
+const meta: Meta<typeof CalendarEventComposerTargetsInput> = {
+ title: 'Modules/Activities/Calendar/CalendarEventComposerTargetsInput',
+ component: CalendarEventComposerTargetsInput,
+ decorators: [
+ MemoryRouterDecorator,
+ ComponentDecorator,
+ ObjectMetadataItemsDecorator,
+ ToastDecorator,
+ (Story, { loaded }) => (
+ <>
+ <CalendarEventTargetsStoryMetadataEffect metadata={loaded.metadata} />
+ <Story />
+ </>
+ ),
+ ],
+ loaders: [
+ async () => ({ metadata: await getCalendarEventTargetsStoryMetadata() }),
+ ],
+ args: {
+ targets: mockedPersonRecords.slice(0, 4).map((record) => ({
+ objectMetadataId: PERSON_OBJECT_METADATA_ID ?? '',
+ recordId: record.id,
+ record,
+ })),
+ onTargetChange: fn(),
+ },
+ parameters: {
+ container: { width: 220 },
+ msw: graphqlMocks,
+ },
+ render: (args) => (
+ <>
+ <CalendarEventComposerTargetsInput {...args} />
+ <Button variant="ghost">Outside calendar field</Button>
+ </>
+ ),
+};
+
+export default meta;
+type Story = StoryObj<typeof CalendarEventComposerTargetsInput>;
+
+export const OverflowAndPicker: Story = {
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const overflowButton = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+ const pickerButton = canvas.getByRole('button', {
+ name: 'Add a related record',
+ });
+
+ expect(overflowButton.closest('[role="button"]')).toBeNull();
+ expect(pickerButton.closest('[role="button"]')).toBeNull();
+
+ await userEvent.click(overflowButton);
+
+ expect(await body.findByRole('dialog')).toBeVisible();
+ expect(body.queryAllByRole('listbox')).toHaveLength(0);
+ expect(pickerButton).toHaveAttribute('aria-expanded', 'false');
+
+ await userEvent.keyboard('{Escape}');
+ await userEvent.click(canvas.getByText('Jeffery Griffin'));
+
+ expect(await body.findByRole('textbox')).toBeVisible();
+ expect(pickerButton).toHaveAttribute('aria-expanded', 'true');
+ await userEvent.click(
+ await body.findByRole('option', { name: /Jeffery Griffin/ }),
+ );
+ expect(args.onTargetChange).toHaveBeenCalled();
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Outside calendar field' }),
+ );
+ await waitFor(() => expect(body.queryAllByRole('listbox')).toHaveLength(0));
+ },
+};
+
+export const EmptyKeyboardActivation: Story = {
+ args: { targets: [] },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const pickerButton = await canvas.findByRole('button', {
+ name: 'Add a related record',
+ });
+
+ await userEvent.tab();
+ expect(pickerButton).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+
+ expect(await body.findByRole('textbox')).toBeVisible();
+ expect(pickerButton).toHaveAttribute('aria-expanded', 'true');
+
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(body.queryAllByRole('listbox')).toHaveLength(0));
+ },
+};
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/__stories__/CalendarEventTargetsStoryMetadataEffect.tsx b/packages/twenty-front/src/modules/activities/calendar/components/__stories__/CalendarEventTargetsStoryMetadataEffect.tsx
new file mode 100644
index 00000000000..13bd4ed82b0
--- /dev/null
+++ b/packages/twenty-front/src/modules/activities/calendar/components/__stories__/CalendarEventTargetsStoryMetadataEffect.tsx
@@ -0,0 +1,19 @@
+import { useLoadMockedMetadata } from '~/testing/hooks/useLoadMockedMetadata';
+import { type PreloadedMockedMetadata } from '~/testing/utils/preloadMockedMetadata';
+import { useEffect } from 'react';
+
+type CalendarEventTargetsStoryMetadataEffectProps = {
+ metadata: PreloadedMockedMetadata;
+};
+
+export const CalendarEventTargetsStoryMetadataEffect = ({
+ metadata,
+}: CalendarEventTargetsStoryMetadataEffectProps) => {
+ const { applyMockedMetadata } = useLoadMockedMetadata();
+
+ useEffect(() => {
+ applyMockedMetadata(metadata);
+ }, [applyMockedMetadata, metadata]);
+
+ return null;
+};
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/__stories__/getCalendarEventTargetsStoryMetadata.ts b/packages/twenty-front/src/modules/activities/calendar/components/__stories__/getCalendarEventTargetsStoryMetadata.ts
new file mode 100644
index 00000000000..812aa83c5d5
--- /dev/null
+++ b/packages/twenty-front/src/modules/activities/calendar/components/__stories__/getCalendarEventTargetsStoryMetadata.ts
@@ -0,0 +1,134 @@
+import { isDefined } from 'twenty-shared/utils';
+import { preloadMockedMetadata } from '~/testing/utils/preloadMockedMetadata';
+
+const CALENDAR_EVENT_TARGET_IDS = {
+ object: '20202020-0000-4000-8000-00000000c100',
+ identifier: '20202020-0000-4000-8000-00000000c101',
+ source: '20202020-0000-4000-8000-00000000c102',
+ target: '20202020-0000-4000-8000-00000000c103',
+ collection: '20202020-0000-4000-8000-00000000c104',
+};
+
+export const getCalendarEventTargetsStoryMetadata = async () => {
+ const metadata = await preloadMockedMetadata();
+ const calendarEvent = metadata.flatObjects.find(
+ ({ nameSingular }) => nameSingular === 'calendarEvent',
+ );
+ const noteTarget = metadata.flatObjects.find(
+ ({ nameSingular }) => nameSingular === 'noteTarget',
+ );
+ const note = metadata.flatObjects.find(
+ ({ nameSingular }) => nameSingular === 'note',
+ );
+
+ if (!isDefined(calendarEvent) || !isDefined(noteTarget) || !isDefined(note)) {
+ throw new Error(
+ 'Calendar target story metadata is missing its source objects',
+ );
+ }
+
+ const identifier = metadata.flatFields.find(
+ ({ id }) => id === noteTarget.labelIdentifierFieldMetadataId,
+ );
+ const source = metadata.flatFields.find(
+ ({ objectMetadataId, name }) =>
+ objectMetadataId === noteTarget.id && name === 'note',
+ );
+ const target = metadata.flatFields.find(
+ ({ objectMetadataId, name }) =>
+ objectMetadataId === noteTarget.id && name === 'target',
+ );
+ const collection = metadata.flatFields.find(
+ ({ objectMetadataId, name }) =>
+ objectMetadataId === note.id && name === 'noteTargets',
+ );
+
+ if (
+ !isDefined(identifier) ||
+ !isDefined(source?.relation) ||
+ !isDefined(target?.morphRelations) ||
+ !isDefined(collection?.relation)
+ ) {
+ throw new Error(
+ 'Calendar target story metadata is missing its junction fields',
+ );
+ }
+
+ const junctionObject = {
+ ...noteTarget,
+ id: CALENDAR_EVENT_TARGET_IDS.object,
+ nameSingular: 'calendarEventTarget',
+ namePlural: 'calendarEventTargets',
+ labelSingular: 'Calendar event target',
+ labelPlural: 'Calendar event targets',
+ labelIdentifierFieldMetadataId: CALENDAR_EVENT_TARGET_IDS.identifier,
+ };
+ const collectionField = {
+ id: CALENDAR_EVENT_TARGET_IDS.collection,
+ name: 'calendarEventTargets',
+ };
+ const sourceField = {
+ id: CALENDAR_EVENT_TARGET_IDS.source,
+ name: 'calendarEvent',
+ };
+ const targetField = {
+ id: CALENDAR_EVENT_TARGET_IDS.target,
+ name: 'target',
+ };
+
+ return {
+ ...metadata,
+ flatObjects: [...metadata.flatObjects, junctionObject],
+ flatFields: [
+ ...metadata.flatFields,
+ {
+ ...identifier,
+ id: CALENDAR_EVENT_TARGET_IDS.identifier,
+ objectMetadataId: junctionObject.id,
+ },
+ {
+ ...source,
+ ...sourceField,
+ objectMetadataId: junctionObject.id,
+ settings: { ...source.settings, joinColumnName: 'calendarEventId' },
+ relation: {
+ ...source.relation,
+ sourceObjectMetadata: junctionObject,
+ sourceFieldMetadata: sourceField,
+ targetObjectMetadata: calendarEvent,
+ targetFieldMetadata: collectionField,
+ },
+ },
+ {
+ ...target,
+ ...targetField,
+ objectMetadataId: junctionObject.id,
+ morphRelations: target.morphRelations
+ .filter(({ targetObjectMetadata }) =>
+ ['person', 'company'].includes(targetObjectMetadata.nameSingular),
+ )
+ .map((relation) => ({
+ ...relation,
+ sourceObjectMetadata: junctionObject,
+ sourceFieldMetadata: targetField,
+ })),
+ },
+ {
+ ...collection,
+ ...collectionField,
+ objectMetadataId: calendarEvent.id,
+ settings: {
+ ...collection.settings,
+ junctionTargetFieldId: targetField.id,
+ },
+ relation: {
+ ...collection.relation,
+ sourceObjectMetadata: calendarEvent,
+ sourceFieldMetadata: collectionField,
+ targetObjectMetadata: junctionObject,
+ targetFieldMetadata: sourceField,
+ },
+ },
+ ],
+ };
+};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatThreadRecordTargets.tsx b/packages/twenty-front/src/modules/ai/components/AiChatThreadRecordTargets.tsx
index efd3a8fc7bd..fcfef9d7493 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatThreadRecordTargets.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatThreadRecordTargets.tsx
@@ -3,7 +3,7 @@ import { useLingui } from '@lingui/react/macro';
import { useCallback, useMemo } from 'react';
import { CoreObjectNameSingular } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
-import { LightIconButton } from 'twenty-ui/components';
+import { OverflowingList, LightIconButton } from 'twenty-ui/components';
import { IconPencil, IconPlus } from 'twenty-ui/icon';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -27,7 +27,6 @@ import { type ObjectRecord } from '@/object-record/types/ObjectRecord';
import { useFieldWidgetJunctionRelationRecords } from '@/page-layout/widgets/field/hooks/useFieldWidgetJunctionRelationRecords';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
import { useListenToEventsForQuery } from '@/sse-db-event/hooks/useListenToEventsForQuery';
import { useAtomFamilySelectorValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilySelectorValue';
import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';
@@ -210,7 +209,7 @@ export const AiChatThreadRecordTargets = ({
<StyledContainer>
{hasTargetRecords && (
<StyledRecordChips>
- <ExpandableList isChipCountDisplayed>
+ <OverflowingList overflowLabel={t`Show all items`} showOverflowCount>
{targetRecords.map(({ record, objectNameSingular }) => (
<RecordChip
key={`${objectNameSingular}-${record.id}`}
@@ -218,7 +217,7 @@ export const AiChatThreadRecordTargets = ({
record={record}
/>
))}
- </ExpandableList>
+ </OverflowingList>
</StyledRecordChips>
)}
{canEditRecordTargets && (
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormMultiRecordFieldChips.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormMultiRecordFieldChips.tsx
index 6d2acebba6f..29cff34a533 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormMultiRecordFieldChips.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormMultiRecordFieldChips.tsx
@@ -3,7 +3,7 @@ import { FormFieldPlaceholder } from '@/object-record/record-field/ui/form-types
import { VariableChipStandalone } from '@/object-record/record-field/ui/form-types/components/VariableChipStandalone';
import { type FormMultiRecordPickerDraftValue } from '@/object-record/record-field/ui/form-types/utils/getFormMultiRecordPickerDraftValue';
import { type ObjectRecord } from '@/object-record/types/ObjectRecord';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import { isStandaloneVariableString } from 'twenty-shared/workflow';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
@@ -81,7 +81,12 @@ export const FormMultiRecordFieldChips = ({
return (
<StyledChipsContainer>
- <ExpandableList isChipCountDisplayed={true}>{chips}</ExpandableList>
+ <OverflowingList
+ overflowLabel={t`Show all items`}
+ showOverflowCount={true}
+ >
+ {chips}
+ </OverflowingList>
</StyledChipsContainer>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MorphRelationOneToManyFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MorphRelationOneToManyFieldDisplay.tsx
index 46b2c8ce792..712bb23a296 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MorphRelationOneToManyFieldDisplay.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MorphRelationOneToManyFieldDisplay.tsx
@@ -1,15 +1,18 @@
+import { useLingui } from '@lingui/react/macro';
import { RecordChip } from '@/object-record/components/RecordChip';
import { FieldContext } from '@/object-record/record-field/ui/contexts/FieldContext';
import { useFieldFocus } from '@/object-record/record-field/ui/hooks/useFieldFocus';
import { MAX_RELATION_CHIPS_DISPLAYED_INLINE } from '@/object-record/record-field/ui/meta-types/display/constants/MaxRelationChipsDisplayedInline';
import { useMorphRelationFromManyFieldDisplay } from '@/object-record/record-field/ui/meta-types/hooks/useMorphRelationFromManyFieldDisplay';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import { useContext } from 'react';
import { type ObjectRecord } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
export const MorphRelationOneToManyFieldDisplay = () => {
+ const { t } = useLingui();
+
const { morphValuesWithObjectNameSingular } =
useMorphRelationFromManyFieldDisplay();
const { isFocused } = useFieldFocus();
@@ -40,8 +43,9 @@ export const MorphRelationOneToManyFieldDisplay = () => {
);
return (
- <ExpandableList
- isChipCountDisplayed={isFocused}
+ <OverflowingList
+ overflowLabel={t`Show all items`}
+ showOverflowCount={isFocused}
maxInlineCount={MAX_RELATION_CHIPS_DISPLAYED_INLINE}
>
{flattenMorphValuesWithObjectNameSingular
@@ -57,6 +61,6 @@ export const MorphRelationOneToManyFieldDisplay = () => {
/>
);
})}
- </ExpandableList>
+ </OverflowingList>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MultiSelectFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MultiSelectFieldDisplay.tsx
index 1c811fefb1e..a188e3e2f2e 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MultiSelectFieldDisplay.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MultiSelectFieldDisplay.tsx
@@ -1,10 +1,13 @@
+import { useLingui } from '@lingui/react/macro';
import { useFieldFocus } from '@/object-record/record-field/ui/hooks/useFieldFocus';
import { useMultiSelectFieldDisplay } from '@/object-record/record-field/ui/meta-types/hooks/useMultiSelectFieldDisplay';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import { Tag } from 'twenty-ui/primitives/data-display';
import { isDefined } from 'twenty-shared/utils';
export const MultiSelectFieldDisplay = () => {
+ const { t } = useLingui();
+
const { fieldValue, fieldDefinition } = useMultiSelectFieldDisplay();
const { isFocused } = useFieldFocus();
@@ -18,12 +21,15 @@ export const MultiSelectFieldDisplay = () => {
if (!isDefined(selectedOptions)) return null;
return (
- <ExpandableList isChipCountDisplayed={isFocused}>
+ <OverflowingList
+ overflowLabel={t`Show all items`}
+ showOverflowCount={isFocused}
+ >
{selectedOptions.map((selectedOption, index) => (
<Tag key={index} color={selectedOption.color}>
{selectedOption.label}
</Tag>
))}
- </ExpandableList>
+ </OverflowingList>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/RelationFromManyFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/RelationFromManyFieldDisplay.tsx
index efaf4b8ba94..e4e5c4106f4 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/RelationFromManyFieldDisplay.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/RelationFromManyFieldDisplay.tsx
@@ -1,3 +1,4 @@
+import { useLingui } from '@lingui/react/macro';
import { useContext } from 'react';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
@@ -10,11 +11,13 @@ import { extractTargetRecordsFromJunction } from '@/object-record/record-field/u
import { isUsableJunctionConfig } from '@/object-record/record-field/ui/utils/junction/isUsableJunctionConfig';
import { resolveJunctionConfig } from '@/object-record/record-field/ui/utils/junction/resolveJunctionConfig';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import { isArray } from '@sniptt/guards';
import { isDefined } from 'twenty-shared/utils';
export const RelationFromManyFieldDisplay = () => {
+ const { t } = useLingui();
+
const { fieldValue, fieldDefinition, generateRecordChipData } =
useRelationFromManyFieldDisplay();
const { isFocused } = useFieldFocus();
@@ -86,8 +89,9 @@ export const RelationFromManyFieldDisplay = () => {
}
return (
- <ExpandableList
- isChipCountDisplayed={isFocused}
+ <OverflowingList
+ overflowLabel={t`Show all items`}
+ showOverflowCount={isFocused}
maxInlineCount={MAX_RELATION_CHIPS_DISPLAYED_INLINE}
>
{targetRecordsWithMetadata.map(({ record, objectMetadata }) => (
@@ -99,13 +103,14 @@ export const RelationFromManyFieldDisplay = () => {
triggerEvent={triggerEvent}
/>
))}
- </ExpandableList>
+ </OverflowingList>
);
}
return (
- <ExpandableList
- isChipCountDisplayed={isFocused}
+ <OverflowingList
+ overflowLabel={t`Show all items`}
+ showOverflowCount={isFocused}
maxInlineCount={MAX_RELATION_CHIPS_DISPLAYED_INLINE}
>
{fieldValue.filter(isDefined).map((record) => {
@@ -120,6 +125,6 @@ export const RelationFromManyFieldDisplay = () => {
/>
);
})}
- </ExpandableList>
+ </OverflowingList>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/LinksFieldDisplay.perf.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/LinksFieldDisplay.perf.stories.tsx
index d7f70ac260a..e0b67229d80 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/LinksFieldDisplay.perf.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/LinksFieldDisplay.perf.stories.tsx
@@ -45,7 +45,7 @@ type Story = StoryObj<typeof LinksFieldDisplay>;
export const Default: Story = {};
-export const ExpandableList: Story = {
+export const OverflowingList: Story = {
decorators: [
(Story) => {
return (
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/MultiSelectFieldDisplay.perf.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/MultiSelectFieldDisplay.perf.stories.tsx
index c6ec70c1ae2..baa4210a03c 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/MultiSelectFieldDisplay.perf.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/__stories__/perf/MultiSelectFieldDisplay.perf.stories.tsx
@@ -43,7 +43,7 @@ type Story = StoryObj<typeof MultiSelectFieldDisplay>;
export const Default: Story = {};
-export const ExpandableList: Story = {
+export const OverflowingList: Story = {
decorators: [
(Story) => {
return (
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/ArrayDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/ArrayDisplay.tsx
index 5887e5f7c3a..597853919ee 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/ArrayDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/ArrayDisplay.tsx
@@ -1,5 +1,5 @@
import { type FieldArrayValue } from '@/object-record/record-field/ui/types/FieldMetadata';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import { t } from '@lingui/core/macro';
import { Chip } from 'twenty-ui/primitives/data-display';
@@ -9,12 +9,12 @@ type ArrayDisplayProps = {
export const ArrayDisplay = ({ value }: ArrayDisplayProps) => {
return (
- <ExpandableList>
+ <OverflowingList overflowLabel={t`Show all items`}>
{value?.map((item, index) => (
<Chip key={`${item}-${index}`} variant="soft" emptyLabel={t`Untitled`}>
{item}
</Chip>
))}
- </ExpandableList>
+ </OverflowingList>
);
};
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx
index 034b24c78a2..daf5385ae8b 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx
@@ -1,7 +1,8 @@
+import { useLingui } from '@lingui/react/macro';
import React, { useMemo } from 'react';
import { type FieldEmailsValue } from '@/object-record/record-field/ui/types/FieldMetadata';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import { styled } from '@linaria/react';
import { isDefined } from 'twenty-shared/utils';
import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink/RoundedLink';
@@ -30,6 +31,8 @@ export const EmailsDisplay = ({
isFocused,
onEmailClick,
}: EmailsDisplayProps) => {
+ const { t } = useLingui();
+
const emails = useMemo(
() =>
[
@@ -40,7 +43,7 @@ export const EmailsDisplay = ({
);
return isFocused ? (
- <ExpandableList isChipCountDisplayed>
+ <OverflowingList overflowLabel={t`Show all items`} showOverflowCount>
{emails.map((email, index) => (
<RoundedLink
key={index}
@@ -49,7 +52,7 @@ export const EmailsDisplay = ({
onClick={(event) => onEmailClick?.(email, event)}
/>
))}
- </ExpandableList>
+ </OverflowingList>
) : (
<StyledContainer>
{emails.map((email, index) => (
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/FilesDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/FilesDisplay.tsx
index 57824f949c2..b468c422db4 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/FilesDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/FilesDisplay.tsx
@@ -1,10 +1,11 @@
+import { useLingui } from '@lingui/react/macro';
import { downloadFile } from '@/activities/files/utils/downloadFile';
import { isAttachmentPreviewEnabledState } from '@/client-config/states/isAttachmentPreviewEnabledState';
import { type FieldFilesValue } from '@/object-record/record-field/ui/types/FieldMetadata';
import { FileChip } from '@/ui/field/display/components/FileChip';
import { UploadFileChip } from '@/ui/field/display/components/UploadFileChip';
import { filePreviewState } from '@/ui/field/display/states/filePreviewState';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { isDefined } from 'twenty-shared/utils';
@@ -22,6 +23,8 @@ export const FilesDisplay = ({
isUploadWindowOpen = false,
isFileUploading = false,
}: FilesDisplayProps) => {
+ const { t } = useLingui();
+
const setFilePreview = useSetAtomState(filePreviewState);
const isAttachmentPreviewEnabled = useAtomStateValue(
isAttachmentPreviewEnabledState,
@@ -48,7 +51,7 @@ export const FilesDisplay = ({
}
return (
- <ExpandableList>
+ <OverflowingList overflowLabel={t`Show all items`}>
{value.map((file) => (
<FileChip
key={file.fileId}
@@ -57,6 +60,6 @@ export const FilesDisplay = ({
forceDisableClick={forceDisableClick}
/>
))}
- </ExpandableList>
+ </OverflowingList>
);
};
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx
index 2b73e31302a..fac8b263dfa 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx
@@ -1,9 +1,10 @@
+import { useLingui } from '@lingui/react/macro';
import React, { useMemo } from 'react';
import { getFieldLinkDefinedLinks } from '@/object-record/record-field/ui/meta-types/input/utils/getFieldLinkDefinedLinks';
import { type FieldLinksValue } from '@/object-record/record-field/ui/types/FieldMetadata';
import { SocialLink } from '@/ui/field/display/components/SocialLink/SocialLink';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import {
getAbsoluteUrlOrThrow,
getUrlHostnameOrThrow,
@@ -19,6 +20,8 @@ type LinksDisplayProps = {
};
export const LinksDisplay = ({ value, onLinkClick }: LinksDisplayProps) => {
+ const { t } = useLingui();
+
const links = useMemo(() => {
if (!isDefined(value)) {
return [];
@@ -44,7 +47,7 @@ export const LinksDisplay = ({ value, onLinkClick }: LinksDisplayProps) => {
}, [value]);
return (
- <ExpandableList>
+ <OverflowingList overflowLabel={t`Show all items`}>
{links.map(({ url, label, displayLabel, type }, index) =>
isSocialLinkType(type) ? (
<SocialLink
@@ -63,6 +66,6 @@ export const LinksDisplay = ({ value, onLinkClick }: LinksDisplayProps) => {
/>
),
)}
- </ExpandableList>
+ </OverflowingList>
);
};
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
index b6fd15cc768..c2d43bf60b3 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx
@@ -1,6 +1,7 @@
+import { useLingui } from '@lingui/react/macro';
import { createPhonesFromFieldValue } from '@/object-record/record-field/ui/meta-types/input/utils/phonesUtils';
import { type FieldPhonesValue } from '@/object-record/record-field/ui/types/FieldMetadata';
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
+import { OverflowingList } from 'twenty-ui/components';
import { styled } from '@linaria/react';
import { parsePhoneNumber } from 'libphonenumber-js';
import React, { useMemo } from 'react';
@@ -34,6 +35,8 @@ export const PhonesDisplay = ({
isFocused,
onPhoneNumberClick,
}: PhonesDisplayProps) => {
+ const { t } = useLingui();
+
const phones = useMemo(() => {
if (!isDefined(value)) {
return [];
@@ -50,7 +53,7 @@ export const PhonesDisplay = ({
};
return isFocused ? (
- <ExpandableList isChipCountDisplayed>
+ <OverflowingList overflowLabel={t`Show all items`} showOverflowCount>
{phones.map(({ number, callingCode }, index) => {
const { parsedPhone, invalidPhone } =
parsePhoneNumberOrReturnInvalidValue(callingCode + number);
@@ -68,7 +71,7 @@ export const PhonesDisplay = ({
/>
);
})}
- </ExpandableList>
+ </OverflowingList>
) : (
<StyledContainer>
{phones.map(({ number, callingCode }, index) => {
diff --git a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableList.tsx b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableList.tsx
deleted file mode 100644
index f9ffec3a768..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableList.tsx
+++ /dev/null
@@ -1,197 +0,0 @@
-import { styled } from '@linaria/react';
-import {
- type ReactElement,
- useCallback,
- useEffect,
- useRef,
- useState,
-} from 'react';
-
-import { AnimatedContainer } from '@/ui/layout/animation/components/internal/AnimatedContainer/AnimatedContainer';
-import { ExpandableListResizeEffect } from '@/ui/layout/expandable-list/components/ExpandableListResizeEffect';
-import { ExpandedListDropdown } from '@/ui/layout/expandable-list/components/ExpandedListDropdown';
-import { isFirstOverflowingChildElement } from '@/ui/layout/expandable-list/utils/isFirstOverflowingChildElement';
-import { isDefined } from 'twenty-shared/utils';
-import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-const StyledContainer = styled.div`
- align-items: center;
- display: flex;
- gap: ${themeCssVariables.spacing[1]};
- justify-content: space-between;
- min-width: 100%;
- width: 100%;
-`;
-
-const StyledChildrenContainer = styled.div`
- display: flex;
- gap: ${themeCssVariables.spacing[1]};
- overflow: hidden;
- max-width: 100%;
- flex: 0 1 fit-content;
- position: relative; // Needed so children elements compute their offsetLeft relatively to this element.
-`;
-
-const StyledChildContainer = styled.div`
- display: flex;
- flex-shrink: 0;
- overflow: hidden;
-
- &:last-child {
- flex-shrink: 1;
- }
-`;
-
-const StyledUnShrinkableContainer = styled.div`
- color: ${themeCssVariables.font.color.primary};
- flex-shrink: 0;
-
- width: 24px;
-`;
-
-export type ExpandableListProps = {
- isChipCountDisplayed?: boolean;
- // Caps children mounted inline; the dropdown still renders all.
- maxInlineCount?: number;
-};
-
-export type ChildrenProperty = {
- shrink: number;
- isVisible: boolean;
-};
-
-export const ExpandableList = ({
- children,
- isChipCountDisplayed: isChipCountDisplayedFromProps,
- maxInlineCount,
-}: {
- children: ReactElement[];
-} & ExpandableListProps) => {
- const cappedChildren = isDefined(maxInlineCount)
- ? children.slice(0, maxInlineCount)
- : children;
- // isChipCountDisplayedInternal => uncontrolled display of the chip count.
- // isChipCountDisplayedFromProps => controlled display of the chip count.
- // If isChipCountDisplayedFromProps is provided, isChipCountDisplayedInternal is not taken into account.
- const [isChipCountDisplayedInternal, setIsChipCountDisplayedInternal] =
- useState(false);
- const isChipCountDisplayed = isDefined(isChipCountDisplayedFromProps)
- ? isChipCountDisplayedFromProps
- : isChipCountDisplayedInternal;
-
- const [isListExpanded, setIsListExpanded] = useState(false);
-
- // Used with floating-ui if anchorElement is not provided.
- // floating-ui mentions that `useState` must be used instead of `useRef`
- // @see https://floating-ui.com/docs/useFloating#elements
- const [childrenContainerElement, setChildrenContainerElement] =
- useState<HTMLDivElement | null>(null);
-
- const [previousChildrenContainerWidth, setPreviousChildrenContainerWidth] =
- useState(childrenContainerElement?.clientWidth ?? 0);
-
- const containerRef = useRef<HTMLDivElement>(null);
-
- const [firstHiddenChildIndex, setFirstHiddenChildIndex] = useState(
- cappedChildren.length,
- );
-
- const hiddenChildrenCount = children.length - firstHiddenChildIndex;
- const canDisplayChipCount = isChipCountDisplayed && hiddenChildrenCount > 0;
-
- const visibleChildren = isChipCountDisplayed
- ? cappedChildren.slice(0, firstHiddenChildIndex)
- : cappedChildren;
-
- const handleChipCountClick = useCallback((event: React.MouseEvent) => {
- event.stopPropagation();
- setIsListExpanded(true);
- }, []);
-
- const resetFirstHiddenChildIndex = useCallback(() => {
- setFirstHiddenChildIndex(cappedChildren.length);
- }, [cappedChildren.length]);
-
- useEffect(() => {
- resetFirstHiddenChildIndex();
- }, [isChipCountDisplayed, cappedChildren.length, resetFirstHiddenChildIndex]);
-
- const handleClickOutside = () => {
- setIsListExpanded(false);
-
- if (
- childrenContainerElement?.clientWidth !== previousChildrenContainerWidth
- ) {
- resetFirstHiddenChildIndex();
- setPreviousChildrenContainerWidth(
- childrenContainerElement?.clientWidth ?? 0,
- );
- }
- };
-
- return (
- <StyledContainer
- ref={containerRef}
- onMouseEnter={
- isChipCountDisplayedFromProps
- ? undefined
- : () => setIsChipCountDisplayedInternal(true)
- }
- onMouseLeave={
- isChipCountDisplayedFromProps
- ? undefined
- : () => setIsChipCountDisplayedInternal(false)
- }
- >
- {isChipCountDisplayed && (
- <ExpandableListResizeEffect
- containerRef={containerRef}
- onContainerWidthChange={resetFirstHiddenChildIndex}
- />
- )}
- <StyledChildrenContainer ref={setChildrenContainerElement}>
- {visibleChildren.map((child, index) => (
- <StyledChildContainer
- key={index}
- ref={
- isChipCountDisplayed
- ? (childElement) => {
- if (
- index > 0 &&
- isFirstOverflowingChildElement({
- containerElement: childrenContainerElement,
- childElement,
- })
- ) {
- setFirstHiddenChildIndex(index);
- }
- }
- : undefined
- }
- >
- {child}
- </StyledChildContainer>
- ))}
- </StyledChildrenContainer>
- {canDisplayChipCount && (
- <AnimatedContainer>
- <StyledUnShrinkableContainer onClick={handleChipCountClick}>
- <OverflowingTextWithTooltip
- text={`+${hiddenChildrenCount}`}
- size="small"
- />
- </StyledUnShrinkableContainer>
- </AnimatedContainer>
- )}
- {isListExpanded && (
- <ExpandedListDropdown
- anchorElement={containerRef.current ?? undefined}
- onClickOutside={handleClickOutside}
- >
- {children}
- </ExpandedListDropdown>
- )}
- </StyledContainer>
- );
-};
diff --git a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableListResizeEffect.tsx b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableListResizeEffect.tsx
deleted file mode 100644
index 8d1cce8f36e..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableListResizeEffect.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { type RefObject, useEffect } from 'react';
-import { isDefined } from 'twenty-shared/utils';
-
-const RESIZE_THRESHOLD_PX = 1;
-
-const RESIZE_SETTLE_DELAY_MS = 100;
-
-type ExpandableListResizeEffectProps = {
- containerRef: RefObject<HTMLElement | null>;
- onContainerWidthChange: () => void;
-};
-
-export const ExpandableListResizeEffect = ({
- containerRef,
- onContainerWidthChange,
-}: ExpandableListResizeEffectProps) => {
- useEffect(() => {
- const containerElement = containerRef.current;
-
- if (!isDefined(containerElement)) {
- return;
- }
-
- let previousWidth = containerElement.clientWidth;
- let settleTimeoutId: ReturnType<typeof setTimeout> | undefined;
-
- const resizeObserver = new ResizeObserver((entries) => {
- const entry = entries[0];
-
- if (!isDefined(entry)) {
- return;
- }
-
- const newWidth = entry.contentRect.width;
-
- if (Math.abs(newWidth - previousWidth) <= RESIZE_THRESHOLD_PX) {
- return;
- }
-
- previousWidth = newWidth;
- clearTimeout(settleTimeoutId);
- settleTimeoutId = setTimeout(
- onContainerWidthChange,
- RESIZE_SETTLE_DELAY_MS,
- );
- });
-
- resizeObserver.observe(containerElement);
-
- return () => {
- clearTimeout(settleTimeoutId);
- resizeObserver.disconnect();
- };
- }, [containerRef, onContainerWidthChange]);
-
- return null;
-};
diff --git a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandedListDropdown.tsx b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandedListDropdown.tsx
deleted file mode 100644
index 63254a97129..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandedListDropdown.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';
-import { StyledOverlayPortalLayer } from '@/ui/layout/overlay/components/StyledOverlayPortalLayer';
-import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer';
-import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
-import { styled } from '@linaria/react';
-import { FloatingPortal, offset, shift, useFloating } from '@floating-ui/react';
-import { type ReactNode } from 'react';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-type ExpandedListDropdownProps = {
- anchorElement?: HTMLElement;
- children: ReactNode;
- onClickOutside?: () => void;
-};
-
-const StyledExpandedListContainer = styled.div<{ widthInPixels: number }>`
- display: flex;
- flex-wrap: wrap;
- gap: ${themeCssVariables.spacing[1]};
- padding: ${themeCssVariables.spacing[2]};
- width: ${({ widthInPixels }) => widthInPixels}px;
-`;
-
-// TODO: unify this and use Dropdown component instead
-export const ExpandedListDropdown = ({
- anchorElement,
- children,
- onClickOutside,
-}: ExpandedListDropdownProps) => {
- const { refs, floatingStyles } = useFloating({
- placement: 'bottom-start',
- strategy: 'fixed',
- middleware: [offset({ mainAxis: -9, crossAxis: -7 }), shift()],
- elements: { reference: anchorElement },
- });
-
- useListenClickOutside({
- refs: [refs.domReference],
- callback: () => {
- onClickOutside?.();
- },
- listenerId: 'expandable-list',
- });
-
- const dropdownContentWidth = anchorElement
- ? Math.max(220, anchorElement.offsetWidth)
- : GenericDropdownContentWidth.Medium;
-
- return (
- <FloatingPortal>
- <StyledOverlayPortalLayer
- data-floating-ui-viewport
- ref={refs.setFloating}
- style={floatingStyles}
- >
- <OverlayContainer>
- <StyledExpandedListContainer widthInPixels={dropdownContentWidth}>
- {children}
- </StyledExpandedListContainer>
- </OverlayContainer>
- </StyledOverlayPortalLayer>
- </FloatingPortal>
- );
-};
diff --git a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__stories__/ExpandableList.stories.tsx b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__stories__/ExpandableList.stories.tsx
deleted file mode 100644
index 2c72e2aea5d..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__stories__/ExpandableList.stories.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { expect, userEvent, waitFor, within } from 'storybook/test';
-
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
-import { isDefined } from 'twenty-shared/utils';
-import { Tag } from 'twenty-ui/primitives/data-display';
-import { ComponentDecorator } from 'twenty-ui/testing';
-import { MAIN_COLOR_NAMES } from 'twenty-ui/theme';
-
-const meta: Meta<typeof ExpandableList> = {
- title: 'UI/Layout/ExpandableList/ExpandableList',
- component: ExpandableList,
- decorators: [
- (Story) => (
- <div style={{ padding: 4, width: 300 }}>
- <Story />
- </div>
- ),
- ComponentDecorator,
- ],
- args: {
- children: Array.from({ length: 7 }, (_, index) => (
- <Tag
- key={index}
- color={MAIN_COLOR_NAMES[index]}
- >{`Option ${index + 1}`}</Tag>
- )),
- isChipCountDisplayed: false,
- },
- argTypes: {
- children: { control: false },
- },
-};
-
-export default meta;
-type Story = StoryObj<typeof ExpandableList>;
-
-export const Default: Story = {};
-
-export const WithChipCount: Story = {
- args: { isChipCountDisplayed: true },
-};
-
-export const WithExpandedList: Story = {
- ...WithChipCount,
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
-
- const chipCount = await canvas.findByText(/^\+\d+$/);
-
- await userEvent.click(chipCount);
-
- const body = canvasElement.ownerDocument.body;
- const bodyCanvas = within(body);
-
- expect(await bodyCanvas.findByText('Option 7')).toBeVisible();
- },
-};
-
-export const ClosesExpandedListOnClickOutside: Story = {
- ...WithChipCount,
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
- const bodyCanvas = within(canvasElement.ownerDocument.body);
-
- await userEvent.click(await canvas.findByText(/^\+\d+$/));
- expect(await bodyCanvas.findByText('Option 7')).toBeVisible();
-
- await userEvent.click(canvasElement);
-
- await waitFor(() => {
- expect(bodyCanvas.queryByText('Option 7')).not.toBeInTheDocument();
- });
- },
-};
-
-const OPTIONS_COUNT = 7;
-const COLLAPSED_WIDTH_PX = 96;
-
-const optionTags = Array.from({ length: OPTIONS_COUNT }, (_, index) => (
- <Tag key={index} color={MAIN_COLOR_NAMES[index]}>{`Option ${index + 1}`}</Tag>
-));
-
-const countRenderedOptions = (canvas: ReturnType<typeof within>) =>
- canvas.queryAllByText(/^Option \d+$/).length;
-
-export const RecomputesVisibleChipsOnResize: Story = {
- render: () => (
- <div
- data-resizable-cell
- style={{
- resize: 'horizontal',
- overflow: 'hidden',
- width: COLLAPSED_WIDTH_PX,
- minWidth: 56,
- maxWidth: '100%',
- }}
- >
- <ExpandableList isChipCountDisplayed>{optionTags}</ExpandableList>
- </div>
- ),
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
- const resizableCell = canvasElement.querySelector<HTMLElement>(
- '[data-resizable-cell]',
- );
-
- await waitFor(() => {
- expect(countRenderedOptions(canvas)).toBeLessThan(OPTIONS_COUNT);
- });
-
- const collapsedCount = countRenderedOptions(canvas);
-
- if (isDefined(resizableCell)) {
- resizableCell.style.width = '100%';
- }
-
- await waitFor(() => {
- expect(countRenderedOptions(canvas)).toBeGreaterThan(collapsedCount);
- });
- },
-};
-
-export const ShowsAllChipsWhenCountHidden: Story = {
- render: () => (
- <div style={{ width: '100%', overflow: 'hidden' }}>
- <ExpandableList isChipCountDisplayed={false}>{optionTags}</ExpandableList>
- </div>
- ),
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
-
- await waitFor(() => {
- expect(countRenderedOptions(canvas)).toBe(OPTIONS_COUNT);
- });
- },
-};
diff --git a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__tests__/ExpandableList.test.tsx b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__tests__/ExpandableList.test.tsx
deleted file mode 100644
index 43157d6137e..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__tests__/ExpandableList.test.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { render, screen } from '@testing-library/react';
-
-import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
-
-const buildChips = (count: number) =>
- Array.from({ length: count }, (_, index) => (
- <span key={index} data-testid="chip">
- chip-{index}
- </span>
- ));
-
-describe('ExpandableList', () => {
- it('mounts every child inline when no cap is provided', () => {
- render(<ExpandableList>{buildChips(5)}</ExpandableList>);
-
- expect(screen.getAllByTestId('chip')).toHaveLength(5);
- });
-
- it('mounts only maxInlineCount children inline when capped', () => {
- render(<ExpandableList maxInlineCount={2}>{buildChips(5)}</ExpandableList>);
-
- expect(screen.getAllByTestId('chip')).toHaveLength(2);
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/layout/expandable-list/utils/isFirstOverflowingChildElement.ts b/packages/twenty-front/src/modules/ui/layout/expandable-list/utils/isFirstOverflowingChildElement.ts
deleted file mode 100644
index 089c407a1e7..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/expandable-list/utils/isFirstOverflowingChildElement.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { isDefined } from 'twenty-shared/utils';
-export const isFirstOverflowingChildElement = ({
- containerElement,
- childElement,
-}: {
- containerElement: HTMLElement | null;
- childElement: HTMLElement | null;
-}) =>
- isDefined(containerElement) &&
- isDefined(childElement) &&
- // First element is always displayed.
- isDefined(childElement.previousElementSibling) &&
- containerElement.scrollWidth > containerElement.clientWidth &&
- childElement.offsetLeft + childElement.offsetWidth >
- containerElement.clientWidth &&
- (childElement.previousElementSibling as HTMLElement).offsetLeft <
- containerElement.clientWidth;
diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.ts
index fc64933d564..d270ea15519 100644
--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts
+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts
@@ -147,6 +147,7 @@ export const DOCUMENTATION_PATHS = {
UI_COMPONENTS_MENU_PICKER: '/ui/components/menu-picker',
UI_COMPONENTS_METRIC_ROW: '/ui/components/metric-row',
UI_COMPONENTS_NOTIFICATION_COUNTER: '/ui/components/notification-counter',
+ UI_COMPONENTS_OVERFLOWING_LIST: '/ui/components/overflowing-list',
UI_COMPONENTS_OVERVIEW: '/ui/components/overview',
UI_COMPONENTS_SEARCH_INPUT: '/ui/components/search-input',
UI_COMPONENTS_SECTION: '/ui/components/section',
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index d75a65c48a6..7ca612a44c1 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -1,3 +1,4 @@
+import { OVERFLOWING_LIST_PROP_DESCRIPTIONS } from './overflowingListPropDescriptions';
import { METRIC_ROW_PROP_DESCRIPTIONS } from './metricRowPropDescriptions';
import { PROGRESS_RING_PROP_DESCRIPTIONS } from './progressRingPropDescriptions';
import { AVATAR_GROUP_PROP_DESCRIPTIONS } from './avatarGroupPropDescriptions';
@@ -492,6 +493,13 @@ export const DOCUMENTED_COMPONENTS = [
},
},
},
+ {
+ name: 'OverflowingList',
+ source: 'components/layout/OverflowingList/OverflowingList.tsx',
+ entryPoint: 'twenty-ui/components',
+ slug: 'components/overflowing-list',
+ propDescriptions: OVERFLOWING_LIST_PROP_DESCRIPTIONS,
+ },
{
name: 'Section',
source: 'components/layout/Section/Section.tsx',
diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.json
index f7fb0770280..0eece38e239 100644
--- a/packages/twenty-ui/docs/module-ownership.json
+++ b/packages/twenty-ui/docs/module-ownership.json
@@ -65,6 +65,7 @@
"MenuPicker",
"MetricRow",
"NotificationCounter",
+ "OverflowingList",
"SearchInput",
"Section",
"SettingsRow",
diff --git a/packages/twenty-ui/docs/overflowingListPropDescriptions.ts b/packages/twenty-ui/docs/overflowingListPropDescriptions.ts
new file mode 100644
index 00000000000..d3745386f32
--- /dev/null
+++ b/packages/twenty-ui/docs/overflowingListPropDescriptions.ts
@@ -0,0 +1,15 @@
+import { type ComponentProps } from 'react';
+
+import { type OverflowingList } from '../src/components/layout/OverflowingList/OverflowingList';
+
+export const OVERFLOWING_LIST_PROP_DESCRIPTIONS = {
+ children: 'Complete ordered list of elements, each with a stable key.',
+ showOverflowCount:
+ 'Shows the overflow count on hover and keyboard focus by default. Use true to show it whenever items overflow, or false to omit the trigger. An open popup stays open until it is dismissed.',
+ maxInlineCount:
+ 'Maximum number of items mounted in the compact row. The popup still contains every item.',
+ overflowLabel:
+ 'Accessible label for the popup. The overflow button is named by its visible count followed by this label. Defaults to Show all items.',
+} satisfies Partial<
+ Record<keyof ComponentProps<typeof OverflowingList>, string>
+>;
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index f48f8bcb8ba..0c46095a736 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -33,6 +33,7 @@
"MenuPicker": "components/navigation/MenuPicker/MenuPicker",
"MetricRow": "components/data-display/MetricRow/MetricRow",
"NotificationCounter": "components/data-display/NotificationCounter/NotificationCounter",
+ "OverflowingList": "components/layout/OverflowingList/OverflowingList",
"SearchInput": "components/input/SearchInput/SearchInput",
"Section": "components/layout/Section/Section",
"SettingsRow": "components/input/SettingsRow/SettingsRow",
@@ -84,6 +85,7 @@
"MenuItemSuggestionProps": "components/navigation/MenuItemSuggestion/types/MenuItemSuggestionProps",
"MenuPickerProps": "components/navigation/MenuPicker/types/MenuPickerProps",
"MetricRowProps": "components/data-display/MetricRow/types/MetricRowProps",
+ "OverflowingListProps": "components/layout/OverflowingList/types/OverflowingListProps",
"SearchInputProps": "components/input/SearchInput/types/SearchInputProps",
"SectionHeaderProps": "components/layout/Section/types/SectionHeaderProps",
"SectionRootProps": "components/layout/Section/types/SectionRootProps",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 9b7f8d064cc..77d487c440d 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -8069,6 +8069,41 @@
}
]
},
+ {
+ "name": "OverflowingList",
+ "entryPoint": "twenty-ui/components",
+ "slug": "components/overflowing-list",
+ "props": [
+ {
+ "name": "children",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>>[]",
+ "required": true,
+ "defaultValue": null,
+ "description": "Complete ordered list of elements, each with a stable key."
+ },
+ {
+ "name": "maxInlineCount",
+ "type": "number",
+ "required": false,
+ "defaultValue": null,
+ "description": "Maximum number of items mounted in the compact row. The popup still contains every item."
+ },
+ {
+ "name": "overflowLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": "Show all items",
+ "description": "Accessible label for the popup. The overflow button is named by its visible count followed by this label. Defaults to Show all items."
+ },
+ {
+ "name": "showOverflowCount",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Shows the overflow count on hover and keyboard focus by default. Use true to show it whenever items overflow, or false to omit the trigger. An open popup stays open until it is dismissed."
+ }
+ ]
+ },
{
"name": "Section",
"entryPoint": "twenty-ui/components",
diff --git a/packages/twenty-ui/src/components/index.ts b/packages/twenty-ui/src/components/index.ts
index 28f85df3440..4a17db7fd98 100644
--- a/packages/twenty-ui/src/components/index.ts
+++ b/packages/twenty-ui/src/components/index.ts
@@ -54,6 +54,8 @@ export type { SearchInputProps } from './input/SearchInput/types/SearchInputProp
export { SettingsRow } from './input/SettingsRow/SettingsRow';
export type { SettingsRowProps } from './input/SettingsRow/types/SettingsRowProps';
export { AnimatedIconCrossfade } from './layout/AnimatedIconCrossfade/AnimatedIconCrossfade';
+export { OverflowingList } from './layout/OverflowingList/OverflowingList';
+export type { OverflowingListProps } from './layout/OverflowingList/types/OverflowingListProps';
export { Section } from './layout/Section/Section';
export type { SectionHeaderProps } from './layout/Section/types/SectionHeaderProps';
export type { SectionRootProps } from './layout/Section/types/SectionRootProps';
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.module.scss b/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.module.scss
new file mode 100644
index 00000000000..c05abf8f283
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.module.scss
@@ -0,0 +1,81 @@
+.root {
+ align-items: center;
+ display: flex;
+ gap: var(--t-spacing-1);
+ inline-size: 100%;
+ justify-content: space-between;
+ min-inline-size: 0;
+ position: relative;
+}
+
+.items {
+ display: flex;
+ flex: 0 1 auto;
+ gap: var(--t-spacing-1);
+ max-inline-size: 100%;
+ min-inline-size: 0;
+ overflow: hidden;
+ position: relative;
+
+ &[data-measuring] {
+ overflow: visible;
+
+ > .item {
+ flex: 0 0 auto;
+ inline-size: max-content;
+ max-inline-size: none;
+ position: static;
+ }
+ }
+}
+
+.item {
+ display: flex;
+ flex: 0 0 auto;
+ min-inline-size: 0;
+ overflow: hidden;
+
+ &[data-hidden] {
+ inline-size: max-content;
+ position: absolute;
+ visibility: hidden;
+ }
+
+ &[data-last-visible] {
+ flex-shrink: 1;
+ }
+}
+
+.trigger {
+ @include focus-ring;
+
+ appearance: none;
+ background: none;
+ border: 0;
+ border-radius: var(--t-border-radius-sm);
+ color: var(--t-font-color-primary);
+ cursor: pointer;
+ flex: 0 0 auto;
+ font: inherit;
+ font-size: var(--t-font-size-sm);
+ inset-inline-end: 0;
+ min-inline-size: 24px;
+ opacity: 0;
+ padding: 0;
+ pointer-events: none;
+ position: absolute;
+
+ &[data-visible] {
+ opacity: 1;
+ pointer-events: auto;
+ position: static;
+ }
+}
+
+.popup[data-overflowing-list-popup] {
+ flex-direction: row;
+ flex-wrap: wrap;
+ inline-size: max(220px, var(--anchor-width));
+ max-block-size: var(--available-height);
+ overflow: auto;
+}
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.module.scss.d.ts b/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.module.scss.d.ts
new file mode 100644
index 00000000000..bc80d9400b0
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.module.scss.d.ts
@@ -0,0 +1,10 @@
+export type Styles = {
+ root: string;
+ items: string;
+ item: string;
+ trigger: string;
+ popup: string;
+};
+
+declare const styles: Styles;
+export default styles;
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.tsx
new file mode 100644
index 00000000000..115af5a4d9d
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/OverflowingList.tsx
@@ -0,0 +1,153 @@
+import { useMergedRefs } from '@base-ui/utils/useMergedRefs';
+import { clsx } from 'clsx';
+import { type SyntheticEvent, useCallback, useState } from 'react';
+
+import { Popover } from '@ui/primitives/surfaces/Popover/Popover';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import styles from './OverflowingList.module.scss';
+import { OverflowingListItem } from './internal/OverflowingListItem';
+import { useOverflowingListLayout } from './internal/useOverflowingListLayout';
+import { useFocusedElementUnmountRef } from './internal/useFocusedElementUnmountRef';
+import { type OverflowingListProps } from './types/OverflowingListProps';
+
+const stopPropagation = (event: SyntheticEvent) => event.stopPropagation();
+
+const STOP_PROPAGATION_PROPS = {
+ onClick: stopPropagation,
+ onMouseDown: stopPropagation,
+ onPointerDown: stopPropagation,
+ onKeyDown: stopPropagation,
+ onKeyUp: stopPropagation,
+};
+
+export const OverflowingList = ({
+ children,
+ showOverflowCount,
+ maxInlineCount,
+ overflowLabel = 'Show all items',
+ className,
+ onMouseEnter,
+ onMouseLeave,
+ onFocusCapture,
+ onBlurCapture,
+ ref,
+ ...props
+}: OverflowingListProps) => {
+ const [isHovered, setIsHovered] = useState(false);
+ const [hasFocus, setHasFocus] = useState(false);
+ const [isOpen, setIsOpen] = useState(false);
+ const [focusedItemCountVisibility, setFocusedItemCountVisibility] =
+ useState<boolean>();
+ const isCountVisible =
+ showOverflowCount ??
+ focusedItemCountVisibility ??
+ (isHovered || hasFocus || isOpen);
+ const inlineItemCount =
+ isDefined(maxInlineCount) && Number.isFinite(maxInlineCount)
+ ? Math.min(children.length, Math.max(0, Math.floor(maxInlineCount)))
+ : children.length;
+ const { containerRef, itemsRef, triggerRef, visibleItemCount, hasOverflow } =
+ useOverflowingListLayout({
+ itemCount: children.length,
+ inlineItemCount,
+ reserveCountSpace: isCountVisible,
+ isMeasurementEnabled: showOverflowCount !== false || isOpen,
+ });
+ const resetFocusState = useCallback(() => {
+ setHasFocus(false);
+ setFocusedItemCountVisibility(undefined);
+ }, []);
+ const resetFocusWhenFocusedTriggerUnmounts =
+ useFocusedElementUnmountRef(resetFocusState);
+ const mergedRef = useMergedRefs(containerRef, ref);
+ const mergedTriggerRef = useMergedRefs(
+ triggerRef,
+ resetFocusWhenFocusedTriggerUnmounts,
+ );
+ const displayedItemCount =
+ showOverflowCount === false ? inlineItemCount : visibleItemCount;
+ const hiddenItemCount = children.length - visibleItemCount;
+ const canExpand = hasOverflow && (isOpen || showOverflowCount !== false);
+
+ if (isOpen && !canExpand) {
+ setIsOpen(false);
+ }
+
+ return (
+ <Popover.Root open={isOpen && canExpand} onOpenChange={setIsOpen}>
+ <div
+ {...props}
+ ref={mergedRef}
+ className={clsx(styles.root, className)}
+ onMouseEnter={(event) => {
+ setIsHovered(true);
+ onMouseEnter?.(event);
+ }}
+ onMouseLeave={(event) => {
+ setIsHovered(false);
+ onMouseLeave?.(event);
+ }}
+ onFocusCapture={(event) => {
+ setHasFocus(true);
+
+ if (itemsRef.current?.contains(event.target)) {
+ setFocusedItemCountVisibility(
+ (currentVisibility) => currentVisibility ?? isCountVisible,
+ );
+ }
+
+ onFocusCapture?.(event);
+ }}
+ onBlurCapture={(event) => {
+ setHasFocus(event.currentTarget.contains(event.relatedTarget));
+
+ if (!itemsRef.current?.contains(event.relatedTarget)) {
+ setFocusedItemCountVisibility(undefined);
+ }
+
+ onBlurCapture?.(event);
+ }}
+ >
+ <div ref={itemsRef} className={styles.items}>
+ {children.slice(0, inlineItemCount).map((child, index) => (
+ <OverflowingListItem
+ key={child.key ?? index}
+ isHidden={index >= displayedItemCount}
+ isLastVisible={
+ showOverflowCount !== false && index === displayedItemCount - 1
+ }
+ onFocusedItemUnmount={resetFocusState}
+ >
+ {child}
+ </OverflowingListItem>
+ ))}
+ </div>
+ {canExpand && (
+ <Popover.Trigger
+ ref={mergedTriggerRef}
+ type="button"
+ className={styles.trigger}
+ data-visible={isCountVisible || undefined}
+ aria-label={`+${hiddenItemCount} ${overflowLabel}`}
+ {...STOP_PROPAGATION_PROPS}
+ >
+ +{hiddenItemCount}
+ </Popover.Trigger>
+ )}
+ <Popover.Popup
+ anchor={containerRef}
+ align="start"
+ sideOffset={-9}
+ alignOffset={-7}
+ aria-label={overflowLabel}
+ className={styles.popup}
+ data-overflowing-list-popup=""
+ {...STOP_PROPAGATION_PROPS}
+ >
+ {children}
+ </Popover.Popup>
+ </div>
+ </Popover.Root>
+ );
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OVERFLOWING_LIST_STORY_ITEMS.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OVERFLOWING_LIST_STORY_ITEMS.tsx
new file mode 100644
index 00000000000..e6832d71745
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OVERFLOWING_LIST_STORY_ITEMS.tsx
@@ -0,0 +1,12 @@
+import { Tag } from '@ui/primitives/data-display/Tag/Tag';
+
+export const OVERFLOWING_LIST_STORY_ITEMS = [
+ 'Customer',
+ 'Partner',
+ 'Priority',
+ 'Renewal',
+].map((label) => (
+ <Tag key={label} color="blue" preventShrink style={{ width: 80 }}>
+ {label}
+ </Tag>
+));
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.interactions.stories.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.interactions.stories.tsx
new file mode 100644
index 00000000000..40f88891d39
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.interactions.stories.tsx
@@ -0,0 +1,571 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+
+import { Tag } from '@ui/primitives/data-display/Tag/Tag';
+import { Button } from '@ui/primitives/input/Button/Button';
+import { Card } from '@ui/primitives/surfaces/Card/Card';
+import { TextDirectionProvider } from '@ui/primitives/layout/TextDirectionProvider/TextDirectionProvider';
+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
+import { ThemeProvider } from '@ui/theme/ThemeProvider';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import { OverflowingList } from '../OverflowingList';
+import { OVERFLOWING_LIST_STORY_ITEMS } from './OVERFLOWING_LIST_STORY_ITEMS';
+import { OverflowingListControlledFocusExample } from './OverflowingListControlledFocusExample';
+import { OverflowingListMutableTag } from './OverflowingListMutableTag';
+import { OverflowingListResizeExample } from './OverflowingListResizeExample';
+import { expectOverflowingListPopupGeometry } from './expectOverflowingListPopupGeometry';
+
+const onHostClick = fn();
+const onHostMouseDown = fn();
+const onHostKeyDown = fn();
+const onItemClick = fn();
+
+const meta: Meta<typeof OverflowingList> = {
+ title: 'UI/Components/OverflowingList/Interactions',
+ component: OverflowingList,
+ tags: ['!autodocs'],
+ decorators: [ComponentDecorator],
+ parameters: {
+ container: { width: 400, height: 280 },
+ a11y: A11Y_DEFER_COLOR_CONTRAST,
+ },
+ args: {
+ children: OVERFLOWING_LIST_STORY_ITEMS,
+ showOverflowCount: true,
+ style: { width: 180, alignSelf: 'center' },
+ },
+ beforeEach: () => {
+ onHostClick.mockClear();
+ onHostMouseDown.mockClear();
+ onHostKeyDown.mockClear();
+ onItemClick.mockClear();
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof OverflowingList>;
+
+export const Keyboard: Story = {
+ play: async ({ canvasElement, step }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+
+ await userEvent.tab();
+ expect(trigger).toHaveFocus();
+
+ for (const key of ['{Enter}', ' ']) {
+ await step(`Open with ${key === ' ' ? 'Space' : 'Enter'}`, async () => {
+ await userEvent.keyboard(key);
+ const dialog = await body.findByRole('dialog', {
+ name: 'Show all items',
+ });
+ await waitFor(() => expect(dialog).toHaveFocus());
+ await expectOverflowingListPopupGeometry({ trigger, dialog });
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
+ expect(trigger).toHaveAttribute('aria-controls', dialog.id);
+ expect(canvasElement).not.toContainElement(dialog);
+
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ await waitFor(() => expect(trigger).toHaveFocus());
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
+ });
+ }
+ },
+};
+
+export const CompleteListWithInlineCap: Story = {
+ args: { maxInlineCount: 1 },
+ render: (args) => (
+ <>
+ <OverflowingList {...args} />
+ <Button>Outside the list</Button>
+ </>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+
+ expect(trigger).toHaveTextContent('+3');
+ expect(trigger).toHaveAccessibleName('+3 Show all items');
+ expect(canvas.queryByText('Renewal')).not.toBeInTheDocument();
+ await userEvent.click(trigger);
+ const dialog = await body.findByRole('dialog', {
+ name: 'Show all items',
+ });
+
+ for (const label of ['Customer', 'Partner', 'Priority', 'Renewal']) {
+ await waitFor(() =>
+ expect(within(dialog).getByText(label)).toBeVisible(),
+ );
+ }
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Outside the list' }),
+ );
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ },
+};
+
+export const ResizeAndContentUpdates: Story = {
+ render: () => <OverflowingListResizeExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument();
+ await userEvent.click(canvas.getByRole('button', { name: 'Narrow list' }));
+ expect(
+ await canvas.findByRole('button', { name: /Show all items$/ }),
+ ).toHaveTextContent('+3');
+ await userEvent.click(
+ canvas.getByRole('button', { name: /Show all items$/ }),
+ );
+ await body.findByRole('dialog', { name: 'Show all items' });
+ const list = canvas.getByLabelText('Resizable tags');
+ list.style.width = '360px';
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ await waitFor(() =>
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument(),
+ );
+
+ list.style.width = '100px';
+ await canvas.findByRole('button', { name: /Show all items$/ });
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument();
+ await userEvent.click(canvas.getByRole('button', { name: 'Widen list' }));
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Lengthen labels' }),
+ );
+ expect(
+ await canvas.findByRole('button', { name: /Show all items$/ }),
+ ).toBeVisible();
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Shorten labels' }),
+ );
+ await waitFor(() =>
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument(),
+ );
+ },
+};
+
+export const CountVisibility: Story = {
+ args: { showOverflowCount: undefined },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+
+ const firstItem = canvas.getByText('Customer');
+
+ await userEvent.unhover(firstItem);
+ await waitFor(() => expect(trigger).toHaveStyle({ opacity: '0' }));
+ await userEvent.hover(firstItem);
+ await waitFor(() => expect(trigger).toHaveStyle({ opacity: '1' }));
+ await userEvent.unhover(firstItem);
+ await waitFor(() => expect(trigger).toHaveStyle({ opacity: '0' }));
+ await userEvent.tab();
+ expect(trigger).toHaveFocus();
+ await waitFor(() => expect(trigger).toHaveStyle({ opacity: '1' }));
+ },
+};
+
+export const CountDisabled: Story = {
+ args: {
+ showOverflowCount: false,
+ children: ['First item', 'Second item', 'Third item'].map((label) => (
+ <Button key={label} style={{ width: 100 }}>
+ {label}
+ </Button>
+ )),
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.hover(canvas.getByRole('button', { name: 'First item' }));
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument();
+
+ for (const label of ['First item', 'Second item', 'Third item']) {
+ await userEvent.tab();
+ const item = canvas.getByRole('button', { name: label });
+ expect(item).toHaveFocus();
+ expect(item.parentElement?.getBoundingClientRect().width).toBeGreaterThan(
+ 0,
+ );
+ }
+ },
+};
+
+export const InlineItemFocus: Story = {
+ args: {
+ showOverflowCount: undefined,
+ style: { width: 168 },
+ children: ['First item', 'Second item', 'Third item'].map((label) => (
+ <Button key={label} style={{ width: 80 }}>
+ {label}
+ </Button>
+ )),
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const firstItem = canvas.getByRole('button', { name: 'First item' });
+ const secondItem = canvas.getByRole('button', { name: 'Second item' });
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+
+ await userEvent.unhover(firstItem);
+ await waitFor(() => expect(trigger).toHaveStyle({ opacity: '0' }));
+ await userEvent.tab();
+ expect(firstItem).toHaveFocus();
+ await userEvent.tab();
+ expect(secondItem).toHaveFocus();
+ expect(secondItem.closest('[inert]')).toBeNull();
+ expect(secondItem.closest('[aria-hidden="true"]')).toBeNull();
+ await userEvent.hover(secondItem);
+ expect(secondItem).toHaveFocus();
+ expect(trigger).toHaveStyle({ opacity: '0' });
+ await userEvent.tab();
+ expect(trigger).toHaveFocus();
+ await waitFor(() => expect(trigger).toHaveStyle({ opacity: '1' }));
+ },
+};
+
+export const ControlledCountWhileFocused: Story = {
+ render: () => <OverflowingListControlledFocusExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const toggle = canvas.getByRole('button', { name: 'Toggle count' });
+
+ await userEvent.tab();
+ expect(toggle).toHaveFocus();
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument();
+ await userEvent.keyboard('{Enter}');
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+ await waitFor(() => expect(trigger).toHaveStyle({ opacity: '1' }));
+ expect(toggle).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument();
+ expect(toggle).toHaveFocus();
+ },
+};
+
+export const OpenPopupOutlivesHiddenCount: Story = {
+ render: () => <OverflowingListControlledFocusExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Toggle count' }));
+ await userEvent.click(
+ await canvas.findByRole('button', { name: /Show all items$/ }),
+ );
+ const dialog = await body.findByRole('dialog', {
+ name: 'Show all items',
+ });
+ const popupToggle = within(dialog).getByRole('button', {
+ name: 'Toggle count',
+ });
+
+ await userEvent.click(popupToggle);
+ await waitFor(() =>
+ expect(popupToggle).toHaveAttribute('aria-pressed', 'false'),
+ );
+ expect(dialog).toBeVisible();
+
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument();
+ },
+};
+
+export const FocusedTriggerRemoval: Story = {
+ args: { showOverflowCount: undefined },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+ const list = trigger.parentElement;
+
+ if (!isDefined(list)) {
+ throw new Error('The overflow trigger must be inside its list');
+ }
+
+ await userEvent.unhover(list);
+ await userEvent.tab();
+ expect(trigger).toHaveFocus();
+ await waitFor(() => expect(trigger).toHaveStyle({ opacity: '1' }));
+
+ list.style.width = '800px';
+ await waitFor(() =>
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument(),
+ );
+
+ list.style.width = '180px';
+ const restoredTrigger = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+ await waitFor(() => expect(restoredTrigger).toHaveStyle({ opacity: '0' }));
+ },
+};
+
+export const ClickableFieldHost: Story = {
+ args: { maxInlineCount: 1 },
+ render: (args) => (
+ <div
+ role="group"
+ aria-label="Clickable field"
+ onClick={onHostClick}
+ onMouseDown={onHostMouseDown}
+ onKeyDown={onHostKeyDown}
+ >
+ <OverflowingList {...args}>
+ {['First item', 'Second item', 'Third item'].map((label) => (
+ <Button key={label} onClick={onItemClick} style={{ width: 100 }}>
+ {label}
+ </Button>
+ ))}
+ </OverflowingList>
+ </div>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const trigger = await canvas.findByRole('button', {
+ name: /Show all items$/,
+ });
+
+ await userEvent.click(trigger);
+ const dialog = await body.findByRole('dialog', {
+ name: 'Show all items',
+ });
+ await userEvent.click(
+ within(dialog).getByRole('button', { name: 'Third item' }),
+ );
+ expect(onItemClick).toHaveBeenCalledOnce();
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(trigger).toHaveFocus());
+ await userEvent.keyboard('{Enter}');
+ await body.findByRole('dialog', { name: 'Show all items' });
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+
+ expect(onHostClick).not.toHaveBeenCalled();
+ expect(onHostMouseDown).not.toHaveBeenCalled();
+ expect(onHostKeyDown).not.toHaveBeenCalled();
+ },
+};
+
+export const IndependentInstances: Story = {
+ render: (args) => (
+ <>
+ <OverflowingList {...args} overflowLabel="Show company tags" />
+ <OverflowingList {...args} overflowLabel="Show person tags" />
+ </>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+ const companyTrigger = await canvas.findByRole('button', {
+ name: /Show company tags$/,
+ });
+ const personTrigger = await canvas.findByRole('button', {
+ name: /Show person tags$/,
+ });
+
+ await userEvent.click(companyTrigger);
+ await body.findByRole('dialog', { name: 'Show company tags' });
+ expect(personTrigger).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.click(personTrigger);
+ const personDialog = await body.findByRole('dialog', {
+ name: 'Show person tags',
+ });
+ await waitFor(() =>
+ expect(
+ body.queryByRole('dialog', { name: 'Show company tags' }),
+ ).not.toBeInTheDocument(),
+ );
+ expect(personTrigger).toHaveAttribute('aria-controls', personDialog.id);
+ expect(companyTrigger).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(personTrigger).toHaveFocus());
+ },
+};
+
+export const ScopedThemeAndDirection: Story = {
+ parameters: { argos: { fitToContent: { zoom: 1 } } },
+ render: (args) => (
+ <section aria-label="Scoped company tags">
+ <ThemeProvider
+ colorScheme="dark"
+ applyToRoot={false}
+ overrides={{ '--t-background-primary': 'rgb(20, 30, 40)' }}
+ >
+ <Card.Root
+ backgroundColor="var(--t-background-primary)"
+ style={{ width: 360, height: 220, padding: 16 }}
+ >
+ <TextDirectionProvider direction="rtl">
+ <OverflowingList {...args} dir="rtl" />
+ </TextDirectionProvider>
+ </Card.Root>
+ </ThemeProvider>
+ </section>
+ ),
+ play: async ({ canvasElement }) => {
+ const scope = within(canvasElement).getByRole('region', {
+ name: 'Scoped company tags',
+ });
+ await userEvent.click(
+ await within(scope).findByRole('button', { name: /Show all items$/ }),
+ );
+ const dialog = await within(scope).findByRole('dialog', {
+ name: 'Show all items',
+ });
+
+ await waitFor(() => expect(dialog).toBeVisible());
+ await expectOverflowingListPopupGeometry({
+ trigger: within(scope).getByRole('button', { name: /Show all items$/ }),
+ dialog,
+ });
+ expect(getComputedStyle(dialog).direction).toBe('rtl');
+ expect(
+ getComputedStyle(dialog)
+ .getPropertyValue('--t-background-primary')
+ .trim(),
+ ).toBe('rgb(20, 30, 40)');
+ },
+};
+
+export const OversizedSingleItem: Story = {
+ args: {
+ children: [
+ <Tag key="long-label" color="blue" style={{ width: 400 }}>
+ A single tag with a label that is wider than its field
+ </Tag>,
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ canvas.getByText(
+ 'A single tag with a label that is wider than its field',
+ ),
+ ).toBeVisible();
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument();
+ },
+};
+
+export const ZoomedInstances: Story = {
+ render: (args) => (
+ <>
+ {[0.75, 1.25].map((zoom) => (
+ <div key={zoom} style={{ zoom }}>
+ <OverflowingList
+ {...args}
+ overflowLabel={`Show tags at ${zoom} scale`}
+ />
+ </div>
+ ))}
+ </>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+
+ for (const zoom of [0.75, 1.25]) {
+ await waitFor(() =>
+ expect(
+ canvas.getByRole('button', { name: `+3 Show tags at ${zoom} scale` }),
+ ).toHaveTextContent('+3'),
+ );
+ const trigger = canvas.getByRole('button', {
+ name: `+3 Show tags at ${zoom} scale`,
+ });
+ await userEvent.click(trigger);
+ const dialog = await body.findByRole('dialog', {
+ name: `Show tags at ${zoom} scale`,
+ });
+ await waitFor(() => expect(dialog).toBeVisible());
+ await expectOverflowingListPopupGeometry({ trigger, dialog });
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(body.queryByRole('dialog')).not.toBeInTheDocument(),
+ );
+ }
+ },
+};
+
+export const DescendantContentUpdates: Story = {
+ args: {
+ style: { width: 200 },
+ children: [
+ <OverflowingListMutableTag key="customer" />,
+ <Tag key="partner" color="green" preventShrink>
+ Partner
+ </Tag>,
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const tag = canvas.getByRole('button', { name: 'Toggle tag label' });
+
+ await userEvent.hover(tag);
+ await userEvent.tab();
+ expect(tag).toHaveFocus();
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument();
+
+ await userEvent.click(tag);
+ expect(
+ await canvas.findByRole('button', { name: /Show all items$/ }),
+ ).toHaveTextContent('+1');
+ await userEvent.click(tag);
+ await waitFor(() =>
+ expect(
+ canvas.queryByRole('button', { name: /Show all items$/ }),
+ ).not.toBeInTheDocument(),
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.stories.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.stories.tsx
new file mode 100644
index 00000000000..0eb60afdfff
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingList.stories.tsx
@@ -0,0 +1,60 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+
+import { Section } from '@ui/components/layout/Section/Section';
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
+
+import { OverflowingList } from '../OverflowingList';
+import { OVERFLOWING_LIST_STORY_ITEMS } from './OVERFLOWING_LIST_STORY_ITEMS';
+
+const meta: Meta<typeof OverflowingList> = {
+ title: 'UI/Components/OverflowingList',
+ component: OverflowingList,
+ decorators: [ComponentDecorator],
+ parameters: {
+ container: { width: 260, height: 200 },
+ a11y: A11Y_DEFER_COLOR_CONTRAST,
+ },
+ args: {
+ children: OVERFLOWING_LIST_STORY_ITEMS,
+ showOverflowCount: true,
+ style: { width: 180 },
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof OverflowingList>;
+
+export const Default: Story = {};
+
+export const Documentation: Story = {
+ render: (args) => (
+ <Section.Root>
+ <Section.Header title="Company tags" />
+ <Text>Open the count to see every tag.</Text>
+ <OverflowingList {...args} overflowLabel="Show all company tags" />
+ </Section.Root>
+ ),
+};
+
+export const CountOnHoverOrFocus: Story = {
+ args: { showOverflowCount: undefined },
+};
+
+export const WithoutCount: Story = {
+ args: { showOverflowCount: false },
+};
+
+export const CappedInlineItems: Story = {
+ args: { maxInlineCount: 1 },
+};
+
+export const AllItemsFit: Story = {
+ args: { style: { width: 360 } },
+ parameters: { container: { width: 400, height: 160 } },
+};
+
+export const Dark: Story = {
+ globals: { colorScheme: 'dark' },
+ tags: ['!autodocs'],
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListControlledFocusExample.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListControlledFocusExample.tsx
new file mode 100644
index 00000000000..495e71bc40a
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListControlledFocusExample.tsx
@@ -0,0 +1,31 @@
+import { useState } from 'react';
+
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { OverflowingList } from '../OverflowingList';
+
+export const OverflowingListControlledFocusExample = () => {
+ const [showOverflowCount, setShowOverflowCount] = useState(false);
+
+ return (
+ <OverflowingList
+ showOverflowCount={showOverflowCount}
+ style={{ width: 168 }}
+ >
+ <Button
+ key="toggle-count"
+ aria-pressed={showOverflowCount}
+ style={{ width: 80 }}
+ onClick={() => setShowOverflowCount((isVisible) => !isVisible)}
+ >
+ Toggle count
+ </Button>
+ <Button key="second-item" style={{ width: 80 }}>
+ Second item
+ </Button>
+ <Button key="third-item" style={{ width: 80 }}>
+ Third item
+ </Button>
+ </OverflowingList>
+ );
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx
new file mode 100644
index 00000000000..e766cc54f3e
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx
@@ -0,0 +1,18 @@
+import { useState } from 'react';
+
+import { Tag } from '@ui/primitives/data-display/Tag/Tag';
+
+export const OverflowingListMutableTag = () => {
+ const [hasLongLabel, setHasLongLabel] = useState(false);
+
+ return (
+ <Tag
+ color="blue"
+ preventShrink
+ aria-label="Toggle tag label"
+ onClick={() => setHasLongLabel(!hasLongLabel)}
+ >
+ {hasLongLabel ? 'Customer with a much longer description' : 'Customer'}
+ </Tag>
+ );
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx
new file mode 100644
index 00000000000..37611c86c84
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx
@@ -0,0 +1,34 @@
+import { useState } from 'react';
+
+import { Section } from '@ui/components/layout/Section/Section';
+import { Tag } from '@ui/primitives/data-display/Tag/Tag';
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { OverflowingList } from '../OverflowingList';
+
+export const OverflowingListResizeExample = () => {
+ const [isNarrow, setIsNarrow] = useState(false);
+ const [hasLongLabels, setHasLongLabels] = useState(false);
+
+ return (
+ <Section.Root>
+ <OverflowingList
+ aria-label="Resizable tags"
+ showOverflowCount
+ style={{ width: isNarrow ? 100 : 360 }}
+ >
+ {['Customer', 'Partner', 'Priority', 'Renewal'].map((label) => (
+ <Tag key={label} color="blue" preventShrink>
+ {hasLongLabels ? `${label} with a longer label` : label}
+ </Tag>
+ ))}
+ </OverflowingList>
+ <Button onClick={() => setIsNarrow(!isNarrow)}>
+ {isNarrow ? 'Widen list' : 'Narrow list'}
+ </Button>
+ <Button onClick={() => setHasLongLabels(!hasLongLabels)}>
+ {hasLongLabels ? 'Shorten labels' : 'Lengthen labels'}
+ </Button>
+ </Section.Root>
+ );
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/expectOverflowingListPopupGeometry.ts b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/expectOverflowingListPopupGeometry.ts
new file mode 100644
index 00000000000..1c7e9fc298a
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/expectOverflowingListPopupGeometry.ts
@@ -0,0 +1,34 @@
+import { expect, waitFor } from 'storybook/test';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+export const expectOverflowingListPopupGeometry = async ({
+ trigger,
+ dialog,
+}: {
+ trigger: HTMLElement;
+ dialog: HTMLElement;
+}) => {
+ const list = trigger.parentElement;
+
+ if (!isDefined(list)) {
+ throw new Error('The overflow trigger must be inside its list');
+ }
+
+ await waitFor(() => {
+ const listRectangle = list.getBoundingClientRect();
+ const dialogRectangle = dialog.getBoundingClientRect();
+ const dialogStyle = getComputedStyle(dialog);
+ const horizontalBorderAndPadding =
+ parseFloat(dialogStyle.paddingLeft) +
+ parseFloat(dialogStyle.paddingRight) +
+ parseFloat(dialogStyle.borderLeftWidth) +
+ parseFloat(dialogStyle.borderRightWidth);
+
+ expect(dialogRectangle.top).toBeCloseTo(listRectangle.bottom - 9, 0);
+ expect(dialogRectangle.width).toBeCloseTo(
+ Math.max(220, listRectangle.width) + horizontalBorderAndPadding,
+ 0,
+ );
+ });
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__tests__/OverflowingList.test.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__tests__/OverflowingList.test.tsx
new file mode 100644
index 00000000000..cb1a1413420
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__tests__/OverflowingList.test.tsx
@@ -0,0 +1,17 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+
+import { OverflowingList } from '../OverflowingList';
+
+runComponentConformance({
+ name: 'OverflowingList',
+ element: (
+ <OverflowingList>
+ {[
+ <span key="first">First item</span>,
+ <span key="second">Second item</span>,
+ ]}
+ </OverflowingList>
+ ),
+ refInstanceOf: HTMLDivElement,
+ skip: ['renderProp'],
+});
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/OverflowingListItem.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/internal/OverflowingListItem.tsx
new file mode 100644
index 00000000000..fe842ae5ef8
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/OverflowingListItem.tsx
@@ -0,0 +1,34 @@
+import { type ReactElement } from 'react';
+
+import styles from '../OverflowingList.module.scss';
+import { useFocusedElementUnmountRef } from './useFocusedElementUnmountRef';
+
+type OverflowingListItemProps = {
+ children: ReactElement;
+ isHidden: boolean;
+ isLastVisible: boolean;
+ onFocusedItemUnmount: () => void;
+};
+
+export const OverflowingListItem = ({
+ children,
+ isHidden,
+ isLastVisible,
+ onFocusedItemUnmount,
+}: OverflowingListItemProps) => {
+ const resetFocusWhenFocusedItemUnmounts =
+ useFocusedElementUnmountRef(onFocusedItemUnmount);
+
+ return (
+ <div
+ ref={resetFocusWhenFocusedItemUnmounts}
+ className={styles.item}
+ data-hidden={isHidden || undefined}
+ data-last-visible={isLastVisible || undefined}
+ aria-hidden={isHidden || undefined}
+ inert={isHidden}
+ >
+ {children}
+ </div>
+ );
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/__tests__/getVisibleItemCount.test.ts b/packages/twenty-ui/src/components/layout/OverflowingList/internal/__tests__/getVisibleItemCount.test.ts
new file mode 100644
index 00000000000..02b8f1d2bb5
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/__tests__/getVisibleItemCount.test.ts
@@ -0,0 +1,69 @@
+import { getVisibleItemCount } from '../getVisibleItemCount';
+
+describe('getVisibleItemCount', () => {
+ it('returns zero for an empty list', () => {
+ expect(
+ getVisibleItemCount({
+ itemWidths: [],
+ availableWidth: 100,
+ gap: 5,
+ includePartialItem: false,
+ }),
+ ).toBe(0);
+ });
+
+ it('keeps an oversized first item visible for truncation', () => {
+ expect(
+ getVisibleItemCount({
+ itemWidths: [240],
+ availableWidth: 100,
+ gap: 5,
+ includePartialItem: false,
+ }),
+ ).toBe(1);
+ });
+
+ it('includes every item when the items and intervening gaps fit exactly', () => {
+ expect(
+ getVisibleItemCount({
+ itemWidths: [30, 40, 20],
+ availableWidth: 100,
+ gap: 5,
+ includePartialItem: false,
+ }),
+ ).toBe(3);
+ });
+
+ it('excludes a partially fitting item when only whole items are allowed', () => {
+ expect(
+ getVisibleItemCount({
+ itemWidths: [30, 40, 20],
+ availableWidth: 90,
+ gap: 5,
+ includePartialItem: false,
+ }),
+ ).toBe(2);
+ });
+
+ it('includes a partially fitting item when partial items are allowed', () => {
+ expect(
+ getVisibleItemCount({
+ itemWidths: [30, 40, 20],
+ availableWidth: 90,
+ gap: 5,
+ includePartialItem: true,
+ }),
+ ).toBe(3);
+ });
+
+ it('excludes the next item when only its preceding gap fits', () => {
+ expect(
+ getVisibleItemCount({
+ itemWidths: [30, 40, 20],
+ availableWidth: 80,
+ gap: 5,
+ includePartialItem: true,
+ }),
+ ).toBe(2);
+ });
+});
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/getVisibleItemCount.ts b/packages/twenty-ui/src/components/layout/OverflowingList/internal/getVisibleItemCount.ts
new file mode 100644
index 00000000000..30aaf40ff84
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/getVisibleItemCount.ts
@@ -0,0 +1,34 @@
+export const getVisibleItemCount = ({
+ itemWidths,
+ availableWidth,
+ gap,
+ includePartialItem,
+}: {
+ itemWidths: number[];
+ availableWidth: number;
+ gap: number;
+ includePartialItem: boolean;
+}) => {
+ let occupiedWidth = 0;
+ let visibleItemCount = 0;
+
+ for (const itemWidth of itemWidths) {
+ const nextOccupiedWidth =
+ occupiedWidth + itemWidth + (visibleItemCount > 0 ? gap : 0);
+
+ const shouldKeepFirstItemVisible = visibleItemCount === 0;
+
+ if (!shouldKeepFirstItemVisible && nextOccupiedWidth > availableWidth) {
+ const partialItemFits = occupiedWidth + gap < availableWidth;
+
+ return includePartialItem && partialItemFits
+ ? visibleItemCount + 1
+ : visibleItemCount;
+ }
+
+ occupiedWidth = nextOccupiedWidth;
+ visibleItemCount += 1;
+ }
+
+ return visibleItemCount;
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureItemWidths.ts b/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureItemWidths.ts
new file mode 100644
index 00000000000..032084e140f
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/measureItemWidths.ts
@@ -0,0 +1,19 @@
+export const measureItemWidths = ({
+ items,
+ itemElements,
+ supportsSynchronousLayout,
+}: {
+ items: HTMLElement;
+ itemElements: Element[];
+ supportsSynchronousLayout: boolean;
+}) => {
+ if (!supportsSynchronousLayout) {
+ return itemElements.map((item) => item.scrollWidth);
+ }
+
+ items.setAttribute('data-measuring', '');
+ const naturalItemWidths = itemElements.map((item) => item.clientWidth);
+ items.removeAttribute('data-measuring');
+
+ return naturalItemWidths;
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/useFocusedElementUnmountRef.ts b/packages/twenty-ui/src/components/layout/OverflowingList/internal/useFocusedElementUnmountRef.ts
new file mode 100644
index 00000000000..527563ead6a
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/useFocusedElementUnmountRef.ts
@@ -0,0 +1,21 @@
+import { useCallback } from 'react';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+export const useFocusedElementUnmountRef = (
+ onFocusedElementUnmount: () => void,
+) =>
+ useCallback(
+ (element: HTMLElement | null) => {
+ if (!isDefined(element)) {
+ return;
+ }
+
+ return () => {
+ if (element.contains(element.ownerDocument.activeElement)) {
+ onFocusedElementUnmount();
+ }
+ };
+ },
+ [onFocusedElementUnmount],
+ );
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/internal/useOverflowingListLayout.ts b/packages/twenty-ui/src/components/layout/OverflowingList/internal/useOverflowingListLayout.ts
new file mode 100644
index 00000000000..36428828b7f
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/internal/useOverflowingListLayout.ts
@@ -0,0 +1,136 @@
+import { useLayoutEffect, useRef, useState } from 'react';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import { getVisibleItemCount } from './getVisibleItemCount';
+import { measureItemWidths } from './measureItemWidths';
+
+const FALLBACK_MEASUREMENT_INTERVAL_MS = 100;
+
+export const useOverflowingListLayout = ({
+ itemCount,
+ inlineItemCount,
+ reserveCountSpace,
+ isMeasurementEnabled,
+}: {
+ itemCount: number;
+ inlineItemCount: number;
+ reserveCountSpace: boolean;
+ isMeasurementEnabled: boolean;
+}) => {
+ const containerRef = useRef<HTMLDivElement>(null);
+ const itemsRef = useRef<HTMLDivElement>(null);
+ const triggerRef = useRef<HTMLButtonElement>(null);
+ const measureRef = useRef<() => void>(undefined);
+ const layoutInputRef = useRef({ itemCount, reserveCountSpace });
+ const [visibleItemCount, setVisibleItemCount] = useState(inlineItemCount);
+ const [hasOverflow, setHasOverflow] = useState(itemCount > inlineItemCount);
+
+ useLayoutEffect(() => {
+ layoutInputRef.current = { itemCount, reserveCountSpace };
+ measureRef.current?.();
+ }, [itemCount, inlineItemCount, reserveCountSpace]);
+
+ useLayoutEffect(() => {
+ const container = containerRef.current;
+ const items = itemsRef.current;
+
+ if (!isMeasurementEnabled || !isDefined(container) || !isDefined(items)) {
+ return;
+ }
+
+ const supportsSynchronousLayout = isDefined(globalThis.ResizeObserver);
+ const observedElements = new Set<Element>();
+ const measure = () => {
+ const itemElements = Array.from(items.children);
+ const currentElements = new Set<Element>([container, ...itemElements]);
+
+ if (isDefined(triggerRef.current)) {
+ currentElements.add(triggerRef.current);
+ }
+
+ for (const element of observedElements) {
+ if (!currentElements.has(element)) {
+ observer?.unobserve(element);
+ observedElements.delete(element);
+ }
+ }
+
+ for (const element of currentElements) {
+ if (!observedElements.has(element)) {
+ observer?.observe(element);
+ observedElements.add(element);
+ }
+ }
+
+ const latestLayoutInput = layoutInputRef.current;
+ const itemWidths = measureItemWidths({
+ items,
+ itemElements,
+ supportsSynchronousLayout,
+ });
+ const gap = parseFloat(getComputedStyle(items).columnGap) || 0;
+ const containerWidth = container.clientWidth;
+ const fittedItemCount = getVisibleItemCount({
+ itemWidths,
+ availableWidth: containerWidth,
+ gap,
+ includePartialItem: false,
+ });
+ const nextHasOverflow = latestLayoutInput.itemCount > fittedItemCount;
+ const triggerWidth = triggerRef.current?.offsetWidth ?? 0;
+ const availableWidth =
+ latestLayoutInput.reserveCountSpace && nextHasOverflow
+ ? Math.max(0, containerWidth - triggerWidth - gap)
+ : containerWidth;
+
+ setHasOverflow(nextHasOverflow);
+ setVisibleItemCount(
+ getVisibleItemCount({
+ itemWidths,
+ availableWidth,
+ gap,
+ includePartialItem: !latestLayoutInput.reserveCountSpace,
+ }),
+ );
+ };
+
+ const observer = supportsSynchronousLayout
+ ? new ResizeObserver(measure)
+ : undefined;
+
+ measureRef.current = measure;
+ measure();
+
+ const contentObserver = new MutationObserver(measure);
+ contentObserver.observe(items, {
+ attributes: true,
+ attributeFilter: ['class', 'style', 'hidden'],
+ characterData: true,
+ childList: true,
+ subtree: true,
+ });
+
+ contentObserver.observe(container, { childList: true });
+
+ if (!isDefined(observer)) {
+ const interval = setInterval(measure, FALLBACK_MEASUREMENT_INTERVAL_MS);
+ window.addEventListener('resize', measure);
+
+ return () => {
+ measureRef.current = undefined;
+ clearInterval(interval);
+ contentObserver.disconnect();
+ window.removeEventListener('resize', measure);
+ };
+ }
+
+ return () => {
+ measureRef.current = undefined;
+ contentObserver.disconnect();
+ observer.disconnect();
+ };
+ }, [isMeasurementEnabled]);
+
+ return { containerRef, itemsRef, triggerRef, visibleItemCount, hasOverflow };
+};
diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/types/OverflowingListProps.ts b/packages/twenty-ui/src/components/layout/OverflowingList/types/OverflowingListProps.ts
new file mode 100644
index 00000000000..dfd0885a6b3
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/OverflowingList/types/OverflowingListProps.ts
@@ -0,0 +1,11 @@
+import { type ComponentPropsWithRef, type ReactElement } from 'react';
+
+export type OverflowingListProps = Omit<
+ ComponentPropsWithRef<'div'>,
+ 'children'
+> & {
+ children: ReactElement[];
+ showOverflowCount?: boolean;
+ maxInlineCount?: number;
+ overflowLabel?: string;
+};