The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Simplify Tag and Status composition (#27681)
Raphaël Bosifb30e6003374
diff --git a/packages/twenty-docs/snippets/ui/generated/data-display/status.mdx b/packages/twenty-docs/snippets/ui/generated/data-display/status.mdxindex 659cfe45a78..a7ce76fd1b4 100644--- a/packages/twenty-docs/snippets/ui/generated/data-display/status.mdx+++ b/packages/twenty-docs/snippets/ui/generated/data-display/status.mdx@@ -15,24 +15,16 @@Theme color used for the status background, text, and loader.</ParamField>-<ParamField body="disabled" type="boolean" default="false">- Applies disabled styling and disables activation when `onClick` is supplied.-</ParamField>-<ParamField body="loading" type="boolean" default="false">- Shows a loader after the label. Does not disable the control or announce a status change by itself.-</ParamField>--<ParamField body="nativeButton" type="boolean" default="true">- Set to `false` when using `render` with an element other than a native button.+ Shows a decorative loader after the label and defaults aria-busy to true. The caller owns announcements and disabled interaction.</ParamField>-<ParamField body="onClick" type="MouseEventHandler<HTMLButtonElement> | MouseEventHandler<HTMLElement>">- Handles activation and renders a native button by default. Without it, the default element is a span.+<ParamField body="onClick" type="MouseEventHandler<HTMLSpanElement>">+ Native click handler. Does not change the default span or add keyboard activation.</ParamField>-<ParamField body="render" type="NonNullable<ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}> | undefined>">- Replaces the default element. Required when `nativeButton` is `false`.+<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, StatusState>">+ Replaces the default span. Compose a button or link to provide explicit interaction semantics.</ParamField><ParamField body="weight" type=""medium" | "regular"" default="regular">diff --git a/packages/twenty-docs/snippets/ui/generated/data-display/tag.mdx b/packages/twenty-docs/snippets/ui/generated/data-display/tag.mdxindex 1ff7d0fd45b..8d1ec227268 100644--- a/packages/twenty-docs/snippets/ui/generated/data-display/tag.mdx+++ b/packages/twenty-docs/snippets/ui/generated/data-display/tag.mdx@@ -19,33 +19,22 @@Theme color for the tag, or `transparent` for an unfilled label.</ParamField>-<ParamField body="disabled" type="boolean" default="false">- Applies disabled styling and prevents pointer and keyboard activation.+<ParamField body="onClick" type="MouseEventHandler<HTMLSpanElement>">+ Native click handler. Does not change the default span or add keyboard activation.</ParamField>-<ParamField body="nativeButton" type="boolean" default="true">- Set to `false` when a clickable tag uses `render` with an element other than a native button.-</ParamField>--<ParamField body="preventPadding" type="boolean" default="false">- Removes the tag padding.-</ParamField>--<ParamField body="preventShrink" type="boolean" default="false">- Keeps the tag from shrinking and disables string-label truncation and its tooltip.-</ParamField>--<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>">- Allows you to replace the component's HTML element- with a different tag, or compose it with another component.-- Accepts a `ReactElement` or a function that returns the element to render.+<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TagState>">+ Replaces the default span. Compose a button or link to provide explicit interaction semantics.</ParamField><ParamField body="startIcon" type="ReactNode">Decorative icon before the label. Hidden from assistive technology.</ParamField>+<ParamField body="truncate" type="boolean" default="true">+ Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to show the full label without a tooltip.+</ParamField>+<ParamField body="variant" type=""ghost" | "outline" | "soft" | "solid"" default="soft">Visual treatment of the tag background and border.</ParamField>diff --git a/packages/twenty-docs/ui/primitives/data-display/status.mdx b/packages/twenty-docs/ui/primitives/data-display/status.mdxindex df0925441a3..7aa0aaf1017 100644--- a/packages/twenty-docs/ui/primitives/data-display/status.mdx+++ b/packages/twenty-docs/ui/primitives/data-display/status.mdx@@ -22,7 +22,7 @@ import { Status } from 'twenty-ui/primitives/data-display';export const RecordStatus = () => <Status color="green">Active</Status>;```-`color` is required and uses the theme palette. The label communicates the meaning independently of the color. The default element is a `span`; `weight="medium"` emphasizes its text.+`color` is required and uses the theme palette. The label communicates the meaning independently of the color. The default element is always a `span`, including when a native click handler is supplied; `weight="medium"` emphasizes its text.## Loading and announcements@@ -40,7 +40,7 @@ export const SaveStatus = ({ isSaving }: SaveStatusProps) => ();```-`loading` shows a loader after the label. The component does not add a live region or change its text automatically. Keep a `role="status"` container mounted when updates should be announced to assistive technology, and provide a label that describes the current state.+`loading` shows a decorative loader after the label and defaults `aria-busy` to `true`. Supply `aria-busy` explicitly when the surrounding workflow owns that state. The component does not add a live region or change its text automatically. Keep a `role="status"` container mounted when updates should be announced to assistive technology, and provide a label that describes the current state.## Change a state@@ -59,16 +59,21 @@ export const ChangeStatusAction = ({<Statuscolor="blue"loading={isUpdating}- disabled={isUpdating}- onClick={onChangeStatus}- aria-label="Change record status"+ render={+ <button+ type="button"+ disabled={isUpdating}+ onClick={onChangeStatus}+ aria-label="Change record status"+ />+ }>{isUpdating ? 'Updating' : 'In progress'}</Status>);```-`onClick` renders a native button with pointer, Enter, and Space activation. `loading` does not prevent repeat activation; pass `disabled` when the action should wait. If `render` replaces the button with a non-button element, set `nativeButton={false}`.+Compose an interactive owner through `render`. Put its click handler, native attributes, ref, and disabled state on that owner. A real button supplies focus, pointer, Enter, and Space activation. `Status.loading` displays progress; pass `disabled` to the button when the action should wait. For navigation, render a link with its destination, such as `<a href="/records" />`. Native owners retain Status's appearance. Node children preserve caller-owned text, translations, and intentional links.## Propsdiff --git a/packages/twenty-docs/ui/primitives/data-display/tag.mdx b/packages/twenty-docs/ui/primitives/data-display/tag.mdxindex 3ce696e2fe6..5ac8b830ef9 100644--- a/packages/twenty-docs/ui/primitives/data-display/tag.mdx+++ b/packages/twenty-docs/ui/primitives/data-display/tag.mdx@@ -19,7 +19,7 @@ import { Tag } from 'twenty-ui/primitives/data-display';export const PriorityTag = () => <Tag color="red">Urgent</Tag>;```-`color` is required and accepts a theme color or `transparent`. The default element is a `span`. Add a decorative icon with `startIcon`; the label supplies its accessible meaning.+`color` is required and accepts a theme color or `transparent`. The default element is always a `span`, including when a native click handler is supplied. Add a decorative icon with `startIcon`; the label supplies its accessible meaning.## Variants@@ -60,19 +60,34 @@ export const CategoryFilter = ({ selected, onToggle }: CategoryFilterProps) => (<Tagcolor="blue"variant={selected ? 'solid' : 'outline'}- aria-pressed={selected}- onClick={onToggle}+ render={<button type="button" aria-pressed={selected} onClick={onToggle} />}>Customer</Tag>);```-Supplying `onClick` renders a button. Selection state belongs to your application; use `aria-pressed` for a toggle and a visible treatment for the selected state. `disabled` prevents pointer and keyboard activation. When `render` replaces an interactive tag with a non-button element, set `nativeButton={false}`.+Compose an interactive owner through `render`. Put its click handler, native attributes, ref, and disabled state on that owner. A real button supplies focus, Enter, and Space activation. Selection state belongs to your application; use `aria-pressed` for a toggle and a visible treatment for the selected state. For navigation, render a link with its destination, such as `<a href="/records" />`. Native owners retain Tag's appearance.## Long labels-By default, constrained string labels truncate and expose their full text in a tooltip on hover. `preventShrink` keeps the full label width and turns off that tooltip, so make sure the surrounding layout can accommodate it. `preventPadding` removes the horizontal padding for custom layouts.+By default, `truncate={true}` truncates constrained string labels and exposes their full text in a tooltip on hover. Set `truncate={false}` to display the full label without a tooltip. The surrounding layout still owns the available width.++```tsx+import { Tag } from 'twenty-ui/primitives/data-display';++export const FullCategoryLabel = () => (+ <Tag+ color="green"+ truncate={false}+ style={{ minWidth: 'fit-content', padding: 0 }}+ >+ Enterprise customer+ </Tag>+);+```++Use native styles for spacing and layout. This example keeps the full label width and removes padding. Node children remain caller-owned content, so compose their text, translations, and intentional links directly.## Propsdiff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsxindex 1d1b326fab4..7e17eceb8ac 100644--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx@@ -35,11 +35,9 @@ import {resetFrontComponentStoryMocks,} from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';import { type TwentyUiGalleryStory as Story } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryStory';-import {- statusControlsTest,- tagControlsTest,- chipControlsTest,-} from '@/__stories__/twenty-ui-gallery/utils/displayControlTests';+import { chipControlsTest } from '@/__stories__/twenty-ui-gallery/utils/displayControlTests';+import { statusControlsTest } from '@/__stories__/twenty-ui-gallery/utils/statusControlsTest';+import { tagControlsTest } from '@/__stories__/twenty-ui-gallery/utils/tagControlsTest';import { PortalBoundsDecorator } from '@/__stories__/twenty-ui-gallery/components/PortalBoundsDecorator';import { portalBoundsTest } from '@/__stories__/twenty-ui-gallery/utils/portalBoundsTest';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.mdindex 0c14cdaad97..83f716123ca 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md@@ -13,6 +13,8 @@ Popover composes Portal, Positioner, Popup, Arrow and Viewport. Its focused ReacTypography composition checks constrained text, explicit links, semantic elements, refs and native focus handlers in both runtimes. Overflow tooltip popup acceptance still depends on renderer portal and geometry support.+Tag and Status retain their presentational span when a native click handler is supplied. Their focused React/Preact fixtures check explicit native button/link composition, keyboard activation, disabled owners, refs, caller-owned links and native handlers. Tag checks positive truncation and native padding styles; Status checks controlled loading, caller-owned busy state and a decorative loader without an implicit live region.+Card composition checks native part props and DOM refs, customized anatomy, ordinary display semantics, independent nested controls, button keyboard activation and disabled state, and explicit link ownership in both runtimes.AvatarGroup checks derived counts, partially loaded totals, custom overflow and surviving keyed child state. Its native button and link (`target="_blank"`) verify refs, focus and pointer/keyboard activation in React and Preact.@@ -39,6 +41,8 @@ effect within the interaction timeout.| `twenty-ui-display-helpers` | Text || `twenty-ui-avatar-controls` | Avatar (stable presentational root, compound fallback, refs, explicit button/link composition and native keyboard/disabled behavior) || `twenty-ui-avatar-group` | AvatarGroup (derived and partial totals, custom overflow, keyed child state, native refs and explicit button/link composition) |+| `twenty-ui-tag-controls` | Tag (stable presentational root, positive truncation, native spacing, node content, refs and explicit button/link composition) |+| `twenty-ui-status-controls` | Status (stable presentational root, loading/busy state, node content, refs and explicit button/link composition) || `twenty-ui-avatar-image` | Avatar Root/Image/Fallback (image labels/attributes/refs, loading callbacks, decoded images, fallback, replacement and unmount/remount) || `twenty-ui-image-input` | ImageInput || `twenty-ui-list-item` | ListItem |diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-status-controls.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-status-controls.front-component.tsxindex 70d8c19fb1a..fd8bb095717 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-status-controls.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-status-controls.front-component.tsx@@ -1,6 +1,8 @@-import { useState } from 'react';+import { createElement, useState } from 'react';import { defineFrontComponent } from 'twenty-sdk/define';+import { isDefined } from 'twenty-shared/utils';import { Status } from 'twenty-ui/primitives/data-display';+import { Button } from 'twenty-ui/primitives/input';import { ThemeProvider } from 'twenty-ui/theme';import 'twenty-ui/style.css';@@ -8,6 +10,9 @@ import { ComponentGallery } from '../shared/front-components/component-gallery';const StatusControls = () => {const [activations, setActivations] = useState(0);+ const [defaultActivations, setDefaultActivations] = useState(0);+ const [linkActivations, setLinkActivations] = useState(0);+ const [loading, setLoading] = useState(true);const handleClick = () => setActivations((count) => count + 1);return (<ThemeProvider colorScheme="light">@@ -17,22 +22,93 @@ const StatusControls = () => {{name: 'Status',node: (- <>- <Status color="green" onClick={handleClick}>+ <div+ style={{+ display: 'flex',+ flexWrap: 'wrap',+ alignItems: 'center',+ gap: 8,+ minWidth: 0,+ }}+ >+ <Status+ color="green"+ render={<button type="button" onClick={handleClick} />}+ ref={(element) => {+ if (isDefined(element)) {+ element.dataset.refTarget = 'status-button';+ }+ }}+ >Open status</Status>- <Status color="green" onClick={handleClick} disabled>+ <Status+ color="green"+ render={+ <button type="button" disabled onClick={handleClick} />+ }+ >Disabled status</Status>- <Status color="blue" loading>+ <Status+ color="blue"+ loading={loading}+ title="Loading status indicator"+ >Loading status</Status>- </>+ <Status+ color="purple"+ title="Default status with handler"+ onClick={() => setDefaultActivations((count) => count + 1)}+ ref={(element) => {+ if (isDefined(element)) {+ element.dataset.refTarget = 'default-status';+ }+ }}+ >+ Default status+ </Status>+ <Status+ color="blue"+ render={(props, state) =>+ createElement('a', {+ ...props,+ href: '#status-documentation',+ target: '_self',+ 'data-render-loading': state.loading,+ })+ }+ onClick={() => setLinkActivations((count) => count + 1)}+ ref={(element) => {+ if (isDefined(element)) {+ element.dataset.refTarget = 'status-link';+ }+ }}+ >+ Status documentation+ </Status>+ <Status color="gray">+ <a href="#status-records" target="_self">+ Intentional status link+ </a>+ </Status>+ <Status color="blue" loading aria-busy={false}>+ Caller-owned busy state+ </Status>+ </div>),},]}/><output aria-label="Activations">{activations}</output>+ <output aria-label="Default status activations">+ {defaultActivations}+ </output>+ <output aria-label="Status link activations">{linkActivations}</output>+ <Button onClick={() => setLoading(!loading)}>+ Toggle status loading+ </Button></ThemeProvider>);};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsxindex f9d9010a204..59bc33d1477 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx@@ -1,5 +1,6 @@import { useState } from 'react';import { defineFrontComponent } from 'twenty-sdk/define';+import { isDefined } from 'twenty-shared/utils';import { Tag } from 'twenty-ui/primitives/data-display';import { IconStar } from 'twenty-ui/icon';import { ThemeProvider } from 'twenty-ui/theme';@@ -9,6 +10,9 @@ import { ComponentGallery } from '../shared/front-components/component-gallery';const TagControls = () => {const [activations, setActivations] = useState(0);+ const [defaultActivations, setDefaultActivations] = useState(0);+ const [linkActivations, setLinkActivations] = useState(0);+ const [focuses, setFocuses] = useState(0);const handleClick = () => setActivations((count) => count + 1);return (<ThemeProvider colorScheme="light">@@ -18,26 +22,108 @@ const TagControls = () => {{name: 'Tag',node: (- <>+ <div+ style={{+ display: 'flex',+ flexWrap: 'wrap',+ alignItems: 'center',+ gap: 8,+ minWidth: 0,+ }}+ ><Tagcolor="blue"onClick={handleClick}+ onFocus={() => setFocuses((count) => count + 1)}startIcon={<IconStar />}+ ref={(element) => {+ if (isDefined(element)) {+ element.dataset.refTarget = 'tag-button';+ }+ }}+ render={+ <button+ type="button"+ ref={(element) => {+ if (isDefined(element)) {+ element.dataset.renderRefTarget = 'tag-button';+ }+ }}+ />+ }>Open tag</Tag>- <Tag color="blue" onClick={handleClick} disabled>+ <Tag+ color="blue"+ render={+ <button type="button" disabled onClick={handleClick} />+ }+ >Disabled tag</Tag><Tag color="green" variant="outline">Static tag</Tag>- </>+ <Tag+ color="purple"+ title="Default tag with handler"+ onClick={() => setDefaultActivations((count) => count + 1)}+ ref={(element) => {+ if (isDefined(element)) {+ element.dataset.refTarget = 'default-tag';+ }+ }}+ >+ Default tag+ </Tag>+ <Tag+ color="blue"+ render={+ <a+ href="#tag-documentation"+ target="_self"+ onClick={() => setLinkActivations((count) => count + 1)}+ ref={(element) => {+ if (isDefined(element)) {+ element.dataset.renderRefTarget = 'tag-link';+ }+ }}+ />+ }+ ref={(element) => {+ if (isDefined(element)) {+ element.dataset.refTarget = 'tag-link';+ }+ }}+ >+ Tag documentation+ </Tag>+ <Tag color="gray" truncate={false} style={{ padding: 0 }}>+ <a href="#tag-records" target="_self">+ Intentional tag link+ </a>+ </Tag>+ <Tag color="blue" title="Truncated tag" style={{ width: 100 }}>+ A long tag label that should truncate+ </Tag>+ <Tag+ color="blue"+ title="Full tag"+ truncate={false}+ style={{ minWidth: 'fit-content' }}+ >+ A long tag label shown in full+ </Tag>+ </div>),},]}/><output aria-label="Activations">{activations}</output>+ <output aria-label="Default tag activations">{defaultActivations}</output>+ <output aria-label="Tag link activations">{linkActivations}</output>+ <output aria-label="Tag focuses">{focuses}</output></ThemeProvider>);};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/displayControlTests.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/displayControlTests.tsindex 826b5c5e46c..c3bdda8127c 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/displayControlTests.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/displayControlTests.ts@@ -43,18 +43,6 @@ const createDisplayControlTest =await expect(canvas.getByLabelText('Activations')).toHaveTextContent('3');};-export const statusControlsTest = createDisplayControlTest({- buttonName: 'Open status',- disabledButtonName: 'Disabled status',- staticContent: 'Loading status',-});--export const tagControlsTest = createDisplayControlTest({- buttonName: 'Open tag',- disabledButtonName: 'Disabled tag',- staticContent: 'Static tag',-});-export const chipControlsTest = createDisplayControlTest({buttonName: 'Open chip',disabledButtonName: 'Disabled chip',diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/statusControlsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/statusControlsTest.tsnew file mode 100644index 00000000000..6dbee4e1397--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/statusControlsTest.ts@@ -0,0 +1,100 @@+import { expect, userEvent, waitFor, within } from 'storybook/test';++import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';+import { galleryRenderTest } from '@/__stories__/twenty-ui-gallery/utils/galleryRenderTests';++export const statusControlsTest: TwentyUiGalleryPlayFunction = async (+ context,+) => {+ await galleryRenderTest(context);+ const canvas = within(context.canvasElement);+ const defaultStatus = canvas.getByTitle('Default status with handler');++ expect(defaultStatus.tagName).toBe('SPAN');+ expect(defaultStatus).toHaveAttribute('data-ref-target', 'default-status');+ expect(defaultStatus).not.toHaveAttribute('role');+ expect(defaultStatus).not.toHaveAttribute('tabindex');+ expect(defaultStatus).not.toHaveAttribute('aria-live');+ expect(defaultStatus).not.toHaveAttribute('data-interactive');+ await userEvent.click(defaultStatus);+ await waitFor(() =>+ expect(+ canvas.getByLabelText('Default status activations'),+ ).toHaveTextContent('1'),+ );++ const button = canvas.getByRole('button', { name: 'Open status' });++ expect(button.tagName).toBe('BUTTON');+ expect(button).toHaveAttribute('data-ref-target', 'status-button');+ await userEvent.click(button);+ button.focus();+ await userEvent.keyboard('{Enter} ');+ await waitFor(() =>+ expect(canvas.getByLabelText('Activations')).toHaveTextContent('3'),+ );+ expect(button).toHaveFocus();++ const disabledButton = canvas.getByRole('button', {+ name: 'Disabled status',+ });++ expect(disabledButton).toBeDisabled();+ await userEvent.click(disabledButton);+ expect(canvas.getByLabelText('Activations')).toHaveTextContent('3');++ const link = canvas.getByRole('link', { name: 'Status documentation' });++ expect(link.tagName).toBe('A');+ expect(link).toHaveAttribute('href', '#status-documentation');+ expect(link).toHaveAttribute('target', '_self');+ expect(link).toHaveAttribute('data-ref-target', 'status-link');+ expect(link).toHaveAttribute('data-render-loading', 'false');+ button.focus();+ await userEvent.tab();+ expect(link).toHaveFocus();+ await userEvent.click(link);+ link.focus();+ await userEvent.keyboard('{Enter}');+ await waitFor(() =>+ expect(canvas.getByLabelText('Status link activations')).toHaveTextContent(+ '2',+ ),+ );+ expect(link).toHaveFocus();++ const nodeLink = canvas.getByRole('link', {+ name: 'Intentional status link',+ });++ expect(nodeLink).toHaveAttribute('href', '#status-records');+ expect(nodeLink.parentElement?.parentElement?.tagName).toBe('SPAN');++ const loadingStatus = canvas.getByTitle('Loading status indicator');++ expect(loadingStatus.tagName).toBe('SPAN');+ expect(loadingStatus).toHaveAttribute('aria-busy', 'true');+ expect(loadingStatus).not.toHaveAttribute('role');+ expect(loadingStatus).not.toHaveAttribute('aria-live');+ expect(loadingStatus.querySelector('[aria-hidden="true"]')).toBeVisible();+ expect(canvas.getByText('Loading status')).toBeVisible();+ expect(+ canvas.getByText('Caller-owned busy state').parentElement,+ ).toHaveAttribute('aria-busy', 'false');+ await userEvent.click(+ canvas.getByRole('button', { name: 'Toggle status loading' }),+ );+ await waitFor(() => {+ expect(loadingStatus).not.toHaveAttribute('aria-busy');+ expect(loadingStatus.querySelector('[aria-hidden="true"]')).toBeNull();+ });+ expect(canvas.getByText('Loading status')).toBeVisible();+ await userEvent.click(+ canvas.getByRole('button', { name: 'Toggle status loading' }),+ );+ await waitFor(() =>+ expect(loadingStatus).toHaveAttribute('aria-busy', 'true'),+ );+ expect(errorHandler).not.toHaveBeenCalled();+};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tagControlsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tagControlsTest.tsnew file mode 100644index 00000000000..06251a0b189--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tagControlsTest.ts@@ -0,0 +1,89 @@+import { expect, userEvent, waitFor, within } from 'storybook/test';++import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';+import { galleryRenderTest } from '@/__stories__/twenty-ui-gallery/utils/galleryRenderTests';++export const tagControlsTest: TwentyUiGalleryPlayFunction = async (context) => {+ await galleryRenderTest(context);+ const canvas = within(context.canvasElement);+ const defaultTag = canvas.getByTitle('Default tag with handler');++ expect(defaultTag.tagName).toBe('SPAN');+ expect(defaultTag).toHaveAttribute('data-ref-target', 'default-tag');+ expect(defaultTag).not.toHaveAttribute('role');+ expect(defaultTag).not.toHaveAttribute('tabindex');+ expect(defaultTag).not.toHaveAttribute('data-interactive');+ await userEvent.click(defaultTag);+ await waitFor(() =>+ expect(canvas.getByLabelText('Default tag activations')).toHaveTextContent(+ '1',+ ),+ );++ const button = canvas.getByRole('button', { name: 'Open tag' });++ expect(button.tagName).toBe('BUTTON');+ expect(button).toHaveAttribute('type', 'button');+ expect(button).toHaveAttribute('data-ref-target', 'tag-button');+ expect(button).toHaveAttribute('data-render-ref-target', 'tag-button');+ await userEvent.click(button);+ button.focus();+ await userEvent.keyboard('{Enter} ');+ await waitFor(() => {+ expect(canvas.getByLabelText('Activations')).toHaveTextContent('3');+ expect(canvas.getByLabelText('Tag focuses')).toHaveTextContent('1');+ });+ expect(button).toHaveFocus();++ const disabledButton = canvas.getByRole('button', { name: 'Disabled tag' });++ expect(disabledButton).toBeDisabled();+ await userEvent.click(disabledButton);+ expect(canvas.getByLabelText('Activations')).toHaveTextContent('3');++ const link = canvas.getByRole('link', { name: 'Tag documentation' });++ expect(link.tagName).toBe('A');+ expect(link).toHaveAttribute('href', '#tag-documentation');+ expect(link).toHaveAttribute('target', '_self');+ expect(link).toHaveAttribute('data-ref-target', 'tag-link');+ expect(link).toHaveAttribute('data-render-ref-target', 'tag-link');+ button.focus();+ await userEvent.tab();+ expect(link).toHaveFocus();+ await userEvent.click(link);+ link.focus();+ await userEvent.keyboard('{Enter}');+ await waitFor(() =>+ expect(canvas.getByLabelText('Tag link activations')).toHaveTextContent(+ '2',+ ),+ );+ expect(link).toHaveFocus();++ const nodeLink = canvas.getByRole('link', { name: 'Intentional tag link' });++ expect(nodeLink).toHaveAttribute('href', '#tag-records');+ expect(nodeLink.parentElement?.parentElement?.tagName).toBe('SPAN');+ expect(nodeLink.parentElement?.parentElement).toHaveStyle({ padding: '0px' });+ expect(canvas.getByText('Static tag')).toBeVisible();++ const truncatedText = canvas.getByText(+ 'A long tag label that should truncate',+ );+ const fullTag = canvas.getByTitle('Full tag');+ const fullText = canvas.getByText('A long tag label shown in full');++ await waitFor(() => {+ expect(getComputedStyle(truncatedText).textOverflow).toBe('ellipsis');+ expect(truncatedText.scrollWidth).toBeGreaterThan(+ truncatedText.clientWidth,+ );+ });+ expect(fullTag).not.toHaveAttribute('data-truncate');+ expect(getComputedStyle(fullText).textOverflow).toBe('clip');+ expect(fullText.scrollWidth).toBe(fullText.clientWidth);+ expect(fullText).not.toHaveAttribute('tabindex');+ expect(errorHandler).not.toHaveBeenCalled();+};diff --git a/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx b/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsxindex ff4710cebda..16abee64360 100644--- a/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx+++ b/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx@@ -48,6 +48,12 @@ const StyledHeaderRight = styled.div`gap: ${themeCssVariables.spacing[1]};`;+const StyledExecutionStatusTag = styled(Tag)`+ && {+ min-width: fit-content;+ }+`;+const StyledTitle = styled.span`color: ${themeCssVariables.font.color.primary};font-size: ${themeCssVariables.font.size.md};@@ -206,7 +212,7 @@ export const CodeExecutionDisplay = ({<StyledTitle>{t`Python Code Execution`}</StyledTitle></StyledHeaderLeft><StyledHeaderRight>- <Tag+ <StyledExecutionStatusTagcolor={status === 'success'? 'turquoise'@@ -215,10 +221,10 @@ export const CodeExecutionDisplay = ({: 'gray'}weight="medium"- preventShrink+ truncate={false}>{statusText}- </Tag>+ </StyledExecutionStatusTag></StyledHeaderRight></StyledHeader>diff --git a/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx b/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsxindex 417dbc47903..eea7eedbe34 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx@@ -25,6 +25,12 @@ const StyledContainer = styled.div`gap: ${themeCssVariables.spacing[2]};`;+const StyledAttemptsTag = styled(Tag)`+ && {+ min-width: fit-content;+ }+`;+export const SettingsAdminJobStateBadge = ({state,attemptsMade = 1,@@ -36,12 +42,12 @@ export const SettingsAdminJobStateBadge = ({<StyledContainer><Tag color={color}>{state}</Tag>{showAttempts && (- <Tag color="red" weight="medium" preventShrink>+ <StyledAttemptsTag color="red" weight="medium" truncate={false}>{plural(attemptsMade, {one: `${attemptsMade} attempt`,other: `${attemptsMade} attempts`,})}- </Tag>+ </StyledAttemptsTag>)}</StyledContainer>);diff --git a/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx b/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsxindex 5a34e15da70..966ed7e12c9 100644--- a/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx+++ b/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx@@ -5,7 +5,7 @@ import { BillingPlanKey } from '~/generated-metadata/graphql';import { styled } from '@linaria/react';import { themeCssVariables } from 'twenty-ui/theme';-export type PlansTagsProps = {+type PlansTagsProps = {plan: BillingPlanKey;isTrialPeriod?: boolean;};@@ -15,6 +15,12 @@ const StyledTagsWrapper = styled.div`gap: ${themeCssVariables.spacing[1]};`;+const StyledTrialTag = styled(Tag)`+ && {+ min-width: fit-content;+ }+`;+export const PlansTags = ({ plan, isTrialPeriod = false }: PlansTagsProps) => {const planDescriptor =plan === BillingPlanKey.PRO@@ -24,7 +30,11 @@ export const PlansTags = ({ plan, isTrialPeriod = false }: PlansTagsProps) => {return (<StyledTagsWrapper><Tag color={planDescriptor.color}>{planDescriptor.label}</Tag>- {isTrialPeriod && <Tag color="blue" preventShrink>{t`Trial`}</Tag>}+ {isTrialPeriod && (+ <StyledTrialTag color="blue" truncate={false}>+ {t`Trial`}+ </StyledTrialTag>+ )}</StyledTagsWrapper>);};diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsxindex 669c2c01627..c8678abf437 100644--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx@@ -13,6 +13,7 @@ import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableLiimport { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader/DropdownMenuHeader';import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent';import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';+import { styled } from '@linaria/react';import { t } from '@lingui/core/macro';import { isDefined } from 'twenty-shared/utils';import { MenuItemDraggable } from 'twenty-ui/components/navigation';@@ -21,6 +22,12 @@ import { Tag } from 'twenty-ui/primitives/data-display';import { type WidgetConfiguration } from '~/generated-metadata/graphql';import { moveArrayItem } from '~/utils/array/moveArrayItem';+const StyledOptionTag = styled(Tag)`+ && {+ min-width: fit-content;+ }+`;+type ChartManualSortSubMenuContentProps = {fieldMetadataItem: FieldMetadataItem;axis: 'primary' | 'secondary';@@ -104,9 +111,9 @@ export const ChartManualSortSubMenuContent = ({gripMode="always"isDragDisabled={sortedOptions.length === 1}text={- <Tag preventShrink color={option.color}>+ <StyledOptionTag truncate={false} color={option.color}>{option.label}- </Tag>+ </StyledOptionTag>}/>}diff --git a/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsxindex dbee38e9e7f..d05271c7962 100644--- a/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx+++ b/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx@@ -17,6 +17,12 @@ const StyledContainer = styled.div`width: 100%;`;+const StyledSelectedOptionTag = styled(Tag)`+ && {+ min-width: fit-content;+ }+`;+export const MultiSelectDisplay = ({values,options,@@ -35,8 +41,8 @@ export const MultiSelectDisplay = ({return (<StyledContainer className={className}>{selectedOptions.map((selectedOption, index) => (- <Tag- preventShrink+ <StyledSelectedOptionTag+ truncate={false}key={index}color={selectedOption.color ?? 'transparent'}startIcon={@@ -44,7 +50,7 @@ export const MultiSelectDisplay = ({}>{selectedOption.label}- </Tag>+ </StyledSelectedOptionTag>))}</StyledContainer>);diff --git a/packages/twenty-front/src/modules/ui/field/display/components/SelectDisplay/SelectDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/SelectDisplay/SelectDisplay.tsxindex 405aacd57ae..9d65bcf475d 100644--- a/packages/twenty-front/src/modules/ui/field/display/components/SelectDisplay/SelectDisplay.tsx+++ b/packages/twenty-front/src/modules/ui/field/display/components/SelectDisplay/SelectDisplay.tsx@@ -1,3 +1,4 @@+import { styled } from '@linaria/react';import { type IconComponent } from 'twenty-ui/icon';import { Tag } from 'twenty-ui/primitives/data-display';import { type ThemeColor } from 'twenty-ui/theme';@@ -7,21 +8,20 @@ type SelectDisplayProps = {color: ThemeColor | 'transparent';label: string;Icon?: IconComponent;- preventPadding?: boolean;};-export const SelectDisplay = ({- color,- label,- Icon,- preventPadding,-}: SelectDisplayProps) => (- <Tag- preventShrink+const StyledSelectTag = styled(Tag)`+ && {+ min-width: fit-content;+ }+`;++export const SelectDisplay = ({ color, label, Icon }: SelectDisplayProps) => (+ <StyledSelectTag+ truncate={false}color={color}startIcon={isDefined(Icon) ? <Icon /> : undefined}- preventPadding={preventPadding}>{label}- </Tag>+ </StyledSelectTag>);diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.jsonindex 652cc2e5f21..a6b1f4ecc8f 100644--- a/packages/twenty-ui/docs/public-exports.json+++ b/packages/twenty-ui/docs/public-exports.json@@ -744,8 +744,10 @@"ColorSampleProps": "primitives/data-display/ColorSample/types/ColorSampleProps","ColorSampleVariant": "primitives/data-display/ColorSample/types/ColorSampleVariant","StatusProps": "primitives/data-display/Status/types/StatusProps",+ "StatusState": "primitives/data-display/Status/types/StatusState","TagColor": "primitives/data-display/Tag/types/TagColor",- "TagProps": "primitives/data-display/Tag/types/TagProps"+ "TagProps": "primitives/data-display/Tag/types/TagProps",+ "TagState": "primitives/data-display/Tag/types/TagState"}},"primitives/feedback": {diff --git a/packages/twenty-ui/docs/statusPropDescriptions.ts b/packages/twenty-ui/docs/statusPropDescriptions.tsindex 072d4d39e0c..0534dd515c5 100644--- a/packages/twenty-ui/docs/statusPropDescriptions.ts+++ b/packages/twenty-ui/docs/statusPropDescriptions.ts@@ -3,14 +3,10 @@ import { type StatusProps } from '../src/primitives/data-display/Status/types/Stexport const STATUS_PROP_DESCRIPTIONS = {color: 'Theme color used for the status background, text, and loader.',weight: 'Font weight of the label.',- disabled:- 'Applies disabled styling and disables activation when `onClick` is supplied.',loading:- 'Shows a loader after the label. Does not disable the control or announce a status change by itself.',+ 'Shows a decorative loader after the label and defaults aria-busy to true. The caller owns announcements and disabled interaction.',onClick:- 'Handles activation and renders a native button by default. Without it, the default element is a span.',- nativeButton:- 'Set to `false` when using `render` with an element other than a native button.',+ 'Native click handler. Does not change the default span or add keyboard activation.',render:- 'Replaces the default element. Required when `nativeButton` is `false`.',+ 'Replaces the default span. Compose a button or link to provide explicit interaction semantics.',} satisfies Partial<Record<keyof StatusProps, string>>;diff --git a/packages/twenty-ui/docs/tagPropDescriptions.ts b/packages/twenty-ui/docs/tagPropDescriptions.tsindex bfb231da903..bda295874c0 100644--- a/packages/twenty-ui/docs/tagPropDescriptions.ts+++ b/packages/twenty-ui/docs/tagPropDescriptions.ts@@ -3,15 +3,14 @@ import { type TagProps } from '../src/primitives/data-display/Tag/types/TagPropsexport const TAG_PROP_DESCRIPTIONS = {color: 'Theme color for the tag, or `transparent` for an unfilled label.',weight: 'Font weight of the label.',- disabled:- 'Applies disabled styling and prevents pointer and keyboard activation.',- nativeButton:- 'Set to `false` when a clickable tag uses `render` with an element other than a native button.',variant: 'Visual treatment of the tag background and border.',startIcon:'Decorative icon before the label. Hidden from assistive technology.',- preventShrink:- 'Keeps the tag from shrinking and disables string-label truncation and its tooltip.',- preventPadding: 'Removes the tag padding.',+ truncate:+ 'Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to show the full label without a tooltip.',borderStyle: 'Border style used by the outline variant.',+ render:+ 'Replaces the default span. Compose a button or link to provide explicit interaction semantics.',+ onClick:+ 'Native click handler. Does not change the default span or add keyboard activation.',} satisfies Partial<Record<keyof TagProps, string>>;diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex fe7b43902d6..7525bf6e859 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -9631,39 +9631,18 @@"description": "Theme color for the tag, or `transparent` for an unfilled label."},{- "name": "disabled",- "type": "boolean",- "required": false,- "defaultValue": "false",- "description": "Applies disabled styling and prevents pointer and keyboard activation."- },- {- "name": "nativeButton",- "type": "boolean",- "required": false,- "defaultValue": "true",- "description": "Set to `false` when a clickable tag uses `render` with an element other than a native button."- },- {- "name": "preventPadding",- "type": "boolean",- "required": false,- "defaultValue": "false",- "description": "Removes the tag padding."- },- {- "name": "preventShrink",- "type": "boolean",+ "name": "onClick",+ "type": "MouseEventHandler<HTMLSpanElement>","required": false,- "defaultValue": "false",- "description": "Keeps the tag from shrinking and disables string-label truncation and its tooltip."+ "defaultValue": null,+ "description": "Native click handler. Does not change the default span or add keyboard activation."},{"name": "render",- "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TagState>","required": false,"defaultValue": null,- "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ "description": "Replaces the default span. Compose a button or link to provide explicit interaction semantics."},{"name": "startIcon",@@ -9672,6 +9651,13 @@"defaultValue": null,"description": "Decorative icon before the label. Hidden from assistive technology."},+ {+ "name": "truncate",+ "type": "boolean",+ "required": false,+ "defaultValue": "true",+ "description": "Truncates constrained string labels and exposes the full text in a tooltip. Set to `false` to show the full label without a tooltip."+ },{"name": "variant","type": "\"ghost\" | \"outline\" | \"soft\" | \"solid\"",@@ -9700,40 +9686,26 @@"defaultValue": null,"description": "Theme color used for the status background, text, and loader."},- {- "name": "disabled",- "type": "boolean",- "required": false,- "defaultValue": "false",- "description": "Applies disabled styling and disables activation when `onClick` is supplied."- },{"name": "loading","type": "boolean","required": false,"defaultValue": "false",- "description": "Shows a loader after the label. Does not disable the control or announce a status change by itself."- },- {- "name": "nativeButton",- "type": "boolean",- "required": false,- "defaultValue": "true",- "description": "Set to `false` when using `render` with an element other than a native button."+ "description": "Shows a decorative loader after the label and defaults aria-busy to true. The caller owns announcements and disabled interaction."},{"name": "onClick",- "type": "MouseEventHandler<HTMLButtonElement> | MouseEventHandler<HTMLElement>",+ "type": "MouseEventHandler<HTMLSpanElement>","required": false,"defaultValue": null,- "description": "Handles activation and renders a native button by default. Without it, the default element is a span."+ "description": "Native click handler. Does not change the default span or add keyboard activation."},{"name": "render",- "type": "NonNullable<ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}> | undefined>",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, StatusState>","required": false,"defaultValue": null,- "description": "Replaces the default element. Required when `nativeButton` is `false`."+ "description": "Replaces the default span. Compose a button or link to provide explicit interaction semantics."},{"name": "weight",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.tsxindex e6832d71745..440b6d4abe9 100644--- 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@@ -6,7 +6,12 @@ export const OVERFLOWING_LIST_STORY_ITEMS = ['Priority','Renewal',].map((label) => (- <Tag key={label} color="blue" preventShrink style={{ width: 80 }}>+ <Tag+ key={label}+ color="blue"+ truncate={false}+ style={{ width: 80, minWidth: 'fit-content' }}+ >{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.tsxindex 421fe995cbe..b40e7bc32c3 100644--- 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@@ -542,7 +542,12 @@ export const DescendantContentUpdates: Story = {style: { width: 200 },children: [<OverflowingListMutableTag key="customer" />,- <Tag key="partner" color="green" preventShrink>+ <Tag+ key="partner"+ color="green"+ truncate={false}+ style={{ minWidth: 'fit-content' }}+ >Partner</Tag>,],diff --git a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsxindex e766cc54f3e..ca36175dff1 100644--- a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListMutableTag.tsx@@ -8,9 +8,15 @@ export const OverflowingListMutableTag = () => {return (<Tagcolor="blue"- preventShrink- aria-label="Toggle tag label"- onClick={() => setHasLongLabel(!hasLongLabel)}+ truncate={false}+ style={{ minWidth: 'fit-content' }}+ render={+ <button+ type="button"+ 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.tsxindex 37611c86c84..72d0aa3913f 100644--- a/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx+++ b/packages/twenty-ui/src/components/layout/OverflowingList/__stories__/OverflowingListResizeExample.tsx@@ -18,7 +18,12 @@ export const OverflowingListResizeExample = () => {style={{ width: isNarrow ? 100 : 360 }}>{['Customer', 'Partner', 'Priority', 'Renewal'].map((label) => (- <Tag key={label} color="blue" preventShrink>+ <Tag+ key={label}+ color="blue"+ truncate={false}+ style={{ minWidth: 'fit-content' }}+ >{hasLongLabels ? `${label} with a longer label` : label}</Tag>))}diff --git a/packages/twenty-ui/src/primitives/data-display/Status/Status.module.scss b/packages/twenty-ui/src/primitives/data-display/Status/Status.module.scssindex 581b29640f4..ed8cb032fb8 100644--- a/packages/twenty-ui/src/primitives/data-display/Status/Status.module.scss+++ b/packages/twenty-ui/src/primitives/data-display/Status/Status.module.scss@@ -6,10 +6,11 @@&[data-weight='medium'] {font-weight: var(--t-font-weight-medium);}- &[data-interactive] {+ &:is(button, a, [role='button'], [role='link']) {cursor: pointer;}- &[data-disabled] {+ &:disabled,+ &[aria-disabled='true'] {cursor: not-allowed;opacity: 0.5;}diff --git a/packages/twenty-ui/src/primitives/data-display/Status/Status.tsx b/packages/twenty-ui/src/primitives/data-display/Status/Status.tsxindex bcf68cc88ac..49804e98932 100644--- a/packages/twenty-ui/src/primitives/data-display/Status/Status.tsx+++ b/packages/twenty-ui/src/primitives/data-display/Status/Status.tsx@@ -1,4 +1,3 @@-import { Button as ButtonPrimitive } from '@base-ui/react/button';import { useRender } from '@base-ui/react/use-render';import { clsx } from 'clsx';import { type CSSProperties } from 'react';@@ -6,7 +5,6 @@ import { type CSSProperties } from 'react';import { Loader } from '@ui/primitives/feedback/Loader/Loader';import { themeCssVariables } from '@ui/theme';import { parseThemeColor } from '@ui/utilities';-import { isDefined } from '@ui/utilities/utils/isDefined';import styles from './Status.module.scss';import { type StatusProps } from './types/StatusProps';@@ -16,9 +14,6 @@ export const Status = ({color,loading = false,weight = 'regular',- disabled = false,- nativeButton = true,- onClick,className,style,render,@@ -29,20 +24,12 @@ export const Status = ({return useRender({defaultTagName: 'span',- render: isDefined(onClick) ? (- <ButtonPrimitive- render={render}- disabled={disabled}- nativeButton={nativeButton}- />- ) : (- render- ),+ render,ref,- state: { loading, weight, disabled, interactive: isDefined(onClick) },+ state: { loading, weight },props: {+ 'aria-busy': loading || undefined,...props,- onClick,className: clsx(styles.status, className),style: {'--tw-status-background': themeCssVariables.tag.background[parsedColor],@@ -52,7 +39,9 @@ export const Status = ({children: (<><span className={styles.content}>{children}</span>- {loading && <Loader color={color} />}+ {loading && (+ <Loader color={color} aria-hidden="true" render={<span />} />+ )}</>),},diff --git a/packages/twenty-ui/src/primitives/data-display/Status/__stories__/Status.stories.tsx b/packages/twenty-ui/src/primitives/data-display/Status/__stories__/Status.stories.tsxindex b6fa556ac05..02faf78dd17 100644--- a/packages/twenty-ui/src/primitives/data-display/Status/__stories__/Status.stories.tsx+++ b/packages/twenty-ui/src/primitives/data-display/Status/__stories__/Status.stories.tsx@@ -25,17 +25,8 @@ type Story = StoryObj<typeof Status>;export const Default: Story = {args: {color: 'red',- onClick: fn(),},decorators: [ComponentDecorator],- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);-- const status = canvas.getByRole('button', { name: 'Urgent' });-- await userEvent.click(status);- expect(args.onClick).toHaveBeenCalled();- },};export const Documentation: Story = {@@ -55,6 +46,37 @@ export const WithLongText: Story = {},};+export const Loading: Story = {+ ...Default,+ args: {+ children: 'Saving',+ color: 'blue',+ loading: true,+ },+};++export const LoadingAccessibility: Story = {+ ...Loading,+ args: {+ ...Loading.args,+ title: 'Save progress',+ ref: fn(),+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const status = canvas.getByTitle('Save progress');++ await expect(status.tagName).toBe('SPAN');+ await expect(status).toHaveAttribute('aria-busy', 'true');+ await expect(status).not.toHaveAttribute('role');+ await expect(status).not.toHaveAttribute('aria-live');+ await expect(canvas.getByText('Saving')).toBeVisible();+ await expect(canvas.queryByRole('status')).not.toBeInTheDocument();+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();+ await expect(args.ref).toHaveBeenCalledWith(status);+ },+};+export const Catalog: CatalogStory<Story, typeof Status> = {argTypes: {color: { control: false },@@ -87,7 +109,16 @@ export const CatalogDark: typeof Catalog = {export const PointerAndKeyboard: Story = {decorators: [ComponentDecorator],- args: { children: 'Open details', onClick: fn(), color: 'blue' },+ args: {+ children: 'Open details',+ onClick: fn(),+ ref: fn(),+ color: 'blue',+ style: { padding: 0 },+ },+ render: ({ onClick, ...args }) => (+ <Status {...args} render={<button type="button" onClick={onClick} />} />+ ),play: async ({ canvasElement, args }) => {const control = within(canvasElement).getByRole('button', {name: 'Open details',@@ -97,6 +128,8 @@ export const PointerAndKeyboard: Story = {await userEvent.keyboard(' ');await expect(args.onClick).toHaveBeenCalledTimes(3);await expect(control).toHaveFocus();+ await expect(args.ref).toHaveBeenCalledWith(control);+ await expect(getComputedStyle(control).padding).toBe('0px');await expect(args.onClick).toHaveBeenLastCalledWith(expect.objectContaining({ type: 'click' }),);@@ -107,16 +140,111 @@ export const Disabled: Story = {decorators: [ComponentDecorator],args: {children: 'Unavailable',- disabled: true,+ loading: true,onClick: fn(),color: 'blue',},+ render: ({ onClick, ...args }) => (+ <Status+ {...args}+ render={<button type="button" disabled onClick={onClick} />}+ />+ ),play: async ({ canvasElement, args }) => {const control = within(canvasElement).getByRole('button', {name: 'Unavailable',});await expect(control).toBeDisabled();+ await expect(control).toHaveAttribute('aria-busy', 'true');await userEvent.click(control);await expect(args.onClick).not.toHaveBeenCalled();},};++export const RenderCallback: Story = {+ ...PointerAndKeyboard,+ render: ({ onClick, ...args }) => (+ <Status+ {...args}+ render={(props) => <button {...props} type="button" onClick={onClick} />}+ />+ ),+};++export const DefaultSemantics: Story = {+ ...Default,+ args: {+ ...Default.args,+ title: 'Record state',+ onClick: fn(),+ ref: fn(),+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const status = canvas.getByTitle('Record state');++ await expect(status.tagName).toBe('SPAN');+ await expect(status).not.toHaveAttribute('role');+ await expect(status).not.toHaveAttribute('tabindex');+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();+ await expect(args.ref).toHaveBeenCalledWith(status);+ await userEvent.click(status);+ await expect(args.onClick).toHaveBeenCalledOnce();+ },+};++export const LoadingInteraction: Story = {+ ...PointerAndKeyboard,+ args: {+ ...PointerAndKeyboard.args,+ loading: true,+ },+ play: async ({ canvasElement, args }) => {+ const button = within(canvasElement).getByRole('button', {+ name: 'Open details',+ });++ await expect(button).toBeEnabled();+ await expect(button).toHaveAttribute('aria-busy', 'true');+ await userEvent.click(button);+ await expect(args.onClick).toHaveBeenCalledOnce();+ },+};++export const Navigation: Story = {+ ...PointerAndKeyboard,+ args: {+ ...PointerAndKeyboard.args,+ children: 'Active records',+ onClick: fn((event) => event.preventDefault()),+ },+ render: ({ onClick, ...args }) => (+ <Status+ {...args}+ render={(props) => (+ <a+ {...props}+ href="#active-records"+ referrerPolicy="no-referrer"+ onClick={onClick}+ >+ {props.children}+ </a>+ )}+ />+ ),+ play: async ({ canvasElement, args }) => {+ const link = within(canvasElement).getByRole('link', {+ name: 'Active records',+ });++ await expect(link.tagName).toBe('A');+ await expect(link).toHaveAttribute('href', '#active-records');+ await expect(link).toHaveAttribute('referrerpolicy', 'no-referrer');+ await expect(args.ref).toHaveBeenCalledWith(link);+ link.focus();+ await userEvent.keyboard('{Enter}');+ await expect(args.onClick).toHaveBeenCalledOnce();+ await expect(link).toHaveFocus();+ },+};diff --git a/packages/twenty-ui/src/primitives/data-display/Status/__tests__/Status.test.tsx b/packages/twenty-ui/src/primitives/data-display/Status/__tests__/Status.test.tsxindex 1243b817468..73447c5b6c2 100644--- a/packages/twenty-ui/src/primitives/data-display/Status/__tests__/Status.test.tsx+++ b/packages/twenty-ui/src/primitives/data-display/Status/__tests__/Status.test.tsx@@ -2,7 +2,7 @@ import { runComponentConformance } from '@test-utilities/conformance/runComponenimport { render, screen } from '@testing-library/react';import userEvent from '@testing-library/user-event';import { createRef } from 'react';-import { expectTypeOf, it, expect, vi } from 'vitest';+import { expect, it, vi } from 'vitest';import { ThemeProvider } from '@ui/theme/ThemeProvider';@@ -16,62 +16,92 @@ runComponentConformance({refInstanceOf: HTMLSpanElement,});-it('forwards native button props, refs, and click event targets', async () => {- const buttonRef = createRef<HTMLButtonElement>();+it('keeps a presentational span with native handlers and caller-owned content', async () => {+ const ref = createRef<HTMLSpanElement>();const handleClick = vi.fn();+ render(+ <ThemeProvider colorScheme="light">+ <Status color="green" ref={ref} onClick={handleClick}>+ <a href="#connection">Connected</a>+ </Status>+ </ThemeProvider>,+ );+ expect(ref.current).toBeInstanceOf(HTMLSpanElement);+ expect(ref.current).not.toHaveAttribute('role');+ expect(ref.current).not.toHaveAttribute('tabindex');+ expect(screen.queryByRole('button')).not.toBeInTheDocument();+ await userEvent.click(screen.getByRole('link', { name: 'Connected' }));+ expect(handleClick).toHaveBeenCalledOnce();+});++it('supports native link attributes and the root ref through callback composition', async () => {+ const ref = createRef<HTMLSpanElement>();+ const handleClick = vi.fn();render(<ThemeProvider colorScheme="light"><Statuscolor="blue"- name="connection"- type="button"- ref={buttonRef}- onClick={(event) => {- expectTypeOf(event.currentTarget).toEqualTypeOf<- EventTarget & HTMLButtonElement- >();- handleClick(event.currentTarget.name);- }}+ ref={ref}+ render={(props) => (+ <a+ {...props}+ href="#connection"+ download="connection.txt"+ onClick={handleClick}+ >+ {props.children}+ </a>+ )}>Connection details</Status></ThemeProvider>,);- const button = screen.getByRole('button', { name: 'Connection details' });- expect(buttonRef.current).toBe(button);- expect(buttonRef.current).toBeInstanceOf(HTMLButtonElement);- await userEvent.click(button);- expect(handleClick).toHaveBeenCalledWith('connection');+ const link = screen.getByRole('link', { name: 'Connection details' });+ expect(ref.current).toBe(link);+ expect(link).toHaveAttribute('download', 'connection.txt');+ await userEvent.tab();+ expect(link).toHaveFocus();+ await userEvent.keyboard('{Enter}');+ expect(handleClick).toHaveBeenCalledOnce();});-it('uses an HTMLElement contract for a custom non-native button', async () => {- const elementRef = createRef<HTMLElement>();- const handleClick = vi.fn();+it('exposes loading without introducing a live region and preserves caller accessibility overrides', () => {+ const ref = createRef<HTMLSpanElement>();+ const { rerender } = render(+ <ThemeProvider colorScheme="light">+ <Status color="blue" loading ref={ref}>+ Saving+ </Status>+ </ThemeProvider>,+ );- render(+ expect(ref.current).toHaveAttribute('aria-busy', 'true');+ expect(ref.current).not.toHaveAttribute('aria-live');+ expect(ref.current).not.toHaveAttribute('role');+ expect(+ ref.current?.querySelector('[aria-hidden="true"]'),+ ).toBeInTheDocument();+ expect(screen.getByText('Saving')).toBeVisible();++ rerender(<ThemeProvider colorScheme="light">- <Status- color="blue"- nativeButton={false}- render={<div />}- ref={elementRef}- onClick={(event) => {- expectTypeOf(event.currentTarget).toEqualTypeOf<- EventTarget & HTMLElement- >();- handleClick(event.currentTarget.tagName);- }}- >- Custom details+ <Status color="green" ref={ref}>+ Saved</Status></ThemeProvider>,);+ expect(ref.current).not.toHaveAttribute('aria-busy');+ expect(ref.current?.querySelector('[aria-hidden="true"]')).toBeNull();- const button = screen.getByRole('button', { name: 'Custom details' });- expect(elementRef.current).toBe(button);- expect(elementRef.current).toBeInstanceOf(HTMLDivElement);- await userEvent.click(button);- expect(handleClick).toHaveBeenCalledWith('DIV');+ rerender(+ <ThemeProvider colorScheme="light">+ <Status color="blue" loading aria-busy={false} role="status" ref={ref}>+ Syncing+ </Status>+ </ThemeProvider>,+ );+ expect(screen.getByRole('status')).toHaveAttribute('aria-busy', 'false');});diff --git a/packages/twenty-ui/src/primitives/data-display/Status/types/StatusProps.ts b/packages/twenty-ui/src/primitives/data-display/Status/types/StatusProps.tsindex 3da82d85d28..c4b1da263e6 100644--- a/packages/twenty-ui/src/primitives/data-display/Status/types/StatusProps.ts+++ b/packages/twenty-ui/src/primitives/data-display/Status/types/StatusProps.ts@@ -1,40 +1,13 @@import { type useRender } from '@base-ui/react/use-render';-import {- type HTMLAttributes,- type MouseEventHandler,- type RefAttributes,-} from 'react';import { type ThemeColor } from '@ui/theme';-type StatusOwnProps = {- color: ThemeColor;- weight?: 'regular' | 'medium';- disabled?: boolean;- loading?: boolean;-};+import { type StatusState } from './StatusState';-type StatusStaticProps = Omit<- useRender.ComponentProps<'span'>,- 'color' | 'onClick'-> & {- onClick?: undefined;- nativeButton?: true;-};--type StatusButtonProps = Omit<- useRender.ComponentProps<'button'>,- 'color' | 'onClick'-> & {- onClick: MouseEventHandler<HTMLButtonElement>;- nativeButton?: true;-};--type StatusCustomProps = Omit<HTMLAttributes<HTMLElement>, 'color'> &- RefAttributes<HTMLElement> & {- nativeButton: false;- render: NonNullable<useRender.ComponentProps<'span'>['render']>;+export type StatusProps = Omit<+ useRender.ComponentProps<'span', StatusState>,+ 'color'+> &+ Partial<StatusState> & {+ color: ThemeColor;};--export type StatusProps = StatusOwnProps &- (StatusStaticProps | StatusButtonProps | StatusCustomProps);diff --git a/packages/twenty-ui/src/primitives/data-display/Status/types/StatusState.ts b/packages/twenty-ui/src/primitives/data-display/Status/types/StatusState.tsnew file mode 100644index 00000000000..c5800e8bb49--- /dev/null+++ b/packages/twenty-ui/src/primitives/data-display/Status/types/StatusState.ts@@ -0,0 +1,4 @@+export type StatusState = {+ loading: boolean;+ weight: 'regular' | 'medium';+};diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss b/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scssindex d4d65a31388..3b8661dad35 100644--- a/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss+++ b/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss@@ -19,7 +19,7 @@min-inline-size: 0;text-align: inherit;- &[data-interactive] {+ &:is(button, a, [role='button'], [role='link']) {cursor: pointer;}&[data-weight='medium'] {@@ -35,21 +35,23 @@background: var(--tw-tag-text);color: var(--t-background-primary);}- &[data-prevent-shrink] {- min-inline-size: fit-content;- }- &[data-prevent-padding] {- padding: 0;- }- &[data-disabled] {+ &:disabled,+ &[aria-disabled='true'] {cursor: not-allowed;opacity: 0.5;}}.content {- overflow: hidden;- text-overflow: ellipsis;+ min-inline-size: 0;white-space: nowrap;++ [data-truncate] > & {+ overflow: hidden;+ text-overflow: ellipsis;+ }+}+.overflowingText {+ display: block;}.iconContainer {display: flex;diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss.d.ts b/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss.d.tsindex c5669e0325e..5334d83411d 100644--- a/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss.d.ts+++ b/packages/twenty-ui/src/primitives/data-display/Tag/Tag.module.scss.d.ts@@ -1,6 +1,7 @@declare const classNames: {readonly tag: 'tag';readonly content: 'content';+ readonly overflowingText: 'overflowingText';readonly iconContainer: 'iconContainer';};export default classNames;diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/Tag.tsx b/packages/twenty-ui/src/primitives/data-display/Tag/Tag.tsxindex e42b17893b5..b3d87dba420 100644--- a/packages/twenty-ui/src/primitives/data-display/Tag/Tag.tsx+++ b/packages/twenty-ui/src/primitives/data-display/Tag/Tag.tsx@@ -1,11 +1,7 @@-import { Button as ButtonPrimitive } from '@base-ui/react/button';import { useRender } from '@base-ui/react/use-render';import { clsx } from 'clsx';-import {- type CSSProperties,- type KeyboardEvent,- type SyntheticEvent,-} from 'react';+import { isBoolean, isString } from '@sniptt/guards';+import { type CSSProperties } from 'react';import { OverflowingTextWithTooltip } from '@ui/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip';import { themeCssVariables } from '@ui/theme';@@ -14,31 +10,14 @@ import { isDefined } from '@ui/utilities/utils/isDefined';import styles from './Tag.module.scss';import { type TagProps } from './types/TagProps';-const preventDisabledInteraction = (event: SyntheticEvent) => {- event.preventDefault();- event.stopPropagation();-};--const preventDisabledKeyboardActivation = (event: KeyboardEvent) => {- if (event.key !== 'Enter' && event.key !== ' ') {- return;- }-- preventDisabledInteraction(event);-};-export const Tag = ({children,color,weight = 'regular',variant = 'soft',startIcon,- preventShrink = false,- preventPadding = false,+ truncate = true,borderStyle = 'solid',- disabled = false,- nativeButton = true,- onClick,className,style,render,@@ -47,36 +26,15 @@ export const Tag = ({}: TagProps) =>useRender({defaultTagName: 'span',- render: isDefined(onClick) ? (- <ButtonPrimitive- render={render}- disabled={disabled}- nativeButton={nativeButton}- />- ) : (- render- ),+ render,ref,state: {variant,weight,- disabled,- interactive: isDefined(onClick),- preventShrink,- preventPadding,+ truncate,},props: {...props,- onClick,- ...(disabled && {- disabled: true,- 'aria-disabled': true,- tabIndex: -1,- onClickCapture: preventDisabledInteraction,- onPointerDownCapture: preventDisabledInteraction,- onKeyDownCapture: preventDisabledKeyboardActivation,- onKeyUpCapture: preventDisabledKeyboardActivation,- }),className: clsx(styles.tag, className),style: {'--tw-tag-background':@@ -95,15 +53,19 @@ export const Tag = ({children: (<>{isDefined(startIcon) &&- typeof startIcon !== 'boolean' &&+ !isBoolean(startIcon) &&startIcon !== '' && (<span className={styles.iconContainer} aria-hidden>{startIcon}</span>)}<span className={styles.content}>- {typeof children === 'string' && !preventShrink ? (- <OverflowingTextWithTooltip text={children} />+ {isString(children) && truncate ? (+ <OverflowingTextWithTooltip+ text={children}+ render={<span />}+ className={styles.overflowingText}+ />) : (children)}diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/__stories__/Tag.stories.tsx b/packages/twenty-ui/src/primitives/data-display/Tag/__stories__/Tag.stories.tsxindex 95ccb3b02aa..46c7713af24 100644--- a/packages/twenty-ui/src/primitives/data-display/Tag/__stories__/Tag.stories.tsx+++ b/packages/twenty-ui/src/primitives/data-display/Tag/__stories__/Tag.stories.tsx@@ -1,7 +1,8 @@import { type Meta, type StoryObj } from '@storybook/react-vite';-import { expect, fn, userEvent, within } from 'storybook/test';+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';-import { IconUser } from '@ui/icon/components/TablerIcons';+import { IconUser } from '@ui/icon';+import { Text } from '@ui/primitives/typography/Text/Text';import {A11Y_DEFER_COLOR_CONTRAST,CatalogDecorator,@@ -26,17 +27,8 @@ type Story = StoryObj<typeof Tag>;export const Default: Story = {args: {color: 'red',- onClick: fn(),},decorators: [ComponentDecorator],- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);-- const tag = canvas.getByText('Urgent');-- await userEvent.click(tag);- await expect(args.onClick).toHaveBeenCalled();- },};export const Documentation: Story = {@@ -69,12 +61,13 @@ export const WithIcon: Story = {},};-export const DontShrink: Story = {+export const WithoutTruncation: Story = {decorators: [ComponentDecorator],args: {color: 'green',children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',- preventShrink: true,+ truncate: false,+ style: { minWidth: 'fit-content' },},parameters: {a11y: A11Y_DEFER_COLOR_CONTRAST,@@ -82,6 +75,59 @@ export const DontShrink: Story = {},};+export const WithoutPadding: Story = {+ ...Default,+ args: {+ ...Default.args,+ style: { padding: 0 },+ title: 'Unpadded category',+ },+ play: async ({ canvasElement }) => {+ const tag = within(canvasElement).getByTitle('Unpadded category');++ await expect(tag).toBeVisible();+ await expect(getComputedStyle(tag).padding).toBe('0px');+ },+};++export const Truncation: Story = {+ ...WithLongText,+ play: async ({ canvasElement }) => {+ const text = within(canvasElement).getByText(+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',+ );++ await expect(getComputedStyle(text).textOverflow).toBe('ellipsis');+ await expect(text.scrollWidth).toBeGreaterThan(text.clientWidth);+ await userEvent.hover(text);++ const tooltip = await within(canvasElement.ownerDocument.body).findByRole(+ 'tooltip',+ );++ await waitFor(() => expect(tooltip).toBeVisible());+ await expect(tooltip).toHaveTextContent(+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',+ );+ },+};++export const FullLabel: Story = {+ ...WithoutTruncation,+ play: async ({ canvasElement }) => {+ const text = within(canvasElement).getByText(+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',+ );++ await expect(getComputedStyle(text).textOverflow).not.toBe('ellipsis');+ await expect(text.scrollWidth).toBeLessThanOrEqual(text.clientWidth);+ await userEvent.hover(text);+ await expect(+ within(canvasElement.ownerDocument.body).queryByRole('tooltip'),+ ).not.toBeInTheDocument();+ },+};+export const Catalog: CatalogStory<Story, typeof Tag> = {argTypes: {color: { control: false },@@ -131,7 +177,17 @@ export const CatalogDark: typeof Catalog = {export const PointerAndKeyboard: Story = {decorators: [ComponentDecorator],- args: { children: 'Open details', onClick: fn(), color: 'blue' },+ args: {+ children: 'Open details',+ onClick: fn(),+ ref: fn(),+ color: 'blue',+ variant: 'solid',+ style: { padding: 0 },+ },+ render: ({ onClick, ...args }) => (+ <Tag {...args} render={<button type="button" onClick={onClick} />} />+ ),play: async ({ canvasElement, args }) => {const control = within(canvasElement).getByRole('button', {name: 'Open details',@@ -141,6 +197,9 @@ export const PointerAndKeyboard: Story = {await userEvent.keyboard(' ');await expect(args.onClick).toHaveBeenCalledTimes(3);await expect(control).toHaveFocus();+ await expect(args.ref).toHaveBeenCalledWith(control);+ await expect(control).toHaveAttribute('data-variant', 'solid');+ await expect(getComputedStyle(control).padding).toBe('0px');await expect(args.onClick).toHaveBeenLastCalledWith(expect.objectContaining({ type: 'click' }),);@@ -151,10 +210,15 @@ export const Disabled: Story = {decorators: [ComponentDecorator],args: {children: 'Unavailable',- disabled: true,onClick: fn(),color: 'blue',},+ render: ({ onClick, ...args }) => (+ <Tag+ {...args}+ render={<button type="button" disabled onClick={onClick} />}+ />+ ),play: async ({ canvasElement, args }) => {const control = within(canvasElement).getByRole('button', {name: 'Unavailable',@@ -164,3 +228,103 @@ export const Disabled: Story = {await expect(args.onClick).not.toHaveBeenCalled();},};++export const RenderCallback: Story = {+ ...PointerAndKeyboard,+ render: ({ onClick, ...args }) => (+ <Tag+ {...args}+ render={(props) => <button {...props} type="button" onClick={onClick} />}+ />+ ),+};++export const DefaultSemantics: Story = {+ ...Default,+ args: {+ ...Default.args,+ title: 'Category label',+ onClick: fn(),+ ref: fn(),+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const tag = canvas.getByTitle('Category label');++ await expect(tag.tagName).toBe('SPAN');+ await expect(tag).not.toHaveAttribute('role');+ await expect(tag).not.toHaveAttribute('tabindex');+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();+ await expect(args.ref).toHaveBeenCalledWith(tag);+ await userEvent.click(tag);+ await expect(args.onClick).toHaveBeenCalledOnce();+ },+};++export const Navigation: Story = {+ ...PointerAndKeyboard,+ args: {+ ...PointerAndKeyboard.args,+ children: 'Customer records',+ onClick: fn((event) => event.preventDefault()),+ },+ render: ({ onClick, ...args }) => (+ <Tag+ {...args}+ render={(props) => (+ <a+ {...props}+ href="#customer-records"+ referrerPolicy="no-referrer"+ onClick={onClick}+ >+ {props.children}+ </a>+ )}+ />+ ),+ play: async ({ canvasElement, args }) => {+ const link = within(canvasElement).getByRole('link', {+ name: 'Customer records',+ });++ await expect(link.tagName).toBe('A');+ await expect(link).toHaveAttribute('href', '#customer-records');+ await expect(link).toHaveAttribute('referrerpolicy', 'no-referrer');+ await expect(args.ref).toHaveBeenCalledWith(link);+ link.focus();+ await userEvent.keyboard('{Enter}');+ await expect(args.onClick).toHaveBeenCalledOnce();+ await expect(link).toHaveFocus();+ },+};++export const NodeContent: Story = {+ ...Default,+ args: {+ ...Default.args,+ children: (+ <>+ Category:{' '}+ <Text+ render={(props) => (+ <a {...props} href="#enterprise-customers">+ {props.children}+ </a>+ )}+ style={{ display: 'inline' }}+ >+ Enterprise customer+ </Text>+ </>+ ),+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const link = canvas.getByRole('link', { name: 'Enterprise customer' });++ await expect(canvas.getByText('Category:')).toBeVisible();+ await expect(link).toHaveAttribute('href', '#enterprise-customers');+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();+ },+};diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/__tests__/Tag.test.tsx b/packages/twenty-ui/src/primitives/data-display/Tag/__tests__/Tag.test.tsxindex 21c93475ae4..f9663f34cdf 100644--- a/packages/twenty-ui/src/primitives/data-display/Tag/__tests__/Tag.test.tsx+++ b/packages/twenty-ui/src/primitives/data-display/Tag/__tests__/Tag.test.tsx@@ -1,7 +1,8 @@import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';import { render, screen } from '@testing-library/react';import userEvent from '@testing-library/user-event';-import { expect, it, vi } from 'vitest';+import { createRef } from 'react';+import { expect, expectTypeOf, it, vi } from 'vitest';import { ThemeProvider } from '@ui/theme/ThemeProvider';@@ -15,77 +16,85 @@ runComponentConformance({refInstanceOf: HTMLSpanElement,});-it('disables a custom button with its own click handler until re-enabled', async () => {- const user = userEvent.setup();+it('keeps its presentational root when native handlers are provided', async () => {+ const ref = createRef<HTMLSpanElement>();const handleClick = vi.fn();- const { rerender } = render(+ render(<ThemeProvider colorScheme="light">- <Tag color="blue" disabled render={<button onClick={handleClick} />}>- Save+ <Tag color="blue" ref={ref} onClick={handleClick} title="Category">+ Customer</Tag></ThemeProvider>,);- const button = screen.getByRole('button', { name: 'Save' });-- await user.click(button);- expect(handleClick).not.toHaveBeenCalled();- expect(button).toBeDisabled();+ expect(ref.current).toBeInstanceOf(HTMLSpanElement);+ expect(ref.current).toHaveAttribute('title', 'Category');+ expect(ref.current).not.toHaveAttribute('role');+ expect(ref.current).not.toHaveAttribute('tabindex');+ expect(screen.queryByRole('button')).not.toBeInTheDocument();+ await userEvent.click(screen.getByText('Customer'));+ expect(handleClick).toHaveBeenCalledOnce();+});- rerender(+it('lets a native button owner receive attributes, refs, keyboard activation and disabled state', async () => {+ const user = userEvent.setup();+ const ref = createRef<HTMLButtonElement>();+ const handleClick = vi.fn();+ const compose = (disabled: boolean) => (<ThemeProvider colorScheme="light">- <Tag color="blue" render={<button onClick={handleClick} />}>- Save+ <Tag+ color="blue"+ render={+ <button+ ref={ref}+ type="button"+ name="category"+ disabled={disabled}+ onClick={(event) => {+ expectTypeOf(event.currentTarget).toEqualTypeOf<+ EventTarget & HTMLButtonElement+ >();+ handleClick(event.currentTarget.name);+ }}+ />+ }+ >+ Customer</Tag>- </ThemeProvider>,+ </ThemeProvider>);+ const { rerender } = render(compose(true));+ const button = screen.getByRole('button', { name: 'Customer' });+ expect(ref.current).toBe(button);+ expect(button).toBeDisabled();await user.click(button);+ expect(handleClick).not.toHaveBeenCalled();++ rerender(compose(false));+ await user.tab();+ expect(button).toHaveFocus();await user.keyboard('{Enter} ');- expect(handleClick).toHaveBeenCalledTimes(3);+ expect(handleClick).toHaveBeenCalledTimes(2);+ expect(handleClick).toHaveBeenLastCalledWith('category');});-it('blocks disabled render-function links without trapping keyboard focus', async () => {- const user = userEvent.setup();- const handleClick = vi.fn();- const handleKeyDown = vi.fn();- const handleKeyUp = vi.fn();-+it('preserves caller-owned link nodes and URL strings', () => {render(<ThemeProvider colorScheme="light">- <Tag- color="blue"- disabled- nativeButton={false}- render={(props) => (- <a- {...props}- href="#details"- onClick={handleClick}- onKeyDown={handleKeyDown}- onKeyUp={handleKeyUp}- >- {props.children}- </a>- )}- >- Details+ <Tag color="blue">+ <a href="#account">Account</a>+ </Tag>+ <Tag color="blue" truncate={false}>+ https://twenty.com</Tag>- <button>Next</button></ThemeProvider>,);- const link = screen.getByRole('link', { name: 'Details' });-- await user.click(link);- link.focus();- await user.keyboard('{Enter} ');- expect(handleClick).not.toHaveBeenCalled();- expect(handleKeyDown).not.toHaveBeenCalled();- expect(handleKeyUp).not.toHaveBeenCalled();- expect(link).toHaveAttribute('aria-disabled', 'true');- expect(link).toHaveAttribute('tabindex', '-1');-- await user.tab();- expect(screen.getByRole('button', { name: 'Next' })).toHaveFocus();+ expect(screen.getByRole('link', { name: 'Account' })).toHaveAttribute(+ 'href',+ '#account',+ );+ expect(screen.getAllByRole('link')).toHaveLength(1);+ expect(screen.getByText('https://twenty.com')).toBeVisible();});diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/types/TagProps.ts b/packages/twenty-ui/src/primitives/data-display/Tag/types/TagProps.tsindex b8d7805580f..cd7ae294c8a 100644--- a/packages/twenty-ui/src/primitives/data-display/Tag/types/TagProps.ts+++ b/packages/twenty-ui/src/primitives/data-display/Tag/types/TagProps.ts@@ -2,15 +2,14 @@ import { type useRender } from '@base-ui/react/use-render';import { type ReactNode } from 'react';import { type TagColor } from './TagColor';+import { type TagState } from './TagState';-export type TagProps = Omit<useRender.ComponentProps<'span'>, 'color'> & {- color: TagColor;- weight?: 'regular' | 'medium';- disabled?: boolean;- nativeButton?: boolean;- variant?: 'solid' | 'soft' | 'outline' | 'ghost';- startIcon?: ReactNode;- preventShrink?: boolean;- preventPadding?: boolean;- borderStyle?: 'solid' | 'dashed';-};+export type TagProps = Omit<+ useRender.ComponentProps<'span', TagState>,+ 'color'+> &+ Partial<TagState> & {+ color: TagColor;+ startIcon?: ReactNode;+ borderStyle?: 'solid' | 'dashed';+ };diff --git a/packages/twenty-ui/src/primitives/data-display/Tag/types/TagState.ts b/packages/twenty-ui/src/primitives/data-display/Tag/types/TagState.tsnew file mode 100644index 00000000000..da97da2b589--- /dev/null+++ b/packages/twenty-ui/src/primitives/data-display/Tag/types/TagState.ts@@ -0,0 +1,5 @@+export type TagState = {+ variant: 'solid' | 'soft' | 'outline' | 'ghost';+ weight: 'regular' | 'medium';+ truncate: boolean;+};diff --git a/packages/twenty-ui/src/primitives/data-display/index.ts b/packages/twenty-ui/src/primitives/data-display/index.tsindex 356f674e899..f73a1b498a8 100644--- a/packages/twenty-ui/src/primitives/data-display/index.ts+++ b/packages/twenty-ui/src/primitives/data-display/index.ts@@ -29,6 +29,8 @@ export type { ColorSampleVariant } from './ColorSample/types/ColorSampleVariant'export { Pill } from './Pill/Pill';export { Status } from './Status/Status';export type { StatusProps } from './Status/types/StatusProps';+export type { StatusState } from './Status/types/StatusState';export { Tag } from './Tag/Tag';export type { TagColor } from './Tag/types/TagColor';export type { TagProps } from './Tag/types/TagProps';+export type { TagState } from './Tag/types/TagState';