The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Let Tabs.Panel shrink on the block axis (#28052)
Raphaël Bosidafbe4e20896
diff --git a/packages/twenty-docs/ui/primitives/navigation/tabs.mdx b/packages/twenty-docs/ui/primitives/navigation/tabs.mdxindex 7a8ab1d59d5..c2ee9d9cdb5 100644--- a/packages/twenty-docs/ui/primitives/navigation/tabs.mdx+++ b/packages/twenty-docs/ui/primitives/navigation/tabs.mdx@@ -152,6 +152,10 @@ Use [DirectionProvider](/ui/primitives/layout/direction-provider) for RTL keyboaUse `keepMounted` when panel contents must retain their state while inactive. Inactive mounted panels remain hidden and do not occupy layout space.+## Panel layout++`Panel` fills the space left by the list and can shrink below its content on both axes, so it stays within a root of fixed height. To scroll its content, set `overflow: auto` on the panel, or on a child that fills it, such as a `flex: 1` child of a column flex panel.+## Native props, render composition, and refsAll 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.diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepTabPanel.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepTabPanel.tsxindex 759aff08ee8..7f2f398de27 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepTabPanel.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepTabPanel.tsx@@ -5,7 +5,6 @@ import { Tabs } from 'twenty-ui/primitives/navigation';const StyledPanel = styled.div`display: flex;flex-direction: column;- min-height: 0;`;type WorkflowStepTabPanelProps = {diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminWorkspaceDetail.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminWorkspaceDetail.tsxindex 0f076d679b6..6a26e7fc6a7 100644--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminWorkspaceDetail.tsx+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminWorkspaceDetail.tsx@@ -83,11 +83,6 @@ const WORKSPACE_DETAIL_TAB_IDS = {CHATS: 'chats',};-const StyledTabPanel = styled.div`- height: 100%;- min-height: 0;-`;-export const SettingsAdminWorkspaceDetail = () => {const { workspaceId } = useParams<{ workspaceId: string }>();const apolloAdminClient = useApolloAdminClient();@@ -339,7 +334,7 @@ export const SettingsAdminWorkspaceDetail = () => {/>}>- <Tabs.Panel value={effectiveTabId} render={<StyledTabPanel />}>+ <Tabs.Panel value={effectiveTabId}><SettingsPageContainer>{effectiveTabId === WORKSPACE_DETAIL_TAB_IDS.INFO && workspace && (<SettingsAdminWorkspaceContentdiff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.module.scss b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.module.scssindex a4d3c14a04a..4465617bb46 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.module.scss+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.module.scss@@ -1,3 +1,18 @@.panel {padding: var(--t-spacing-4);}++.fixedHeightRoot {+ block-size: 200px;+}++.scrollingPanel {+ display: flex;+ flex-direction: column;+}++.scrollArea {+ flex: 1;+ overflow: auto;+ padding: var(--t-spacing-4);+}diff --git a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.module.scss.d.ts b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.module.scss.d.tsindex 25ca51db313..9cdc4840dac 100644--- a/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.module.scss.d.ts+++ b/packages/twenty-ui/src/primitives/navigation/Tabs/__stories__/Tabs.stories.module.scss.d.ts@@ -1,4 +1,7 @@declare const classNames: {readonly panel: 'panel';+ readonly fixedHeightRoot: 'fixedHeightRoot';+ readonly scrollingPanel: 'scrollingPanel';+ readonly scrollArea: 'scrollArea';};export default classNames;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 6fa62743850..f1a5ef26928 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@@ -227,6 +227,53 @@ export const KeepMounted: Story = {},};+const ACTIVITY_LOG_ENTRIES = Array.from(+ { length: 12 },+ (_, index) => `Activity entry ${index + 1}`,+);++export const FixedHeight: Story = {+ decorators: [ComponentDecorator],+ parameters: { container: { width: 360 } },+ args: { value: 'activity', children: 'Activity' },+ render: (args) => (+ <Tabs.Root defaultValue="activity" className={styles.fixedHeightRoot}>+ <Tabs.List aria-label="Record details">+ <Tabs.Tab {...args} />+ <Tabs.Tab value="notes">Notes</Tabs.Tab>+ <Tabs.Indicator />+ </Tabs.List>+ <Tabs.Panel value="activity" className={styles.scrollingPanel}>+ <div+ role="region"+ aria-label="Activity log"+ tabIndex={0}+ className={styles.scrollArea}+ >+ {ACTIVITY_LOG_ENTRIES.map((entry) => (+ <p key={entry}>{entry}</p>+ ))}+ </div>+ </Tabs.Panel>+ <Tabs.Panel value="notes" className={styles.panel}>+ Record notes+ </Tabs.Panel>+ </Tabs.Root>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const activityLog = canvas.getByRole('region', { name: 'Activity log' });++ await expect(activityLog.scrollHeight).toBeGreaterThan(+ activityLog.clientHeight,+ );++ activityLog.scrollTop = activityLog.scrollHeight;++ await waitFor(() => expect(activityLog.scrollTop).toBeGreaterThan(0));+ },+};+export const RightToLeft: Story = {decorators: [ComponentDecorator],parameters: { container: { width: 300 } },diff --git a/packages/twenty-ui/src/primitives/navigation/internal/tab/Tab.module.scss b/packages/twenty-ui/src/primitives/navigation/internal/tab/Tab.module.scssindex 509ab9605bb..7ec79b40d7e 100644--- a/packages/twenty-ui/src/primitives/navigation/internal/tab/Tab.module.scss+++ b/packages/twenty-ui/src/primitives/navigation/internal/tab/Tab.module.scss@@ -142,6 +142,7 @@.panel {flex: 1;+ min-block-size: 0;min-inline-size: 0;@include focus-ring;