The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Align Tabs with Base UI (#27732)
Raphaël Bosic3e6198469a7
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/tab-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/tab-button.mdxindex 7cebc263ab4..34ed2a9c167 100644--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/tab-button.mdx+++ b/packages/twenty-docs/snippets/ui/generated/components/navigation/tab-button.mdx@@ -49,7 +49,7 @@</ParamField><ParamField body="size" type=""md" | "sm"" default="sm">- Padding of the tab content: sm or md.+ Padding of the tab content: sm or md. Explicit size takes precedence over the ButtonGroup size, then sm applies.</ParamField><ParamField body="startIcon" type="ReactNode">diff --git a/packages/twenty-docs/snippets/ui/generated/navigation/tabs.mdx b/packages/twenty-docs/snippets/ui/generated/navigation/tabs.mdxindex 861f58fb1ca..ae35c44ed5e 100644--- a/packages/twenty-docs/snippets/ui/generated/navigation/tabs.mdx+++ b/packages/twenty-docs/snippets/ui/generated/navigation/tabs.mdx@@ -151,6 +151,30 @@The value of the Tab.</ParamField>+### Tabs.Indicator++<ParamField body="Indicator.className" type="string | ((state: TabsIndicatorState) => string | undefined)">+ CSS class applied to the element, or a function that+ returns a class based on the component's state.+</ParamField>++<ParamField body="Indicator.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TabsIndicatorState>">+ 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>++<ParamField body="Indicator.renderBeforeHydration" type="boolean" default="false">+ Whether to render itself before React hydrates.+ This minimizes the time that the indicator isn't visible after server-side rendering.+</ParamField>++<ParamField body="Indicator.style" type="CSSProperties | ((state: TabsIndicatorState) => CSSProperties | undefined)">+ Style applied to the element, or a function that+ returns a style object based on the component's state.+</ParamField>+### Tabs.Panel<ParamField body="Panel.className" type="string | ((state: TabsPanelState) => string | undefined)">diff --git a/packages/twenty-docs/ui/components/navigation/tab-button.mdx b/packages/twenty-docs/ui/components/navigation/tab-button.mdxindex 46f6bdf6863..94bac5d328b 100644--- a/packages/twenty-docs/ui/components/navigation/tab-button.mdx+++ b/packages/twenty-docs/ui/components/navigation/tab-button.mdx@@ -6,7 +6,7 @@ description: Present route links and actions alongside tabs with consistent stylimport { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';import TabButtonReference from '/snippets/ui/generated/components/navigation/tab-button.mdx';-Use `TabButton` for navigation links and actions such as adding a tab or opening an overflow menu. It shares the appearance of [Tabs](/ui/primitives/navigation/tabs) and uses [Button](/ui/primitives/input/button) for interaction.+Use `TabButton` for route links and actions such as adding a tab or opening an overflow menu. It shares the appearance of [Tabs](/ui/primitives/navigation/tabs) and uses [Button](/ui/primitives/input/button) for interaction.<StoryEmbedstoryId="ui-components-tabbutton--default"@@ -14,13 +14,15 @@ Use `TabButton` for navigation links and actions such as adding a tab or openingheight={180}/>-## State ownership+## State and semantics-Your application supplies `active` from its current route or menu state. This prop highlights the control without changing its role or introducing selection state. Use `Tabs.Root`, `Tabs.List`, `Tabs.Tab`, and `Tabs.Panel` to switch between related content panels, with controlled or uncontrolled selection.+Your application supplies `active` from its current route or menu state. This prop highlights the control. Set `aria-current="page"` on the current route link. Route links and adjacent actions retain their link or button semantics, with no tab role, `aria-selected`, or panel relationship.++Use `Tabs.Root`, `Tabs.List`, `Tabs.Tab`, `Tabs.Panel`, and optional `Tabs.Indicator` to switch between related content panels. Keep route and action controls outside `Tabs.List`.## Navigation-Set `href` to render a link. Supply `aria-current="page"` on the current destination.+Set `href` to render a native link. The current route owns its `active` appearance and `aria-current` value.```tsximport { TabButton } from 'twenty-ui/components/navigation';@@ -38,11 +40,30 @@ export const BillingLink = () => ();```-For client-side routing, set `nativeButton={false}` and `role="link"`, pass the resolved destination as `href`, and supply your router link through `render`. Keep route state and history options on the router link. Custom wrappers must forward props and the ref to the anchor. Disabled links retain their link role and block activation.+For client-side routing, supply your router link through `render`, set `nativeButton={false}` and `role="link"`, and pass the resolved destination as `href`. Keep route state and history options on the router link. Custom wrappers must forward the supplied props and ref to their anchor.++```tsx+import { TabButton } from 'twenty-ui/components/navigation';++export const ComposedBillingLink = () => (+ <TabButton+ nativeButton={false}+ role="link"+ href="/billing"+ render={<a />}+ aria-current="page"+ active+ >+ Billing+ </TabButton>+);+```++An explicit `nativeButton` controls the interaction contract even when `href` is present. Match it to the actual rendered element. Disabled links retain their link role and block activation.## Actions-Without `href`, the control renders a native button with `type="button"`. Native attributes, refs, styles, class names, and event handlers pass through.+Without `href`, the control renders a native button with `type="button"`. Native attributes, refs, styles, class names, and event handlers pass through. `render` accepts an element or a function receiving the Button props and state. Refs point to the actual rendered button or anchor, including refs supplied on a composed element.```tsximport { useState } from 'react';@@ -64,7 +85,7 @@ export const AddTabAction = () => {};```-Use `startIcon`, `endIcon`, and `badge` for supporting content. An avatar passed to an icon slot is decorative when the text names the destination. The `size` prop controls content padding with `sm` and `md` values.+Use `startIcon`, `endIcon`, and `badge` for supporting content. An avatar passed to an icon slot is decorative when the text names the destination. `size` retains the public Button size contract. An explicit size takes priority over a surrounding `ButtonGroup` size; otherwise the component defaults to `sm`.## Propsdiff --git a/packages/twenty-docs/ui/primitives/navigation/tabs.mdx b/packages/twenty-docs/ui/primitives/navigation/tabs.mdxindex 1098e226994..7a8ab1d59d5 100644--- a/packages/twenty-docs/ui/primitives/navigation/tabs.mdx+++ b/packages/twenty-docs/ui/primitives/navigation/tabs.mdx@@ -4,10 +4,9 @@ description: Switch between related panels with accessible tab navigation.---import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';-import TabsReference from '/snippets/ui/generated/navigation/tabs.mdx';-`Tabs` connects each tab to a panel using a shared `value`. Keep the values unique within a root.+`Tabs` connects each tab to a related content panel using a shared `value`. Keep values unique within a root. Use [TabButton](/ui/components/navigation/tab-button) for route links and adjacent actions.<StoryEmbedstoryId="ui-navigation-tabs--documentation"@@ -17,29 +16,35 @@ import TabsReference from '/snippets/ui/generated/navigation/tabs.mdx';## Anatomy-Place tabs inside `Tabs.List` and their panels alongside the list, all within the same `Tabs.Root`.+Place tabs and an optional indicator inside `Tabs.List`. Place their panels alongside the list, all within the same `Tabs.Root`.```textTabs.Root├── Tabs.List│ ├── Tabs.Tab-│ └── Tabs.Tab+│ ├── Tabs.Tab+│ └── Tabs.Indicator├── Tabs.Panel└── Tabs.Panel```-| Part | Requirement | Purpose |-| ------- | -------------------- | -------------------------------------------------------------------------- |-| `Root` | Required | Owns the active value and orientation. |-| `List` | Required | Groups the tabs and supplies keyboard navigation and the active indicator. |-| `Tab` | One per panel | Activates the panel with the same `value`. |-| `Panel` | One per content view | Displays its content when its `value` is active. |+| Part | Requirement | Purpose |+| ----------- | -------------------- | --------------------------------------------------------- |+| `Root` | Required | Owns the selected value and orientation. |+| `List` | Required | Groups tabs and supplies keyboard focus navigation. |+| `Tab` | One per panel | Activates the panel with the same `value`. |+| `Panel` | One per content view | Displays its content when its `value` is active. |+| `Indicator` | Optional | Shows the position of the active tab with themed styling. |++Give the list an accessible name and match each tab's `value` to its panel's `value`. Base UI supplies the tab and panel IDs, `aria-controls`, and `aria-labelledby` relationships.-Give the list an accessible name and match each selectable tab's `value` to its panel's `value`. Twenty UI includes the active indicator in `List`. Use `Tab.startIcon` and `Tab.badge` for optional supporting content while keeping the tab label in its children.+When you provide a custom `id` on `Tabs.Panel`, set `aria-controls` on the matching `Tabs.Tab` to that same ID. The installed Base UI 1.8.0 implementation requires this explicit relationship. Custom tab IDs are registered correctly for the panel's `aria-labelledby`.++Add one `Tabs.Indicator` when you want the active underline. `List` does not insert an indicator.## Uncontrolled state-Use `defaultValue` to set the initial active tab. The tabs own subsequent selection changes.+Use `defaultValue` to set the initial selection. The root owns subsequent changes.```tsximport { Tabs } from 'twenty-ui/primitives/navigation';@@ -51,6 +56,7 @@ export const RecordTabs = () => (<Tabs.Tab value="activity" badge={3}>Activity</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview">Company and contact details.</Tabs.Panel><Tabs.Panel value="activity">Recent calls and emails.</Tabs.Panel>@@ -58,18 +64,18 @@ export const RecordTabs = () => ();```-`Tabs.Tab` accepts `startIcon`, `badge`, and a `size` of `sm` or `md` (default `sm`). The active indicator is included in `Tabs.List`.+`Tabs.Tab` accepts `startIcon`, `endIcon`, `badge`, and a `size` of `sm` or `md` (default `sm`). The remaining props retain the installed Base UI contract. Values are not restricted to strings or numbers. Reference values must use the same identity on their tab, panel, and root. A root value of `null` selects no panel.-## Controlled state+## Controlled state and event details-Pass `value` and update it with `onValueChange` to own the same active tab in React state. The callback receives the next value and event details.+Pass `value` and update it with `onValueChange` to own selection. The callback receives the next value and Base UI event details, including the originating `event`, `reason`, `activationDirection`, and `cancel()`.```tsximport { useState } from 'react';import { Tabs } from 'twenty-ui/primitives/navigation';export const RecordTabs = () => {- const [tab, setTab] = useState<string | number | null>('overview');+ const [tab, setTab] = useState('overview');return (<Tabs.Root value={tab} onValueChange={setTab}>@@ -78,6 +84,7 @@ export const RecordTabs = () => {<Tabs.Tab value="activity" badge={3}>Activity</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview">Company and contact details.</Tabs.Panel><Tabs.Panel value="activity">Recent calls and emails.</Tabs.Panel>@@ -86,38 +93,99 @@ export const RecordTabs = () => {};```-## Manual activation+User activation has reason `none`. In uncontrolled roots, automatic fallback can have reason `initial`, `disabled`, or `missing`. Automatic fallback may select `null` when no enabled tab remains. These automatic changes cannot be canceled. Controlled roots keep selection under the application's ownership.-Keyboard activation is independent of state ownership. Use `activateOnFocus={false}` with either controlled or uncontrolled tabs.+Cancel a user change before updating controlled state, or use the same callback with an uncontrolled root:```tsx-import { useState } from 'react';import { Tabs } from 'twenty-ui/primitives/navigation';-export const SettingsTabs = () => {- const [tab, setTab] = useState<string | number | null>('profile');+export const ProtectedTabs = () => (+ <Tabs.Root+ defaultValue="overview"+ onValueChange={(value, details) => {+ if (value === 'restricted') {+ details.cancel();+ }+ }}+ >+ <Tabs.List aria-label="Account sections">+ <Tabs.Tab value="overview">Overview</Tabs.Tab>+ <Tabs.Tab value="restricted">Restricted</Tabs.Tab>+ <Tabs.Indicator />+ </Tabs.List>+ <Tabs.Panel value="overview">Account details.</Tabs.Panel>+ <Tabs.Panel value="restricted">Restricted content.</Tabs.Panel>+ </Tabs.Root>+);+```++## Keyboard activation, orientation, and direction++`Tabs.List` uses manual activation by default (`activateOnFocus={false}`). Arrow keys move focus; Enter or Space activates the focused tab. Set `activateOnFocus` to select a tab when keyboard focus reaches it. Both policies work with controlled and uncontrolled state.++```tsx+import { Tabs } from 'twenty-ui/primitives/navigation';++export const SettingsTabs = () => (+ <Tabs.Root defaultValue="profile" orientation="vertical">+ <Tabs.List aria-label="Settings" activateOnFocus loopFocus={false}>+ <Tabs.Tab value="profile">Profile</Tabs.Tab>+ <Tabs.Tab value="billing" disabled>+ Billing+ </Tabs.Tab>+ <Tabs.Tab value="notifications">Notifications</Tabs.Tab>+ <Tabs.Indicator />+ </Tabs.List>+ <Tabs.Panel value="profile">Profile settings.</Tabs.Panel>+ <Tabs.Panel value="billing">Billing settings.</Tabs.Panel>+ <Tabs.Panel value="notifications">Notification settings.</Tabs.Panel>+ </Tabs.Root>+);+```++Horizontal lists use Left and Right; vertical lists use Up and Down. Home and End focus the first and last enabled tabs. Disabled tabs are skipped. `loopFocus` defaults to `true`; set it to `false` to stop at either boundary.++Use [DirectionProvider](/ui/primitives/layout/direction-provider) for RTL keyboard direction and `dir="rtl"` on the root for layout. Set `orientation="vertical"` on `Root` for a vertical list and indicator.++## Panel lifetime++Use `keepMounted` when panel contents must retain their state while inactive. Inactive mounted panels remain hidden and do not occupy layout space.++## Native props, render composition, and refs++All five parts preserve native props, event handlers, refs, and Base UI `render` composition. Their `className` and `style` can also be functions of the part's state. The default elements are a `div` for Root, List, and Panel, a `button` for Tab, and a `span` for Indicator. Refs point to the actual rendered elements.++```tsx+import { useRef } from 'react';+import { Tabs } from 'twenty-ui/primitives/navigation';++export const ComposedTabs = () => {+ const panelRef = useRef<HTMLElement>(null);return (- <Tabs.Root value={tab} onValueChange={setTab}>- <Tabs.List aria-label="Settings" activateOnFocus={false}>- <Tabs.Tab value="profile">Profile</Tabs.Tab>- <Tabs.Tab value="notifications">Notifications</Tabs.Tab>- <Tabs.Tab value="billing" disabled>- Billing+ <Tabs.Root defaultValue="overview" render={<section />}>+ <Tabs.List aria-label="Account details">+ <Tabs.Tab value="overview" nativeButton render={<button />}>+ Overview</Tabs.Tab>+ <Tabs.Indicator render={<span data-testid="active-indicator" />} /></Tabs.List>- <Tabs.Panel value="profile">Profile settings.</Tabs.Panel>- <Tabs.Panel value="notifications">Notification settings.</Tabs.Panel>+ <Tabs.Panel+ value="overview"+ render={<article />}+ ref={(element) => {+ panelRef.current = element;+ }}+ >+ Account details.+ </Tabs.Panel></Tabs.Root>);};```-With `activateOnFocus={false}`, arrow keys move focus and Enter or Space activates the focused tab. `loopFocus` defaults to `true`. Disabled tabs are skipped. Use `orientation="vertical"` on `Root` for vertical navigation.--## Panel lifetime--Use `keepMounted` on a panel when its contents must remain mounted while inactive.+Keep `nativeButton` consistent with the element composed for a tab. Use `nativeButton={false}` for a custom interactive element that is not a native button and forwards the supplied props and ref. A route anchor belongs in `TabButton`, where the route owns navigation and `aria-current`.## Visual emphasis@@ -125,10 +193,10 @@ Use `highlighted` on `Tabs.Tab` to outline its content independently of selectio## Props-The reference is generated from the public component types. Native attributes, including accessible names and event handlers, are also accepted on parts that render elements.+The generated reference includes the public props for every part. Public part state types and Root change detail/reason types are available from `twenty-ui/primitives/navigation`.<TabsReference />-## Route links and adjacent actions+## Migration-Use [TabButton](/ui/components/navigation/tab-button) for route navigation and actions such as adding a tab or opening a menu. Keep those controls outside `Tabs.List`, whose children represent content selection. `Tabs.Tab` supports `startIcon`, `endIcon`, and `badge` slots for icons, decorative avatars, and counts.+Add an explicit `Tabs.Indicator` to lists that should retain the active underline. Remove duplicate indicators from compositions that previously relied on `List` inserting one. Keep route links, create controls, and overflow controls outside `Tabs.List`, whose children select related panels.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 f799993b7a6..0292d5771f7 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@@ -49,7 +49,7 @@ effect within the interaction timeout.| `twenty-ui-image-input` | ImageInput (native chooser, readable files, preview URLs, reset and ownership cleanup) || `twenty-ui-list-item` | ListItemButton and ListItem (native action composition, visual rows, explicit button/link/Menu.Item owners, refs/events/focus/keyboard, disabled behavior and sibling controls) || `twenty-ui-settings-row` | SettingsRow |-| `twenty-ui-tabs` | Tabs |+| `twenty-ui-tabs` | Tabs and TabButton || `twenty-ui-overflowing-list` | OverflowingList || `twenty-ui-phone-country-picker` | PhoneCountryPicker || `twenty-ui-currency-picker` | CurrencyPicker |@@ -173,6 +173,27 @@ Direct app-owned `Dialog`/`AlertDialog` modality and native browser dialog/popovAn invisible popup is not a compatibility pass.+Tabs still depends on C05 geometry acceptance for Indicator measurements and+physical activation direction. The worker lazily requests host snapshots on+first geometry reads and has no ResizeObserver to remeasure the initial+Indicator. Its first inactive-tab read returns a zero rectangle while the+active tab already has a snapshot, so a forward selection initially reports+`left` instead of `right`. The fixture pins both the zero-width Indicator and+incorrect initial direction with known-failure assertions while checking+selection, callback values/reasons, focus, panel relationships and native+composition. Passing these stories does not establish Indicator visibility or+physical-direction accuracy in the renderer.++Native anchor Enter activation also remains a separate renderer limitation.+Base UI recognizes native links by `tagName === 'A'`, while worker refs retain+the remote element name `HTML-A`. It therefore synthesizes a click in addition+to the host anchor's native click. The route fixture preserves exact pointer+counts, pins the observed duplicate Enter callback, and keeps the expected+single Enter callback as a known-failure assertion. Pointer activation, native+link attributes, refs, `aria-current`, and disabled callback suppression pass;+single keyboard activation remains pending renderer integration. Local+fragment links use `target="_self"` to keep navigation inside the story iframe.+SettingsRow's flat Switch props target the control. Its controlled compositionuses `nativeButton` and an actual button through `render`, preserving one changecallback for label and control activation. `labelRender` supplies native label@@ -243,7 +264,15 @@ worker. `HTMLElement.click()` dispatches a local click, and a click dispatchedinside the worker on a checkbox or radio input toggles it and fires `input` and`change`, which is how Base UI's Switch, Checkbox and Radio variantsactivate. Tabs, SettingsRow, Switch, Checkbox and RadioGroup therefore cover-activation and disabled items in both runtimes. Events that happen outside the+activation and disabled items in both runtimes. The Tabs fixture also verifies+manual focus versus activation, uncontrolled automatic activation, canceled+changes, disabled skipping, vertical and RTL navigation, looping boundaries,+panel labeling and mounted-panel hiding, native/render composition and actual+refs. Default panel IDs preserve automatic tab/panel relationships. Base UI 1.8+registers a generated panel ID even when an explicit `id` is supplied, so the+controlled fixture pairs its explicit panel IDs with matching native+`aria-controls` on each tab. Its TabButton controls retain route links with+`aria-current` and adjacent button actions without tab-panel semantics. Events that happen outside thecomponent never reach the worker, so dismissal on a press elsewhere on the pageis not covered.diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tab-button-contracts-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tab-button-contracts-example.tsxnew file mode 100644index 00000000000..a98f246b2de--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tab-button-contracts-example.tsx@@ -0,0 +1,104 @@+import { createElement, useState } from 'react';+import { isDefined } from 'twenty-shared/utils';+import { TabButton } from 'twenty-ui/components/navigation';+import { IconPlus } from 'twenty-ui/icon';+import { ButtonGroup } from 'twenty-ui/primitives/input';+import { Text } from 'twenty-ui/primitives/typography';++export const TabButtonContractsExample = () => {+ const [routeClicks, setRouteClicks] = useState(0);+ const [actionClicks, setActionClicks] = useState(0);++ return (+ <>+ <nav aria-label="Account routes">+ <TabButton+ active+ aria-current="page"+ nativeButton={false}+ role="link"+ href="#account-route"+ target="_self"+ title="Current account route"+ render={+ <a+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-render-ref-target', 'route-link');+ }}+ />+ }+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-ref-target', 'route-link');+ }}+ onClick={(event) => {+ event.preventDefault();+ setRouteClicks((count) => count + 1);+ }}+ >+ Account route+ </TabButton>+ <TabButton+ nativeButton={false}+ role="link"+ href="#activity-route"+ target="_self"+ render={(props, state) =>+ createElement('a', {+ ...props,+ 'data-render-disabled': String(state.disabled),+ })+ }+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-ref-target', 'callback-route-link');+ }}+ onClick={(event) => {+ event.preventDefault();+ setRouteClicks((count) => count + 1);+ }}+ >+ Activity route+ </TabButton>+ <TabButton+ href="#disabled-route"+ target="_self"+ disabled+ onClick={(event) => {+ event.preventDefault();+ setRouteClicks((count) => count + 1);+ }}+ >+ Disabled route+ </TabButton>+ </nav>+ <ButtonGroup aria-label="Adjacent tab actions" size="md">+ <TabButton+ nativeButton+ href="#native-action"+ render={<button />}+ startIcon={<IconPlus />}+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-ref-target', 'tab-action');+ }}+ onClick={() => setActionClicks((count) => count + 1)}+ >+ Create related panel+ </TabButton>+ <TabButton size="sm">More actions</TabButton>+ </ButtonGroup>+ <Text aria-label="Route activations">{routeClicks}</Text>+ <Text aria-label="Adjacent action activations">{actionClicks}</Text>+ </>+ );+};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tabs-contracts-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tabs-contracts-example.tsxnew file mode 100644index 00000000000..1d7a0c13f90--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tabs-contracts-example.tsx@@ -0,0 +1,181 @@+import { createElement, useState } from 'react';+import { isDefined } from 'twenty-shared/utils';+import { Button } from 'twenty-ui/primitives/input';+import { DirectionProvider } from 'twenty-ui/primitives/layout';+import { Tabs } from 'twenty-ui/primitives/navigation';+import { Text } from 'twenty-ui/primitives/typography';++export const TabsContractsExample = () => {+ const [value, setValue] = useState('overview');+ const [changeCount, setChangeCount] = useState(0);+ const [changeDetails, setChangeDetails] = useState('none');+ const [nativeKey, setNativeKey] = useState('none');+ const [automaticValue, setAutomaticValue] = useState('first');+ const [automaticDetails, setAutomaticDetails] = useState('none');++ return (+ <>+ <Tabs.Root+ value={value}+ onValueChange={(nextValue, details) => {+ setValue(nextValue);+ setChangeCount((count) => count + 1);+ setChangeDetails(+ `${nextValue}:${details.reason}:${details.event.type}:${details.activationDirection}`,+ );+ }}+ render={<section />}+ data-testid="controlled-tabs-root"+ title="Controlled account panels"+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-ref-target', 'tabs-root');+ }}+ >+ <Tabs.List+ aria-label="Account sections"+ render={<nav />}+ onKeyDown={(event) => setNativeKey(event.key)}+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-ref-target', 'tabs-list');+ }}+ >+ <Tabs.Tab+ value="overview"+ id="account-overview-tab"+ aria-controls="account-overview-panel"+ render={<button data-native-owner="overview" />}+ nativeButton+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-ref-target', 'tabs-tab');+ }}+ >+ Overview+ </Tabs.Tab>+ <Tabs.Tab value="disabled" disabled>+ Unavailable+ </Tabs.Tab>+ <Tabs.Tab+ value="activity"+ id="account-activity-tab"+ aria-controls="account-activity-panel"+ >+ Activity+ </Tabs.Tab>+ <Tabs.Indicator+ data-testid="account-indicator"+ render={(props, state) =>+ createElement('span', {+ ...props,+ 'data-render-orientation': state.orientation,+ })+ }+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-ref-target', 'tabs-indicator');+ }}+ />+ </Tabs.List>+ <Tabs.Panel+ value="overview"+ id="account-overview-panel"+ keepMounted+ render={<article />}+ ref={(element) => {+ if (!isDefined(element)) {+ return;+ }+ element.setAttribute('data-ref-target', 'tabs-panel');+ }}+ >+ Account overview+ </Tabs.Panel>+ <Tabs.Panel+ value="activity"+ id="account-activity-panel"+ keepMounted+ render={(props, state) =>+ createElement('article', {+ ...props,+ 'data-render-hidden': String(state.hidden),+ })+ }+ >+ Recent activity+ </Tabs.Panel>+ </Tabs.Root>+ <Text aria-label="Controlled selection">{value}</Text>+ <Text aria-label="Controlled change count">{changeCount}</Text>+ <Text aria-label="Controlled change details">{changeDetails}</Text>+ <Text aria-label="Tabs native key">{nativeKey}</Text>+ <Button onClick={() => setValue('overview')}>+ Select overview externally+ </Button>+ <Tabs.Root+ defaultValue="first"+ orientation="vertical"+ onValueChange={(nextValue, details) => {+ if (nextValue === 'blocked') {+ details.cancel();+ }+ setAutomaticDetails(+ `${nextValue}:${details.reason}:${details.event.type}:${details.isCanceled}`,+ );+ if (details.isCanceled) {+ return;+ }+ setAutomaticValue(nextValue);+ }}+ >+ <Tabs.List+ aria-label="Automatic vertical sections"+ activateOnFocus+ loopFocus={false}+ >+ <Tabs.Tab value="disabled-first" disabled>+ Disabled first+ </Tabs.Tab>+ <Tabs.Tab value="first">First section</Tabs.Tab>+ <Tabs.Tab value="disabled-middle" disabled>+ Disabled middle+ </Tabs.Tab>+ <Tabs.Tab value="second">Second section</Tabs.Tab>+ <Tabs.Tab value="blocked">Blocked section</Tabs.Tab>+ <Tabs.Tab value="disabled-last" disabled>+ Disabled last+ </Tabs.Tab>+ <Tabs.Indicator />+ </Tabs.List>+ <Tabs.Panel value="first">First section content</Tabs.Panel>+ <Tabs.Panel value="second">Second section content</Tabs.Panel>+ <Tabs.Panel value="blocked">Blocked section content</Tabs.Panel>+ </Tabs.Root>+ <Text aria-label="Automatic selection">{automaticValue}</Text>+ <Text aria-label="Automatic change details">{automaticDetails}</Text>+ <DirectionProvider direction="rtl">+ <Tabs.Root defaultValue="start" dir="rtl">+ <Tabs.List aria-label="RTL sections" activateOnFocus>+ <Tabs.Tab value="start">RTL start</Tabs.Tab>+ <Tabs.Tab value="disabled" disabled>+ RTL unavailable+ </Tabs.Tab>+ <Tabs.Tab value="end">RTL end</Tabs.Tab>+ <Tabs.Indicator />+ </Tabs.List>+ <Tabs.Panel value="start">RTL start content</Tabs.Panel>+ <Tabs.Panel value="end">RTL end content</Tabs.Panel>+ </Tabs.Root>+ </DirectionProvider>+ </>+ );+};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tabs.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tabs.front-component.tsxindex 2d912677acd..fcb94c6e62d 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tabs.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tabs.front-component.tsx@@ -1,33 +1,19 @@-import { useState } from 'react';import { defineFrontComponent } from 'twenty-sdk/define';-import { Tabs } from 'twenty-ui/primitives/navigation';import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';+import { TabButtonContractsExample } from '@/__stories__/twenty-ui-gallery/tab-button-contracts-example';+import { TabsContractsExample } from '@/__stories__/twenty-ui-gallery/tabs-contracts-example';-const TabsExample = () => {- const [value, setValue] = useState('overview');-- return (- <TwentyUiGalleryCard title="Tabs">- <Tabs.Root value={value} onValueChange={setValue}>- <Tabs.List aria-label="Account sections">- <Tabs.Tab value="overview">Overview</Tabs.Tab>- <Tabs.Tab value="disabled" disabled>- Unavailable- </Tabs.Tab>- <Tabs.Tab value="activity">Activity</Tabs.Tab>- </Tabs.List>- <Tabs.Panel value="overview">Account overview</Tabs.Panel>- <Tabs.Panel value="activity">Recent activity</Tabs.Panel>- </Tabs.Root>- <p role="status">Section: {value}</p>- </TwentyUiGalleryCard>- );-};+const TabsExample = () => (+ <TwentyUiGalleryCard title="Tabs">+ <TabsContractsExample />+ <TabButtonContractsExample />+ </TwentyUiGalleryCard>+);export default defineFrontComponent({universalIdentifier: '4d23e9af-7cb3-4e4a-bbca-8e960f840004',name: 'twenty-ui-tabs',- description: 'Tabs selection and keyboard navigation in the sandbox',+ description: 'Tabs panels, keyboard selection, and route or action controls',component: TabsExample,});diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tabButtonTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tabButtonTest.tsnew file mode 100644index 00000000000..ed436452dcb--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tabButtonTest.ts@@ -0,0 +1,92 @@+import { expect, userEvent, waitFor, within } from 'storybook/test';++import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';+import { expectAssertionToKeepFailing } from '@/__stories__/twenty-ui-gallery/utils/expectAssertionToKeepFailing';++export const tabButtonTest: TwentyUiGalleryPlayFunction = async ({+ canvasElement,+}) => {+ const canvas = within(canvasElement);+ const routes = within(+ canvas.getByRole('navigation', { name: 'Account routes' }),+ );+ const route = routes.getByRole('link', { name: 'Account route' });+ const callbackRoute = routes.getByRole('link', { name: 'Activity route' });+ const disabledRoute = routes.getByRole('link', { name: 'Disabled route' });++ expect(route.tagName).toBe('A');+ expect(route).toHaveAttribute('href', '#account-route');+ expect(route).toHaveAttribute('title', 'Current account route');+ expect(route).toHaveAttribute('aria-current', 'page');+ expect(route).toHaveAttribute('data-ref-target', 'route-link');+ expect(route).toHaveAttribute('data-render-ref-target', 'route-link');+ expect(callbackRoute.tagName).toBe('A');+ expect(callbackRoute).toHaveAttribute(+ 'data-ref-target',+ 'callback-route-link',+ );+ expect(callbackRoute).toHaveAttribute('data-render-disabled', 'false');+ expect(callbackRoute).not.toHaveAttribute('aria-current');+ expect(disabledRoute).toHaveAttribute('aria-disabled', 'true');++ for (const link of [route, callbackRoute, disabledRoute]) {+ expect(link).toHaveAttribute('target', '_self');+ expect(link).not.toHaveAttribute('aria-selected');+ expect(link).not.toHaveAttribute('aria-controls');+ }+ expect(routes.queryByRole('tab')).not.toBeInTheDocument();++ await userEvent.click(route);+ await waitFor(() =>+ expect(canvas.getByLabelText('Route activations')).toHaveTextContent('1'),+ );+ await userEvent.keyboard('{Enter}');+ await waitFor(() =>+ expect(canvas.getByLabelText('Route activations')).toHaveTextContent('3'),+ );+ await expectAssertionToKeepFailing(() =>+ expect(canvas.getByLabelText('Route activations')).toHaveTextContent('2'),+ );+ await userEvent.click(callbackRoute);+ await waitFor(() =>+ expect(canvas.getByLabelText('Route activations')).toHaveTextContent('4'),+ );+ await userEvent.click(disabledRoute);+ await expectAssertionToKeepFailing(() =>+ expect(canvas.getByLabelText('Route activations')).not.toHaveTextContent(+ /^4$/,+ ),+ );++ const action = canvas.getByRole('button', { name: 'Create related panel' });+ const moreAction = canvas.getByRole('button', { name: 'More actions' });+ expect(action.tagName).toBe('BUTTON');+ expect(action).toHaveAttribute('type', 'button');+ expect(action).toHaveAttribute('data-ref-target', 'tab-action');+ for (const button of [action, moreAction]) {+ expect(button).not.toHaveAttribute('aria-selected');+ expect(button).not.toHaveAttribute('aria-controls');+ expect(button).not.toHaveAttribute('aria-current');+ }+ await waitFor(() => {+ expect(action).toHaveAttribute('data-size', 'md');+ expect(moreAction).toHaveAttribute('data-size', 'sm');+ expect(+ within(action).getByText('Create related panel').parentElement,+ ).toHaveStyle({ paddingBlockStart: '8px', paddingBlockEnd: '8px' });+ expect(+ within(moreAction).getByText('More actions').parentElement,+ ).toHaveStyle({+ paddingBlockStart: '4px',+ paddingBlockEnd: '4px',+ });+ });+ await userEvent.click(action);+ await userEvent.keyboard('{Enter}');+ await userEvent.keyboard(' ');+ await waitFor(() =>+ expect(+ canvas.getByLabelText('Adjacent action activations'),+ ).toHaveTextContent('3'),+ );+};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tabsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tabsTest.tsindex 33afcb61def..7ff8e388566 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tabsTest.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tabsTest.ts@@ -4,32 +4,208 @@ import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponeimport { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';import { expectAssertionToKeepFailing } from '@/__stories__/twenty-ui-gallery/utils/expectAssertionToKeepFailing';+import { tabButtonTest } from '@/__stories__/twenty-ui-gallery/utils/tabButtonTest';-export const tabsTest: TwentyUiGalleryPlayFunction = async ({- canvasElement,-}) => {- const canvas = within(canvasElement);+export const tabsTest: TwentyUiGalleryPlayFunction = async (context) => {+ const canvas = within(context.canvasElement);await expectFrontComponentMounted(canvas);- const overviewTab = canvas.getByRole('tab', { name: 'Overview' });- const activityTab = canvas.getByRole('tab', { name: 'Activity' });- const unavailableTab = canvas.getByRole('tab', { name: 'Unavailable' });- expect(overviewTab).toHaveAttribute('aria-selected', 'true');- expect(unavailableTab).toHaveAttribute('aria-disabled', 'true');- expect(canvas.getByRole('status')).toHaveTextContent('Section: overview');+ const root = canvas.getByTestId('controlled-tabs-root');+ const list = canvas.getByRole('tablist', { name: 'Account sections' });+ const overview = within(list).getByRole('tab', { name: 'Overview' });+ const activity = within(list).getByRole('tab', { name: 'Activity' });+ const unavailable = within(list).getByRole('tab', { name: 'Unavailable' });+ const overviewPanel = canvas.getByRole('tabpanel', { name: 'Overview' });+ const activityPanel = root.querySelector('#account-activity-panel')!;+ const indicator = within(list).getByTestId('account-indicator');- await userEvent.click(activityTab);+ expect(root.tagName).toBe('SECTION');+ expect(root).toHaveAttribute('title', 'Controlled account panels');+ expect(root).toHaveAttribute('data-ref-target', 'tabs-root');+ expect(list.tagName).toBe('NAV');+ expect(list).toHaveAttribute('data-ref-target', 'tabs-list');+ expect(overview.tagName).toBe('BUTTON');+ expect(overview).toHaveAttribute('data-ref-target', 'tabs-tab');+ expect(overview).toHaveAttribute('data-native-owner', 'overview');+ expect(overview).toHaveAttribute('aria-controls', overviewPanel.id);+ expect(overviewPanel.tagName).toBe('ARTICLE');+ expect(overviewPanel).toHaveAttribute('aria-labelledby', overview.id);+ expect(overviewPanel).toHaveAttribute('data-ref-target', 'tabs-panel');+ expect(indicator.tagName).toBe('SPAN');+ expect(indicator).toHaveAttribute('data-ref-target', 'tabs-indicator');+ expect(indicator).toHaveAttribute('data-render-orientation', 'horizontal');+ expect(+ list.querySelectorAll('[data-ref-target="tabs-indicator"]'),+ ).toHaveLength(1);+ expect(overview).toHaveAttribute('aria-selected', 'true');+ expect(unavailable).toHaveAttribute('aria-disabled', 'true');+ expect(activityPanel).not.toBeVisible();+ expect(activityPanel).toHaveAttribute('data-render-hidden', 'true');+ expect(activityPanel.getBoundingClientRect().height).toBe(0);++ await waitFor(() => {+ expect(overview.getBoundingClientRect().width).toBeGreaterThan(0);+ expect(activity.getBoundingClientRect().width).toBeGreaterThan(0);+ expect(overview.getBoundingClientRect().left).toBeLessThan(+ activity.getBoundingClientRect().left,+ );+ });+ await expectAssertionToKeepFailing(() =>+ expect(indicator.getBoundingClientRect().width).toBeGreaterThan(0),+ );+ await userEvent.click(overview);+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(activity).toHaveFocus());+ expect(overview).toHaveAttribute('aria-selected', 'true');+ expect(canvas.getByLabelText('Controlled change count')).toHaveTextContent(+ '0',+ );await waitFor(() =>- expect(canvas.getByRole('status')).toHaveTextContent('Section: activity'),+ expect(canvas.getByLabelText('Tabs native key')).toHaveTextContent(+ 'ArrowRight',+ ),+ );+ await userEvent.keyboard('{Enter}');+ await waitFor(() => {+ expect(activity).toHaveAttribute('aria-selected', 'true');+ expect(canvas.getByLabelText('Controlled selection')).toHaveTextContent(+ 'activity',+ );+ expect(canvas.getByLabelText('Controlled change count')).toHaveTextContent(+ '1',+ );+ expect(+ canvas.getByLabelText('Controlled change details').textContent,+ ).toMatch(/^activity:none:(click|keydown):left$/);+ expect(canvas.getByRole('tabpanel', { name: 'Activity' })).toBe(+ activityPanel,+ );+ expect(activityPanel).toHaveAttribute('aria-labelledby', activity.id);+ expect(activity).toHaveAttribute('aria-controls', activityPanel.id);+ expect(activityPanel).toHaveAttribute('data-render-hidden', 'false');+ expect(overviewPanel).not.toBeVisible();+ });+ await expectAssertionToKeepFailing(() =>+ expect(+ canvas.getByLabelText('Controlled change details').textContent,+ ).toMatch(/^activity:none:(click|keydown):right$/),+ );+ await userEvent.click(activity);+ expect(canvas.getByLabelText('Controlled change count')).toHaveTextContent(+ '1',);- expect(activityTab).toHaveAttribute('aria-selected', 'true');- expect(overviewTab).toHaveAttribute('aria-selected', 'false');- expect(canvas.getByText('Recent activity')).toBeVisible();- await userEvent.click(unavailableTab);+ await userEvent.keyboard('{Home}');+ await waitFor(() => expect(overview).toHaveFocus());+ expect(activity).toHaveAttribute('aria-selected', 'true');+ await userEvent.keyboard('{End}');+ await waitFor(() => expect(activity).toHaveFocus());+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => expect(overview).toHaveFocus());+ expect(activity).toHaveAttribute('aria-selected', 'true');+ await userEvent.keyboard(' ');+ await waitFor(() => {+ expect(overview).toHaveAttribute('aria-selected', 'true');+ expect(canvas.getByLabelText('Controlled change count')).toHaveTextContent(+ '2',+ );+ });+ await userEvent.click(unavailable);await expectAssertionToKeepFailing(() =>- expect(canvas.getByRole('status')).toHaveTextContent('Section: disabled'),+ expect(canvas.getByLabelText('Controlled selection')).toHaveTextContent(+ 'disabled',+ ),);- expect(activityTab).toHaveAttribute('aria-selected', 'true');++ await userEvent.click(activity);+ await waitFor(() =>+ expect(activity).toHaveAttribute('aria-selected', 'true'),+ );+ await userEvent.click(+ canvas.getByRole('button', { name: 'Select overview externally' }),+ );+ await waitFor(() =>+ expect(overview).toHaveAttribute('aria-selected', 'true'),+ );+ expect(canvas.getByLabelText('Controlled change count')).toHaveTextContent(+ '3',+ );++ const vertical = canvas.getByRole('tablist', {+ name: 'Automatic vertical sections',+ });+ const first = within(vertical).getByRole('tab', { name: 'First section' });+ const second = within(vertical).getByRole('tab', { name: 'Second section' });+ const blocked = within(vertical).getByRole('tab', {+ name: 'Blocked section',+ });+ expect(vertical).toHaveAttribute('aria-orientation', 'vertical');+ await userEvent.click(first);+ await userEvent.keyboard('{ArrowDown}');+ await waitFor(() => {+ expect(second).toHaveFocus();+ expect(second).toHaveAttribute('aria-selected', 'true');+ const secondPanel = canvas.getByRole('tabpanel', {+ name: 'Second section',+ });+ expect(secondPanel).toBeVisible();+ expect(second).toHaveAttribute('aria-controls', secondPanel.id);+ expect(secondPanel).toHaveAttribute('aria-labelledby', second.id);+ expect(+ canvas.getByLabelText('Automatic change details').textContent,+ ).toMatch(/^second:none:focus(?:in)?:false$/);+ });+ await userEvent.keyboard('{ArrowDown}');+ await waitFor(() => {+ expect(blocked).toHaveFocus();+ expect(second).toHaveAttribute('aria-selected', 'true');+ expect(+ canvas.getByLabelText('Automatic change details').textContent,+ ).toMatch(/^blocked:none:focus(?:in)?:true$/);+ });+ expect(+ canvas.queryByRole('tabpanel', { name: 'Blocked section' }),+ ).not.toBeInTheDocument();+ await userEvent.keyboard('{ArrowDown}');+ await waitFor(() => expect(blocked).toHaveFocus());+ await userEvent.keyboard('{Home}');+ await waitFor(() => {+ expect(first).toHaveFocus();+ expect(first).toHaveAttribute('aria-selected', 'true');+ });+ await userEvent.keyboard('{ArrowUp}');+ await waitFor(() => expect(first).toHaveFocus());+ await userEvent.keyboard('{End}');+ await waitFor(() => {+ expect(blocked).toHaveFocus();+ expect(first).toHaveAttribute('aria-selected', 'true');+ });+ await userEvent.keyboard('{ArrowUp}');+ await waitFor(() => {+ expect(second).toHaveFocus();+ expect(second).toHaveAttribute('aria-selected', 'true');+ });++ const rightToLeft = canvas.getByRole('tablist', { name: 'RTL sections' });+ const start = within(rightToLeft).getByRole('tab', { name: 'RTL start' });+ const end = within(rightToLeft).getByRole('tab', { name: 'RTL end' });+ await userEvent.click(start);+ await userEvent.keyboard('{ArrowLeft}');+ await waitFor(() => {+ expect(end).toHaveFocus();+ expect(end).toHaveAttribute('aria-selected', 'true');+ });+ await userEvent.keyboard('{ArrowLeft}');+ await waitFor(() => {+ expect(start).toHaveFocus();+ expect(start).toHaveAttribute('aria-selected', 'true');+ });+ await userEvent.keyboard('{ArrowRight}');+ await waitFor(() => {+ expect(end).toHaveFocus();+ expect(end).toHaveAttribute('aria-selected', 'true');+ });++ await tabButtonTest(context);expect(errorHandler).not.toHaveBeenCalled();};diff --git a/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx b/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsxindex 08e89a15d3e..68a3c4bd9a0 100644--- a/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx+++ b/packages/twenty-front/src/modules/page-layout/components/__stories__/PageLayoutTabList.stories.tsx@@ -380,6 +380,13 @@ export const IdentifierBarNarrow: Story = {const body = within(canvasElement.ownerDocument.body);const [moreButton] = await canvas.findAllByRole('button', { name: /More/ });+ const addButton = canvas.getByRole('button', { name: 'New Tab' });++ expect(moreButton.closest('[role="tablist"]')).toBeNull();+ expect(moreButton).not.toHaveAttribute('aria-selected');+ expect(addButton.closest('[role="tablist"]')).toBeNull();+ expect(addButton).not.toHaveAttribute('aria-selected');+ expect(addButton).not.toHaveAttribute('aria-controls');await userEvent.click(moreButton);await userEvent.click(await body.findByRole('button', { name: 'Revenue' }));diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListRow.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListRow.tsxindex ab063d6fa22..16a3613baed 100644--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListRow.tsx+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/TabListRow.tsx@@ -49,6 +49,7 @@ export const TabListRow = ({render={<StyledContainer isScrollable={isScrollable} />}>{children}+ <Tabs.Indicator /></Tabs.List>);};diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListItemNavigation.stories.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListItemNavigation.stories.tsxnew file mode 100644index 00000000000..18b37760849--- /dev/null+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListItemNavigation.stories.tsx@@ -0,0 +1,95 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { MemoryRouter, useLocation } from 'react-router-dom';+import { expect, fn, userEvent, within } from 'storybook/test';+import { ComponentDecorator } from 'twenty-ui/testing';+import { Text } from 'twenty-ui/primitives/typography';++import { TabListItem } from '@/ui/layout/tab-list/components/TabListItem';+import { type TabListItemProps } from '@/ui/layout/tab-list/types/TabListItemProps';++type TabListItemNavigationExampleProps = Extract<+ TabListItemProps,+ { mode: 'link' }+>;++const TabListItemNavigationExample = (+ args: TabListItemNavigationExampleProps,+) => {+ const location = useLocation();++ return (+ <>+ <TabListItem {...args} active={location.hash === '#activity'} />+ <Text role="status">+ {location.pathname}+ {location.search}+ {location.hash}+ </Text>+ <Text>{location.state?.source}</Text>+ </>+ );+};++const meta = {+ title: 'UI/Layout/TabList/ItemNavigation',+ component: TabListItemNavigationExample,+ args: {+ tab: { id: 'activity', title: 'Activity' },+ mode: 'link',+ active: false,+ onSelect: fn(),+ ref: fn(),+ },+ decorators: [+ ComponentDecorator,+ (Story) => (+ <MemoryRouter+ initialEntries={[+ {+ pathname: '/object/company/record-1',+ search: '?filter=open',+ state: { source: 'record-route' },+ },+ ]}+ >+ <Story />+ </MemoryRouter>+ ),+ ],+} satisfies Meta<typeof TabListItemNavigationExample>;++export default meta;+type Story = StoryObj<typeof meta>;++export const RouteLinkComposition: Story = {+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const activity = await canvas.findByRole('link', { name: 'Activity' });++ expect(activity.tagName).toBe('A');+ expect(args.ref).toHaveBeenCalledWith(activity);+ expect(activity).toHaveAttribute(+ 'href',+ '/object/company/record-1?filter=open#activity',+ );+ expect(activity).not.toHaveAttribute('type');+ expect(activity).not.toHaveAttribute('aria-current');+ expect(activity).not.toHaveAttribute('aria-selected');+ expect(activity).not.toHaveAttribute('aria-controls');+ expect(canvas.queryByRole('tab')).not.toBeInTheDocument();+ expect(canvas.queryByRole('tablist')).not.toBeInTheDocument();+ expect(canvas.queryByRole('tabpanel')).not.toBeInTheDocument();++ activity.focus();+ await userEvent.keyboard('{Enter}');++ expect(args.onSelect).toHaveBeenCalledTimes(1);+ expect(args.onSelect).toHaveBeenCalledWith('activity');+ expect(canvas.getByRole('status')).toHaveTextContent(+ '/object/company/record-1?filter=open#activity',+ );+ expect(canvas.getByText('record-route')).toBeVisible();+ expect(activity).toHaveAttribute('aria-current', 'page');+ expect(activity).toHaveFocus();+ },+};diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListNavigation.stories.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListNavigation.stories.tsxindex 288e51827b6..7cd0fd62fe6 100644--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListNavigation.stories.tsx+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/TabListNavigation.stories.tsx@@ -229,8 +229,14 @@ export const RouteLinks: Story = {expect(disabled).toHaveAttribute('aria-disabled', 'true');expect(disabled).toHaveAttribute('tabindex', '-1');+ expect(activity.tagName).toBe('A');expect(activity).not.toHaveAttribute('type');+ expect(activity).not.toHaveAttribute('aria-selected');+ expect(activity).not.toHaveAttribute('aria-controls');+ expect(overview).toHaveAttribute('aria-current', 'page');overview.focus();+ await userEvent.keyboard('{ArrowRight}');+ expect(overview).toHaveFocus();await userEvent.tab();expect(activity).toHaveFocus();@@ -243,6 +249,8 @@ export const RouteLinks: Story = {expect(canvas.getByText(args.sidePanel ? 'REPLACE' : 'PUSH')).toBeVisible();expect(canvas.getByText('tab-list')).toBeVisible();expect(activity).toHaveAttribute('aria-current', 'page');+ expect(overview).not.toHaveAttribute('aria-current');+ expect(canvas.queryByRole('tab')).not.toBeInTheDocument();await userEvent.click(disabled);expect(canvas.getByRole('status')).toHaveTextContent('activity: 2');expect(canvas.getByText('?filter=open#activity')).toBeVisible();diff --git a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsxindex 1039463ade2..cd77f0152ae 100644--- a/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx+++ b/packages/twenty-front/src/modules/ui/layout/tab-list/components/__stories__/Tablist.stories.tsx@@ -120,6 +120,8 @@ export const Overflow: Story = {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);const moreButton = await canvas.findByRole('button', { name: /More/ });+ expect(moreButton.closest('[role="tablist"]')).toBeNull();+ expect(moreButton).not.toHaveAttribute('aria-selected');await userEvent.click(moreButton);const popup = await body.findByRole('dialog', { name: /More/ });const sales = await body.findByRole('button', { name: 'Sales' });diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex 558c27436bc..419b6e63484 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -776,8 +776,9 @@ export const DOCUMENTED_COMPONENTS = [active:'Highlights the current destination or an action associated with the active tab. Does not change the control role.',badge: 'Content following the label and trailing icon, such as a count.',- size: 'Padding of the tab content: sm or md.',+ size: 'Padding of the tab content: sm or md. Explicit size takes precedence over the ButtonGroup size, then sm applies.',},+ propDefaults: { size: 'sm' },},{name: 'AvatarGroup',diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.jsonindex 038c90661cf..e2e08793ded 100644--- a/packages/twenty-ui/docs/public-exports.json+++ b/packages/twenty-ui/docs/public-exports.json@@ -891,11 +891,26 @@"ListItemIndicator": "primitives/navigation/ListItem/types/ListItemIndicator","ListItemProps": "primitives/navigation/ListItem/types/ListItemProps","ListItemState": "primitives/navigation/ListItem/types/ListItemState",+ "TabsIndicatorProps": "primitives/navigation/Tabs/types/TabsIndicatorProps",+ "TabsIndicatorState": "primitives/navigation/Tabs/types/TabsIndicatorState","TabsListProps": "primitives/navigation/Tabs/types/TabsListProps",+ "TabsListState": "primitives/navigation/Tabs/types/TabsListState",+ "TabsPanelMetadata": "primitives/navigation/Tabs/types/TabsPanelMetadata","TabsPanelProps": "primitives/navigation/Tabs/types/TabsPanelProps",+ "TabsPanelState": "primitives/navigation/Tabs/types/TabsPanelState",+ "TabsRootChangeEventDetails": "primitives/navigation/Tabs/types/TabsRootChangeEventDetails",+ "TabsRootChangeEventReason": "primitives/navigation/Tabs/types/TabsRootChangeEventReason",+ "TabsRootOrientation": "primitives/navigation/Tabs/types/TabsRootOrientation","TabsRootProps": "primitives/navigation/Tabs/types/TabsRootProps",+ "TabsRootState": "primitives/navigation/Tabs/types/TabsRootState","TabsSize": "primitives/navigation/Tabs/types/TabsSize",- "TabsTabProps": "primitives/navigation/Tabs/types/TabsTabProps"+ "TabsTabActivationDirection": "primitives/navigation/Tabs/types/TabsTabActivationDirection",+ "TabsTabMetadata": "primitives/navigation/Tabs/types/TabsTabMetadata",+ "TabsTabPosition": "primitives/navigation/Tabs/types/TabsTabPosition",+ "TabsTabProps": "primitives/navigation/Tabs/types/TabsTabProps",+ "TabsTabSize": "primitives/navigation/Tabs/types/TabsTabSize",+ "TabsTabState": "primitives/navigation/Tabs/types/TabsTabState",+ "TabsTabValue": "primitives/navigation/Tabs/types/TabsTabValue"}},"primitives/surfaces": {diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex cf5e9e82e18..6ae33d60e8d 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -5519,6 +5519,39 @@}]},+ {+ "name": "Indicator",+ "props": [+ {+ "name": "className",+ "type": "string | ((state: TabsIndicatorState) => string | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."+ },+ {+ "name": "render",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TabsIndicatorState>",+ "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."+ },+ {+ "name": "renderBeforeHydration",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Whether to render itself before React hydrates.\nThis minimizes the time that the indicator isn't visible after server-side rendering."+ },+ {+ "name": "style",+ "type": "CSSProperties | ((state: TabsIndicatorState) => CSSProperties | undefined)",+ "required": false,+ "defaultValue": null,+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."+ }+ ]+ },{"name": "Panel","props": [@@ -11514,7 +11547,7 @@"type": "\"md\" | \"sm\"","required": false,"defaultValue": "sm",- "description": "Padding of the tab content: sm or md."+ "description": "Padding of the tab content: sm or md. Explicit size takes precedence over the ButtonGroup size, then sm applies."},{"name": "startIcon",diff --git a/packages/twenty-ui/src/components/data-display/NotificationCounter/__stories__/NotificationCounter.stories.tsx b/packages/twenty-ui/src/components/data-display/NotificationCounter/__stories__/NotificationCounter.stories.tsxindex 8d6497ff130..1082c1f5309 100644--- a/packages/twenty-ui/src/components/data-display/NotificationCounter/__stories__/NotificationCounter.stories.tsx+++ b/packages/twenty-ui/src/components/data-display/NotificationCounter/__stories__/NotificationCounter.stories.tsx@@ -32,6 +32,7 @@ export const WithIconAndBadge: Story = {</Tabs.Tab><Tabs.Tab value="activity">Activity</Tabs.Tab><Tabs.Tab value="settings">Settings</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview" style={{ padding: 'var(--t-spacing-4)' }}>Record overviewdiff --git a/packages/twenty-ui/src/components/navigation/TabButton/TabButton.tsx b/packages/twenty-ui/src/components/navigation/TabButton/TabButton.tsxindex f5d8ff2937c..2cfb47decc8 100644--- a/packages/twenty-ui/src/components/navigation/TabButton/TabButton.tsx+++ b/packages/twenty-ui/src/components/navigation/TabButton/TabButton.tsx@@ -1,6 +1,8 @@import { clsx } from 'clsx';+import { useContext } from 'react';import { Button } from '@ui/primitives/input/Button/Button';+import { ButtonGroupContext } from '@ui/primitives/input/ButtonGroup/internal/ButtonGroupContext';import { TabsTabContent } from '@ui/primitives/navigation/internal/tab/TabsTabContent';import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';@@ -15,18 +17,23 @@ export const TabButton = ({startIcon,endIcon,badge,- size = 'sm',+ size,...props-}: TabButtonProps) => (- <Button- {...props}- variant="ghost"- size={size}- data-active={active || undefined}- className={mergeClassNames(clsx(tabStyles.tab, styles.button), className)}- >- <TabsTabContent startIcon={startIcon} endIcon={endIcon} badge={badge}>- {children}- </TabsTabContent>- </Button>-);+}: TabButtonProps) => {+ const buttonGroup = useContext(ButtonGroupContext);+ const resolvedSize = size ?? buttonGroup?.size ?? 'sm';++ return (+ <Button+ {...props}+ variant="ghost"+ size={resolvedSize}+ data-active={active || undefined}+ className={mergeClassNames(clsx(tabStyles.tab, styles.button), className)}+ >+ <TabsTabContent startIcon={startIcon} endIcon={endIcon} badge={badge}>+ {children}+ </TabsTabContent>+ </Button>+ );+};diff --git a/packages/twenty-ui/src/components/navigation/TabButton/__stories__/TabButton.stories.tsx b/packages/twenty-ui/src/components/navigation/TabButton/__stories__/TabButton.stories.tsxindex 704d032df8a..0dd9eff0d14 100644--- a/packages/twenty-ui/src/components/navigation/TabButton/__stories__/TabButton.stories.tsx+++ b/packages/twenty-ui/src/components/navigation/TabButton/__stories__/TabButton.stories.tsx@@ -19,7 +19,6 @@ import {type CatalogStory,} from '@ui/testing';import { type ReactNode } from 'react';-import { expect, fn, userEvent, within } from 'storybook/test';import styles from './TabButton.stories.module.scss';@@ -246,39 +245,6 @@ export const Catalog: CatalogStory<Story, typeof TabButton> = {decorators: [CatalogDecorator],};-export const KeyboardAction: Story = {- args: { children: 'New Tab', startIcon: <IconUser />, onClick: fn() },- render: Default.render,- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);- const button = canvas.getByRole('button', { name: 'New Tab' });-- button.focus();- await userEvent.keyboard('{Enter}');- expect(args.onClick).toHaveBeenCalledTimes(1);- expect(button).toHaveAttribute('type', 'button');- },-};--export const DisabledLink: Story = {- args: {- children: 'Unavailable',- href: '#unavailable',- disabled: true,- onClick: fn(),- },- render: Default.render,- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);- const link = canvas.getByRole('link', { name: 'Unavailable' });-- expect(link).toHaveAttribute('aria-disabled', 'true');- await userEvent.click(link);- expect(args.onClick).not.toHaveBeenCalled();- expect(link).not.toHaveAttribute('type');- },-};-export const MatchingTabContent: Story = {args: {children: 'Messages',@@ -299,22 +265,27 @@ export const MatchingTabContent: Story = {>{args.children}</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="messages">Messages content</Tabs.Panel></Tabs.Root></>),- play: async ({ canvasElement }) => {- const canvas = within(canvasElement);- const button = canvas.getByRole('button', { name: 'Messages 12' });- const tab = canvas.getByRole('tab', { name: 'Messages 12' });+};- expect(button.getBoundingClientRect().width).toBe(- tab.getBoundingClientRect().width,- );- expect(button.getBoundingClientRect().height).toBe(- tab.getBoundingClientRect().height,- );- expect(getComputedStyle(button).color).toBe(getComputedStyle(tab).color);+export const CurrentRoute: Story = {+ args: {+ children: 'Overview',+ href: '#overview',+ active: true,+ 'aria-current': 'page',},+ render: (args) => (+ <nav aria-label="Workspace pages">+ <TabContainer>+ <TabButton {...args} />+ <TabButton href="#settings">Settings</TabButton>+ </TabContainer>+ </nav>+ ),};diff --git a/packages/twenty-ui/src/components/navigation/TabButton/__stories__/TabButtonInteractions.stories.tsx b/packages/twenty-ui/src/components/navigation/TabButton/__stories__/TabButtonInteractions.stories.tsxnew file mode 100644index 00000000000..16e5a15da40--- /dev/null+++ b/packages/twenty-ui/src/components/navigation/TabButton/__stories__/TabButtonInteractions.stories.tsx@@ -0,0 +1,111 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { TabButton } from '@ui/components/navigation/TabButton/TabButton';+import { ComponentDecorator } from '@ui/testing';+import { useRef } from 'react';+import { expect, fn, userEvent, within } from 'storybook/test';++import { MatchingTabContent as MatchingTabContentPresentation } from './TabButton.stories';++const meta: Meta<typeof TabButton> = {+ id: 'ui-components-tabbutton-interactions',+ title: 'UI/Components/Navigation/TabButton/Interactions',+ component: TabButton,+ decorators: [ComponentDecorator],+};++export default meta;+type Story = StoryObj<typeof TabButton>;++export const KeyboardAction: Story = {+ args: { children: 'New view', onClick: fn() },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const button = canvas.getByRole('button', { name: 'New view' });+ button.focus();+ await userEvent.keyboard('{Enter}');+ await userEvent.keyboard(' ');+ expect(args.onClick).toHaveBeenCalledTimes(2);+ expect(button).toHaveAttribute('type', 'button');+ expect(button).not.toHaveAttribute('aria-selected');+ expect(button).not.toHaveAttribute('aria-controls');+ expect(canvas.queryByRole('tab')).not.toBeInTheDocument();+ },+};++export const DisabledLink: Story = {+ args: {+ children: 'Unavailable',+ href: '#unavailable',+ disabled: true,+ onClick: fn(),+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const link = canvas.getByRole('link', { name: 'Unavailable' });+ expect(link).toHaveAttribute('aria-disabled', 'true');+ await userEvent.click(link);+ expect(args.onClick).not.toHaveBeenCalled();+ expect(link).not.toHaveAttribute('type');+ },+};++export const RouteComposition: Story = {+ args: { onClick: fn((event) => event.preventDefault()) },+ render: function Render(args) {+ const anchorRef = useRef<HTMLAnchorElement>(null);+ return (+ <nav aria-label="Workspace pages">+ <TabButton+ {...args}+ active+ aria-current="page"+ nativeButton={false}+ role="link"+ render={(props) => (+ <a {...props} href="#overview">+ {props.children}+ </a>+ )}+ ref={anchorRef}+ onFocus={() => {+ anchorRef.current?.setAttribute('data-ref-target', 'anchor');+ }}+ >+ Overview+ </TabButton>+ <TabButton href="#settings">Settings</TabButton>+ </nav>+ );+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const route = canvas.getByRole('link', { name: 'Overview' });+ route.focus();+ expect(route).toHaveAttribute('data-ref-target', 'anchor');+ expect(route.tagName).toBe('A');+ expect(route).toHaveAttribute('aria-current', 'page');+ await userEvent.keyboard('{Enter}');+ expect(args.onClick).toHaveBeenCalledTimes(1);+ expect(canvas.getByRole('link', { name: 'Settings' })).not.toHaveAttribute(+ 'aria-current',+ );+ expect(canvas.queryByRole('tablist')).not.toBeInTheDocument();+ expect(canvas.queryByRole('tabpanel')).not.toBeInTheDocument();+ },+};++export const MatchingTabContent: Story = {+ ...MatchingTabContentPresentation,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const button = canvas.getByRole('button', { name: 'Messages 12' });+ const tab = canvas.getByRole('tab', { name: 'Messages 12' });+ expect(button.getBoundingClientRect().width).toBe(+ tab.getBoundingClientRect().width,+ );+ expect(button.getBoundingClientRect().height).toBe(+ tab.getBoundingClientRect().height,+ );+ expect(getComputedStyle(button).color).toBe(getComputedStyle(tab).color);+ },+};diff --git a/packages/twenty-ui/src/components/navigation/TabButton/__tests__/TabButton.test.tsx b/packages/twenty-ui/src/components/navigation/TabButton/__tests__/TabButton.test.tsxindex d26e5483e3c..2cef0a24f82 100644--- a/packages/twenty-ui/src/components/navigation/TabButton/__tests__/TabButton.test.tsx+++ b/packages/twenty-ui/src/components/navigation/TabButton/__tests__/TabButton.test.tsx@@ -1,3 +1,9 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { createRef, type MouseEvent } from 'react';+import { describe, expect, it, vi } from 'vitest';++import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';import { TabButton } from '../TabButton';@@ -17,3 +23,109 @@ runComponentConformance({ownClassName: styles.button,renderPropTagName: 'a',});++describe('TabButton semantics and appearance', () => {+ it('keeps route links separate from panel tabs and forwards explicit current state', () => {+ render(+ <nav aria-label="Pages">+ <TabButton href="#overview" active aria-current="page">+ Overview+ </TabButton>+ <TabButton href="#settings" active>+ Settings+ </TabButton>+ </nav>,+ );++ const currentRoute = screen.getByRole('link', { name: 'Overview' });+ expect(currentRoute).toHaveAttribute('aria-current', 'page');+ expect(screen.getByRole('link', { name: 'Settings' })).not.toHaveAttribute(+ 'aria-current',+ );+ expect(currentRoute).not.toHaveAttribute('aria-controls');+ expect(currentRoute).not.toHaveAttribute('aria-selected');+ expect(screen.queryByRole('tablist')).not.toBeInTheDocument();+ expect(screen.queryByRole('tab')).not.toBeInTheDocument();+ });++ it('uses explicit child size before group size before its standalone default', () => {+ render(+ <>+ <TabButton>Standalone</TabButton>+ <ButtonGroup size="md" aria-label="Page actions">+ <TabButton>Inherited</TabButton>+ <TabButton size="sm">Explicit</TabButton>+ </ButtonGroup>+ </>,+ );++ expect(screen.getByRole('button', { name: 'Standalone' })).toHaveAttribute(+ 'data-size',+ 'sm',+ );+ expect(screen.getByRole('button', { name: 'Inherited' })).toHaveAttribute(+ 'data-size',+ 'md',+ );+ expect(screen.getByRole('button', { name: 'Explicit' })).toHaveAttribute(+ 'data-size',+ 'sm',+ );+ });++ it('preserves explicit native button composition and actual refs', async () => {+ const user = userEvent.setup();+ const buttonRef = createRef<HTMLButtonElement>();+ const onClick = vi.fn();+ render(+ <TabButton+ render={<button name="create" value="record" />}+ nativeButton+ ref={buttonRef}+ onClick={onClick}+ >+ Create+ </TabButton>,+ );++ const button = screen.getByRole('button', { name: 'Create' });+ expect(buttonRef.current).toBe(button);+ expect(button).toHaveAttribute('name', 'create');+ expect(button).toHaveAttribute('value', 'record');+ await user.click(button);+ expect(onClick).toHaveBeenCalledTimes(1);+ expect(button).not.toHaveAttribute('aria-selected');+ expect(button).not.toHaveAttribute('aria-controls');+ });++ it('composes callback-rendered anchors without inferring panel semantics', async () => {+ const user = userEvent.setup();+ const anchorRef = createRef<HTMLAnchorElement>();+ const onClick = vi.fn((event: MouseEvent) => event.preventDefault());+ render(+ <TabButton+ nativeButton={false}+ role="link"+ render={(props) => (+ <a {...props} href="#activity">+ {props.children}+ </a>+ )}+ ref={anchorRef}+ active+ aria-current="page"+ onClick={onClick}+ >+ Activity+ </TabButton>,+ );++ const link = screen.getByRole('link', { name: 'Activity' });+ expect(anchorRef.current).toBe(link);+ expect(link).toHaveAttribute('href', '#activity');+ expect(link).toHaveAttribute('aria-current', 'page');+ expect(link).not.toHaveAttribute('type');+ await user.click(link);+ expect(onClick).toHaveBeenCalledTimes(1);+ });+});diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/Tabs.tsx b/packages/twenty-ui/src/primitives/navigation/Tabs/Tabs.tsxindex 619aae1e3f8..e43c63bca31 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/Tabs.tsx+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/Tabs.tsx@@ -1,3 +1,4 @@+import { TabsIndicator } from './internal/TabsIndicator';import { TabsList } from './internal/TabsList';import { TabsPanel } from './internal/TabsPanel';import { TabsRoot } from './internal/TabsRoot';@@ -7,5 +8,6 @@ export const Tabs = {Root: TabsRoot,List: TabsList,Tab: TabsTab,+ Indicator: TabsIndicator,Panel: TabsPanel,};diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.tsx b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.tsxindex 4424ceac0d4..0e390ac8cfe 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.tsx+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.tsx@@ -39,6 +39,7 @@ const TabsExample = ({<Tabs.Tab {...tabProps} /><Tabs.Tab value="activity">Activity</Tabs.Tab><Tabs.Tab value="settings">Settings</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panelvalue="overview"@@ -266,6 +267,7 @@ export const Catalog: CatalogStory<Story, typeof Tabs.Tab> = {<Tabs.Root value={args.value === 'selected' ? 'selected' : null}><Tabs.List aria-label="Record details"><Tabs.Tab {...args} />+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value={args.value} keepMounted /></Tabs.Root>diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/TabsInteractions.stories.tsx b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/TabsInteractions.stories.tsxindex 654133c5a66..d08332e1de7 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/TabsInteractions.stories.tsx+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/TabsInteractions.stories.tsx@@ -3,6 +3,10 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';import { useState } from 'react';import { expect, fn, userEvent, waitFor, within } from 'storybook/test';+import { IconInfoCircle } from '@ui/icon';+import { Button } from '@ui/primitives/input/Button/Button';+import { Input } from '@ui/primitives/input/Input/Input';+import { ComponentDecorator } from '@ui/testing';import tabStyles from '../../internal/tab/Tab.module.scss';@@ -39,9 +43,10 @@ const TabsInteractionExample = ({Activity</Tabs.Tab><Tabs.Tab value="settings">Settings</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview" keepMounted={keepMounted}>- <input aria-label="Draft" />+ <Input aria-label="Draft" /></Tabs.Panel><Tabs.Panel value="files" keepMounted={keepMounted}>Files content@@ -70,9 +75,7 @@ const ControlledTabsInteractionExample = ({onValueChange?.(nextValue, details);}}/>- <button type="button" onClick={() => setValue(pendingValue)}>- Apply selection- </button>+ <Button onClick={() => setValue(pendingValue)}>Apply selection</Button></>);};@@ -303,7 +306,7 @@ export const SlotsAndStateStyling: Story = {<Tabs.Tabvalue="activity"size="md"- startIcon={<svg data-testid="icon" />}+ startIcon={<IconInfoCircle data-testid="icon" />}badge={0}className={({ active }) =>active ? 'selected-consumer' : 'consumer'@@ -312,6 +315,7 @@ export const SlotsAndStateStyling: Story = {>Activity</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview">Overview content</Tabs.Panel><Tabs.Panel value="activity">Activity content</Tabs.Panel>@@ -347,6 +351,7 @@ export const EmptySlots: Story = {Tab {index + 1}</Tabs.Tab>))}+ <Tabs.Indicator /></Tabs.List></Tabs.Root>),@@ -378,6 +383,7 @@ export const PolymorphicTab: Story = {>Activity</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview">Overview content</Tabs.Panel><Tabs.Panel value="activity">Activity content</Tabs.Panel>@@ -395,3 +401,76 @@ export const PolymorphicTab: Story = {).toBeVisible();},};++export const CanceledAutomaticChange: Story = {+ decorators: [ComponentDecorator],+ args: {+ activateOnFocus: true,+ onValueChange: fn<NonNullable<TabsRootProps['onValueChange']>>(+ (_value, details) => details.cancel(),+ ),+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ await userEvent.click(canvas.getByRole('tab', { name: 'Overview' }));+ await userEvent.keyboard('{ArrowRight}');+ await expect(canvas.getByRole('tab', { name: 'Activity' })).toHaveFocus();+ await expect(+ canvas.getByRole('tabpanel', { name: 'Overview' }),+ ).toBeVisible();+ await expect(args.onValueChange).toHaveBeenCalledTimes(1);+ await expect(args.onValueChange).toHaveBeenCalledWith(+ 'activity',+ expect.objectContaining({ reason: 'none', isCanceled: true }),+ );+ },+};++export const ExplicitIndicator: Story = {+ decorators: [ComponentDecorator],+ render: () => (+ <Tabs.Root defaultValue="overview">+ <Tabs.List aria-label="Details">+ <Tabs.Tab value="overview">Overview</Tabs.Tab>+ <Tabs.Tab value="activity">Activity</Tabs.Tab>+ <Tabs.Indicator+ data-testid="indicator"+ className={({ activeTabSize }) =>+ activeTabSize ? 'measured-indicator' : undefined+ }+ render={(props, state) => (+ <span {...props} data-width={state.activeTabSize?.width} />+ )}+ />+ </Tabs.List>+ <Tabs.Panel value="overview">Overview content</Tabs.Panel>+ <Tabs.Panel value="activity">Activity content</Tabs.Panel>+ </Tabs.Root>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const indicator = canvas.getByTestId('indicator');+ const list = canvas.getByRole('tablist');+ await expect(list.querySelectorAll(`.${tabStyles.indicator}`)).toHaveLength(+ 1,+ );+ await expect(indicator).toHaveClass(+ tabStyles.indicator,+ 'measured-indicator',+ );+ await expect(indicator).toBeVisible();+ const overviewWidth = canvas+ .getByRole('tab', { name: 'Overview' })+ .getBoundingClientRect().width;+ await expect(Number(indicator.getAttribute('data-width'))).toBeCloseTo(+ overviewWidth,+ );+ await userEvent.click(canvas.getByRole('tab', { name: 'Activity' }));+ const activityWidth = canvas+ .getByRole('tab', { name: 'Activity' })+ .getBoundingClientRect().width;+ await expect(Number(indicator.getAttribute('data-width'))).toBeCloseTo(+ activityWidth,+ );+ },+};diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/TabsKeyboard.stories.tsx b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/TabsKeyboard.stories.tsxindex c5641641b60..9cb39afc7de 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/TabsKeyboard.stories.tsx+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/TabsKeyboard.stories.tsx@@ -1,6 +1,8 @@import { type Meta, type StoryObj } from '@storybook/react-vite';import { expect, fn, userEvent, within } from 'storybook/test';+import { Button } from '@ui/primitives/input/Button/Button';+import { ComponentDecorator } from '@ui/testing';import { Tabs } from '../Tabs';@@ -28,6 +30,7 @@ const TabsKeyboardExample = ({<Tabs.Tab value="last" disabled>Last</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview">Overview content</Tabs.Panel><Tabs.Panel value="activity">Activity content</Tabs.Panel>@@ -135,6 +138,7 @@ export const DisabledPolymorphicTab: Story = {>Activity</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview">Overview content</Tabs.Panel><Tabs.Panel value="activity">Activity content</Tabs.Panel>@@ -155,7 +159,7 @@ export const AllDisabled: Story = {decorators: [ComponentDecorator],render: (args) => (<>- <button type="button">Before tabs</button>+ <Button>Before tabs</Button><Tabs.Root value="overview" onValueChange={args.onValueChange}><Tabs.List aria-label="Details"><Tabs.Tab value="overview" disabled>@@ -164,6 +168,7 @@ export const AllDisabled: Story = {<Tabs.Tab value="activity" disabled>Activity</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="overview">Overview content</Tabs.Panel></Tabs.Root>@@ -185,12 +190,14 @@ export const NestedTabs: Story = {<Tabs.Root defaultValue="outer" onKeyDown={args.onKeyDown}><Tabs.List aria-label="Outer"><Tabs.Tab value="outer">Outer</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="outer"><Tabs.Root defaultValue="inner"><Tabs.List aria-label="Inner" activateOnFocus><Tabs.Tab value="inner">Inner</Tabs.Tab><Tabs.Tab value="next">Next</Tabs.Tab>+ <Tabs.Indicator /></Tabs.List><Tabs.Panel value="inner">Inner content</Tabs.Panel><Tabs.Panel value="next">Next content</Tabs.Panel>@@ -207,6 +214,6 @@ export const NestedTabs: Story = {'aria-selected','true',);- await expect(args.onKeyDown).toHaveBeenCalledTimes(1);+ await expect(args.onKeyDown).not.toHaveBeenCalled();},};diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/__tests__/Tabs.behavior.test.tsx b/packages/twenty-ui/src/primitives/navigation/Tabs/__tests__/Tabs.behavior.test.tsxnew file mode 100644index 00000000000..651df65bba0--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/__tests__/Tabs.behavior.test.tsx@@ -0,0 +1,212 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { createRef } from 'react';++import { type TabsTabProps } from '../types/TabsTabProps';+import { describe, expect, it, vi } from 'vitest';++import styles from '../../internal/tab/Tab.module.scss';+import { Tabs } from '../Tabs';+import { type TabsListProps } from '../types/TabsListProps';+import { type TabsRootProps } from '../types/TabsRootProps';++const TabsExample = ({+ rootProps,+ listProps,+ disabledActivity = false,+ indicator = true,+}: {+ rootProps?: TabsRootProps;+ listProps?: TabsListProps;+ disabledActivity?: boolean;+ indicator?: boolean;+}) => (+ <Tabs.Root defaultValue="overview" {...rootProps}>+ <Tabs.List aria-label="Details" {...listProps}>+ <Tabs.Tab value="overview">Overview</Tabs.Tab>+ <Tabs.Tab value="activity" disabled={disabledActivity}>+ Activity+ </Tabs.Tab>+ <Tabs.Tab value="settings">Settings</Tabs.Tab>+ {indicator && <Tabs.Indicator data-testid="indicator" />}+ </Tabs.List>+ <Tabs.Panel value="overview">Overview content</Tabs.Panel>+ <Tabs.Panel value="activity">Activity content</Tabs.Panel>+ <Tabs.Panel value="settings">Settings content</Tabs.Panel>+ </Tabs.Root>+);++describe('Tabs behavior', () => {+ it('keeps manual arrow focus separate from selection and labels the selected panel', async () => {+ const user = userEvent.setup();+ const onValueChange = vi.fn();+ render(<TabsExample rootProps={{ onValueChange }} disabledActivity />);++ await user.click(screen.getByRole('tab', { name: 'Overview' }));+ await user.keyboard('{ArrowRight}');++ const settings = screen.getByRole('tab', { name: 'Settings' });+ expect(settings).toHaveFocus();+ expect(screen.getByRole('tabpanel', { name: 'Overview' })).toBeVisible();+ expect(onValueChange).not.toHaveBeenCalled();++ await user.keyboard('{Enter}');++ const panel = screen.getByRole('tabpanel', { name: 'Settings' });+ expect(settings).toHaveAttribute('aria-controls', panel.id);+ expect(panel).toHaveAttribute('aria-labelledby', settings.id);+ expect(panel).toHaveTextContent('Settings content');+ expect(onValueChange).toHaveBeenCalledWith(+ 'settings',+ expect.objectContaining({+ reason: 'none',+ event: expect.objectContaining({ type: 'click' }),+ }),+ );+ });++ it('allows automatic arrow activation to be canceled while focus skips disabled tabs', async () => {+ const user = userEvent.setup();+ const onValueChange = vi.fn<NonNullable<TabsRootProps['onValueChange']>>(+ (_value, details) => details.cancel(),+ );+ render(+ <TabsExample+ rootProps={{ onValueChange }}+ listProps={{ activateOnFocus: true }}+ disabledActivity+ />,+ );++ await user.click(screen.getByRole('tab', { name: 'Overview' }));+ await user.keyboard('{ArrowRight}');++ expect(screen.getByRole('tab', { name: 'Settings' })).toHaveFocus();+ expect(screen.getByRole('tabpanel', { name: 'Overview' })).toBeVisible();+ expect(onValueChange).toHaveBeenCalledOnce();+ expect(onValueChange).toHaveBeenCalledWith(+ 'settings',+ expect.objectContaining({ reason: 'none', isCanceled: true }),+ );+ });++ it('retains the controlled value until the parent commits a requested change', async () => {+ const user = userEvent.setup();+ const onValueChange = vi.fn();+ const { rerender } = render(+ <TabsExample rootProps={{ value: 'overview', onValueChange }} />,+ );++ await user.click(screen.getByRole('tab', { name: 'Activity' }));++ expect(onValueChange).toHaveBeenCalledWith('activity', expect.anything());+ expect(screen.getByRole('tabpanel', { name: 'Overview' })).toBeVisible();++ rerender(<TabsExample rootProps={{ value: 'activity', onValueChange }} />);++ expect(screen.getByRole('tabpanel', { name: 'Activity' })).toBeVisible();+ await user.keyboard('{ArrowRight}');+ expect(screen.getByRole('tab', { name: 'Settings' })).toHaveFocus();+ expect(screen.getByRole('tabpanel', { name: 'Activity' })).toBeVisible();+ });++ it('preserves arbitrary value identity and canceled click changes', async () => {+ const user = userEvent.setup();+ const overview = { id: 'overview' };+ const activity = { id: 'activity' };+ const onValueChange = vi.fn<NonNullable<TabsRootProps['onValueChange']>>(+ (_value, details) => details.cancel(),+ );+ render(+ <Tabs.Root defaultValue={overview} onValueChange={onValueChange}>+ <Tabs.List aria-label="Details">+ <Tabs.Tab value={overview}>Overview</Tabs.Tab>+ <Tabs.Tab value={activity}>Activity</Tabs.Tab>+ <Tabs.Indicator />+ </Tabs.List>+ <Tabs.Panel value={overview}>Overview content</Tabs.Panel>+ <Tabs.Panel value={activity}>Activity content</Tabs.Panel>+ </Tabs.Root>,+ );++ await user.click(screen.getByRole('tab', { name: 'Activity' }));++ expect(onValueChange.mock.calls[0]?.[0]).toBe(activity);+ expect(onValueChange.mock.calls[0]?.[1].event).toBeInstanceOf(MouseEvent);+ expect(screen.getByRole('tabpanel', { name: 'Overview' })).toBeVisible();+ });++ it('reports an uncancelable disabled fallback for an uncontrolled selected tab', async () => {+ const user = userEvent.setup();+ const onValueChange = vi.fn<NonNullable<TabsRootProps['onValueChange']>>(+ (_value, details) => {+ if (details.reason === 'disabled') {+ details.cancel();+ }+ },+ );+ const { rerender } = render(<TabsExample rootProps={{ onValueChange }} />);+ await user.click(screen.getByRole('tab', { name: 'Activity' }));++ rerender(<TabsExample rootProps={{ onValueChange }} disabledActivity />);++ expect(screen.getByRole('tabpanel', { name: 'Overview' })).toBeVisible();+ expect(onValueChange).toHaveBeenLastCalledWith(+ 'overview',+ expect.objectContaining({+ reason: 'disabled',+ activationDirection: 'none',+ }),+ );+ });++ it('renders only an explicitly composed indicator', () => {+ const { rerender } = render(<TabsExample indicator={false} />);+ expect(+ screen.getByRole('tablist').querySelector(`.${styles.indicator}`),+ ).toBeNull();++ rerender(<TabsExample />);++ const indicator = screen.getByTestId('indicator');+ expect(indicator).toHaveClass(styles.indicator);+ expect(+ screen.getByRole('tablist').querySelectorAll(`.${styles.indicator}`),+ ).toHaveLength(1);+ });++ it('keeps anchor composition and its ref on the actual tab element', async () => {+ const user = userEvent.setup();+ const ref = createRef<HTMLAnchorElement>();+ const onClick = vi.fn<NonNullable<TabsTabProps['onClick']>>((event) =>+ event.preventDefault(),+ );+ render(+ <Tabs.Root defaultValue="overview">+ <Tabs.List aria-label="Details">+ <Tabs.Tab value="overview">Overview</Tabs.Tab>+ <Tabs.Tab+ value="activity"+ ref={ref}+ nativeButton={false}+ render={<a href="#activity" aria-label="Activity" />}+ onClick={onClick}+ >+ Activity+ </Tabs.Tab>+ <Tabs.Indicator />+ </Tabs.List>+ <Tabs.Panel value="overview">Overview content</Tabs.Panel>+ <Tabs.Panel value="activity">Activity content</Tabs.Panel>+ </Tabs.Root>,+ );++ const activity = screen.getByRole('tab', { name: 'Activity' });+ expect(ref.current).toBe(activity);+ expect(activity).toBeInstanceOf(HTMLAnchorElement);+ expect(activity).toHaveAttribute('href', '#activity');+ await user.click(activity);+ expect(onClick).toHaveBeenCalledOnce();+ expect(screen.getByRole('tabpanel', { name: 'Activity' })).toBeVisible();+ });+});diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/__tests__/Tabs.test.tsx b/packages/twenty-ui/src/primitives/navigation/Tabs/__tests__/Tabs.test.tsxindex f6aad0b2c3e..6913c8eeb85 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/__tests__/Tabs.test.tsx+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/__tests__/Tabs.test.tsx@@ -15,6 +15,13 @@ const ListWrapper = ({ children }: { children: ReactNode }) => (</RootWrapper>);+const IndicatorWrapper = ({ children }: { children: ReactNode }) => (+ <ListWrapper>+ <Tabs.Tab value="overview">Overview</Tabs.Tab>+ {children}+ </ListWrapper>+);+runComponentConformance({name: 'Tabs.Root',element: <Tabs.Root />,@@ -49,3 +56,12 @@ runComponentConformance({renderPropTagName: 'div',wrapper: RootWrapper,});++runComponentConformance({+ name: 'Tabs.Indicator',+ element: <Tabs.Indicator />,+ refInstanceOf: HTMLSpanElement,+ ownClassName: styles.indicator,+ renderPropTagName: 'span',+ wrapper: IndicatorWrapper,+});diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/internal/TabsIndicator.tsx b/packages/twenty-ui/src/primitives/navigation/Tabs/internal/TabsIndicator.tsxnew file mode 100644index 00000000000..6ed8e3d1e58--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/internal/TabsIndicator.tsx@@ -0,0 +1,13 @@+import { Tabs as TabsPrimitive } from '@base-ui/react/tabs';++import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';++import styles from '../../internal/tab/Tab.module.scss';+import { type TabsIndicatorProps } from '../types/TabsIndicatorProps';++export const TabsIndicator = ({ className, ...props }: TabsIndicatorProps) => (+ <TabsPrimitive.Indicator+ {...props}+ className={mergeClassNames(styles.indicator, className)}+ />+);diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/internal/TabsList.tsx b/packages/twenty-ui/src/primitives/navigation/Tabs/internal/TabsList.tsxindex f5f9110ac14..985687a4720 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/internal/TabsList.tsx+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/internal/TabsList.tsx@@ -9,7 +9,6 @@ import { focusNextEnabledTab } from './focusNextEnabledTab';export const TabsList = ({className,- children,onKeyDown,loopFocus = true,...props@@ -37,9 +36,6 @@ export const TabsList = ({loopFocus={loopFocus}onKeyDown={handleKeyDown}className={mergeClassNames(styles.list, className)}- >- {children}- <TabsPrimitive.Indicator className={styles.indicator} />- </TabsPrimitive.List>+ />);};diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/internal/focusNextEnabledTab.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/internal/focusNextEnabledTab.tsindex 9e4a094d274..266fadf4e6f 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/internal/focusNextEnabledTab.ts+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/internal/focusNextEnabledTab.ts@@ -10,6 +10,16 @@ type FocusNextEnabledTabOptions = {loopFocus: boolean;};+const TAB_SELECTOR = '[role="tab"]';+const TAB_LIST_SELECTOR = '[role="tablist"]';+const UNAVAILABLE_TAB_ANCESTOR_SELECTOR = '[hidden], [inert]';++const isUnavailableTab = (tab: HTMLElement) =>+ tab.hasAttribute('data-disabled') ||+ tab.hasAttribute('disabled') ||+ tab.getAttribute('aria-disabled') === 'true' ||+ isDefined(tab.closest(UNAVAILABLE_TAB_ANCESTOR_SELECTOR));+export const focusNextEnabledTab = ({event,direction,@@ -20,9 +30,14 @@ export const focusNextEnabledTab = ({}const list = event.currentTarget;- const tabs = Array.from(- list.querySelectorAll<HTMLElement>('[role="tab"]'),- ).filter((tab) => tab.closest('[role="tablist"]') === list);+ const tabs: HTMLElement[] = [];+ list.querySelectorAll<HTMLElement>(TAB_SELECTOR).forEach((tab) => {+ if (tab.closest(TAB_LIST_SELECTOR) !== list) {+ return;+ }++ tabs.push(tab);+ });const currentIndex = tabs.findIndex((tab) => tab === event.target);if (currentIndex === -1) {@@ -34,7 +49,7 @@ export const focusNextEnabledTab = ({? ['ArrowLeft', 'ArrowRight']: ['ArrowRight', 'ArrowLeft'];const [forwardKey, backwardKey] =- list.getAttribute('aria-orientation') === 'vertical'+ list.getAttribute('data-orientation') === 'vertical'? ['ArrowDown', 'ArrowUp']: horizontalKeys;@@ -42,42 +57,55 @@ export const focusNextEnabledTab = ({return;}- // Base UI 1.5 intentionally focuses disabled tabs; Twenty skips them.+ const isBackward = event.key === backwardKey;+ let candidateIndex = currentIndex + (isBackward ? -1 : 1);++ if (event.key === 'Home') {+ candidateIndex = 0;+ }++ if (event.key === 'End') {+ candidateIndex = tabs.length - 1;+ }++ const isOutsideTabs = candidateIndex < 0 || candidateIndex >= tabs.length;+ const wrappedIndex = isBackward ? tabs.length - 1 : 0;+ const candidate =+ tabs[isOutsideTabs && loopFocus ? wrappedIndex : candidateIndex];++ if (!isDefined(candidate) || !isUnavailableTab(candidate)) {+ return;+ }+event.preventBaseUIHandler();event.preventDefault();- const enabledTabs = tabs.filter(- (tab) =>- !tab.hasAttribute('data-disabled') &&- !tab.hasAttribute('disabled') &&- tab.getAttribute('aria-disabled') !== 'true' &&- !tab.closest('[hidden], [inert]'),- );+ const enabledTabs = tabs.filter((tab) => !isUnavailableTab(tab));+ let nextTab: HTMLElement | undefined;if (event.key === 'Home') {- enabledTabs[0]?.focus();- return;+ nextTab = enabledTabs[0];}if (event.key === 'End') {- enabledTabs[enabledTabs.length - 1]?.focus();- return;+ nextTab = enabledTabs[enabledTabs.length - 1];}- const isBackward = event.key === backwardKey;- const orderedTabs = isBackward ? [...enabledTabs].reverse() : enabledTabs;- const nextTab = orderedTabs.find((tab) =>- isBackward- ? tabs.indexOf(tab) < currentIndex- : tabs.indexOf(tab) > currentIndex,- );-- if (isDefined(nextTab)) {- nextTab.focus();- return;+ if (event.key === forwardKey || event.key === backwardKey) {+ const orderedTabs = isBackward ? [...enabledTabs].reverse() : enabledTabs;+ nextTab = orderedTabs.find((tab) =>+ isBackward+ ? tabs.indexOf(tab) < currentIndex+ : tabs.indexOf(tab) > currentIndex,+ );+ nextTab ??= loopFocus ? orderedTabs[0] : undefined;}- if (loopFocus) {- orderedTabs[0]?.focus();+ if (!isDefined(nextTab) || nextTab === event.target) {+ return;}++ event.stopPropagation();+ const nextEnabledTab = nextTab;+ queueMicrotask(() => nextEnabledTab.focus());};diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsIndicatorProps.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsIndicatorProps.tsnew file mode 100644index 00000000000..c94c903c838--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsIndicatorProps.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsIndicatorProps = TabsPrimitive.Indicator.Props;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsIndicatorState.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsIndicatorState.tsnew file mode 100644index 00000000000..8b983670670--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsIndicatorState.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsIndicatorState = TabsPrimitive.Indicator.State;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsListState.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsListState.tsnew file mode 100644index 00000000000..6fcd70dd611--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsListState.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsListState = TabsPrimitive.List.State;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsPanelMetadata.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsPanelMetadata.tsnew file mode 100644index 00000000000..3bc0f725f0b--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsPanelMetadata.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsPanelMetadata = TabsPrimitive.Panel.Metadata;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsPanelState.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsPanelState.tsnew file mode 100644index 00000000000..9d5a7ced7f4--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsPanelState.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsPanelState = TabsPrimitive.Panel.State;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootChangeEventDetails.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootChangeEventDetails.tsnew file mode 100644index 00000000000..52bcf5cefcd--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootChangeEventDetails.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsRootChangeEventDetails = TabsPrimitive.Root.ChangeEventDetails;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootChangeEventReason.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootChangeEventReason.tsnew file mode 100644index 00000000000..40d5b768580--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootChangeEventReason.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsRootChangeEventReason = TabsPrimitive.Root.ChangeEventReason;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootOrientation.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootOrientation.tsnew file mode 100644index 00000000000..a90359fe45a--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootOrientation.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsRootOrientation = TabsPrimitive.Root.Orientation;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootState.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootState.tsnew file mode 100644index 00000000000..35a5fa6147e--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsRootState.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsRootState = TabsPrimitive.Root.State;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabActivationDirection.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabActivationDirection.tsnew file mode 100644index 00000000000..48e9a9a21c0--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabActivationDirection.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsTabActivationDirection = TabsPrimitive.Tab.ActivationDirection;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabMetadata.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabMetadata.tsnew file mode 100644index 00000000000..d53b60ded48--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabMetadata.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsTabMetadata = TabsPrimitive.Tab.Metadata;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabPosition.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabPosition.tsnew file mode 100644index 00000000000..0a5e5c9b4b6--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabPosition.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsTabPosition = TabsPrimitive.Tab.Position;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabProps.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabProps.tsindex b540bc3a077..f2ffc313d7b 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabProps.ts+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabProps.ts@@ -1,9 +1,9 @@import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';-import { type ReactNode } from 'react';+import { type ComponentProps, type ReactNode } from 'react';import { type TabsSize } from './TabsSize';-export type TabsTabProps = TabsPrimitive.Tab.Props & {+export type TabsTabProps = ComponentProps<typeof TabsPrimitive.Tab> & {/** Icon rendered before the label. */startIcon?: ReactNode;/** Content rendered after the label, such as a count. */diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabSize.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabSize.tsnew file mode 100644index 00000000000..071e43b32bb--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabSize.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsTabSize = TabsPrimitive.Tab.Size;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabState.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabState.tsnew file mode 100644index 00000000000..24f797efb2f--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabState.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsTabState = TabsPrimitive.Tab.State;diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabValue.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabValue.tsnew file mode 100644index 00000000000..b0321f1b2f9--- /dev/null+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/types/TabsTabValue.ts@@ -0,0 +1,3 @@+import { type Tabs as TabsPrimitive } from '@base-ui/react/tabs';++export type TabsTabValue = TabsPrimitive.Tab.Value;diff --git a/packages/twenty-ui/src/primitives/navigation/index.ts b/packages/twenty-ui/src/primitives/navigation/index.tsindex 6df8c92487b..e6bd7586aa3 100644--- a/packages/twenty-ui/src/primitives/navigation/index.ts+++ b/packages/twenty-ui/src/primitives/navigation/index.ts@@ -17,8 +17,23 @@ export type { ListItemIndicator } from './ListItem/types/ListItemIndicator';export type { ListItemProps } from './ListItem/types/ListItemProps';export type { ListItemState } from './ListItem/types/ListItemState';export { Tabs } from './Tabs/Tabs';+export type { TabsIndicatorProps } from './Tabs/types/TabsIndicatorProps';+export type { TabsIndicatorState } from './Tabs/types/TabsIndicatorState';export type { TabsListProps } from './Tabs/types/TabsListProps';+export type { TabsListState } from './Tabs/types/TabsListState';+export type { TabsPanelMetadata } from './Tabs/types/TabsPanelMetadata';export type { TabsPanelProps } from './Tabs/types/TabsPanelProps';+export type { TabsPanelState } from './Tabs/types/TabsPanelState';+export type { TabsRootChangeEventDetails } from './Tabs/types/TabsRootChangeEventDetails';+export type { TabsRootChangeEventReason } from './Tabs/types/TabsRootChangeEventReason';+export type { TabsRootOrientation } from './Tabs/types/TabsRootOrientation';export type { TabsRootProps } from './Tabs/types/TabsRootProps';+export type { TabsRootState } from './Tabs/types/TabsRootState';export type { TabsSize } from './Tabs/types/TabsSize';+export type { TabsTabActivationDirection } from './Tabs/types/TabsTabActivationDirection';+export type { TabsTabMetadata } from './Tabs/types/TabsTabMetadata';+export type { TabsTabPosition } from './Tabs/types/TabsTabPosition';export type { TabsTabProps } from './Tabs/types/TabsTabProps';+export type { TabsTabSize } from './Tabs/types/TabsTabSize';+export type { TabsTabState } from './Tabs/types/TabsTabState';+export type { TabsTabValue } from './Tabs/types/TabsTabValue';