The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Allow custom FormFieldRow content padding (#28934)
Raphaël Bosi2e27e9727b4b
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/form-field-row.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/form-field-row.mdxindex 2acf1b3e5be..d4e5829372a 100644--- a/packages/twenty-docs/snippets/ui/generated/components/input/form-field-row.mdx+++ b/packages/twenty-docs/snippets/ui/generated/components/input/form-field-row.mdx@@ -19,6 +19,10 @@CSS class applied to the group root.</ParamField>+<ParamField body="contentPaddingInline" type="PaddingInline<string | number>" default="var(--t-spacing-2)">+ Inline padding around the field content, defaulting to the --t-spacing-2 theme token (8 pixels in the standard theme). Numbers use pixels; CSS padding values are also supported. Set 0 to align content with the row inset when no visible label is present.+</ParamField>+<ParamField body="hasDivider" type="boolean" default="true">Shows a decorative bottom divider. Set false on the final row when the surrounding surface supplies its own border.</ParamField>diff --git a/packages/twenty-docs/ui/components/input/form-field-row.mdx b/packages/twenty-docs/ui/components/input/form-field-row.mdxindex a4168ed0a86..e97683b9e32 100644--- a/packages/twenty-docs/ui/components/input/form-field-row.mdx+++ b/packages/twenty-docs/ui/components/input/form-field-row.mdx@@ -55,6 +55,14 @@ export const SubjectField = () => {The root is a group named by `label`. Supply `aria-label` or `aria-labelledby` when the visible label is omitted, and label each nested input separately. The row does not move focus or disable nested controls. Those controls retain their own keyboard behavior and focus styling.+`contentPaddingInline` defaults to the `--t-spacing-2` theme token, which is 8 pixels in the standard theme, and accepts a CSS padding value. Numeric values use pixels. Set `contentPaddingInline={0}` to align recipient chips and an input with the row inset when there is no visible label.++<StoryEmbed+ storyId="ui-input-formfieldrow--without-label"+ title="Recipient row without a visible label"+ height={110}+/>+## Events and customizationNative attributes, event handlers, `className`, `style`, `ref` and `render` apply to the group root. Forward supplied props and ref when replacing the root through `render`. An `onClick` handler shows a pointer cursor. The caller owns click-to-focus behavior and guards events from nested controls or portals when needed. `isHoverable` independently enables a neutral hover background.diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex 64316336911..2b12280bbad 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -1076,6 +1076,7 @@ export const DOCUMENTED_COMPONENTS = [propDescriptions: FORM_FIELD_ROW_PROP_DESCRIPTIONS,propDefaults: {labelWidth: '80',+ contentPaddingInline: 'var(--t-spacing-2)',isHoverable: 'false',hasDivider: 'true',},diff --git a/packages/twenty-ui/docs/formFieldRowPropDescriptions.ts b/packages/twenty-ui/docs/formFieldRowPropDescriptions.tsindex 4375cf37111..2d4b1ce02a3 100644--- a/packages/twenty-ui/docs/formFieldRowPropDescriptions.ts+++ b/packages/twenty-ui/docs/formFieldRowPropDescriptions.ts@@ -17,6 +17,8 @@ export const FORM_FIELD_ROW_PROP_DESCRIPTIONS = {'Native group click handler. Providing a handler shows a pointer cursor; the caller guards nested-control and portaled events as needed.',labelWidth:'Preferred label column width, capped at 40% of the row. Numbers use pixels; use the same width for aligned sibling rows.',+ contentPaddingInline:+ 'Inline padding around the field content, defaulting to the --t-spacing-2 theme token (8 pixels in the standard theme). Numbers use pixels; CSS padding values are also supported. Set 0 to align content with the row inset when no visible label is present.',isHoverable:'Enables a neutral hover background independently of click handlers. Keyboard focus remains on nested controls without changing the row background.',hasDivider:diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex bee974fc357..c6c0b082696 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -14914,6 +14914,13 @@"defaultValue": null,"description": "CSS class applied to the group root."},+ {+ "name": "contentPaddingInline",+ "type": "PaddingInline<string | number>",+ "required": false,+ "defaultValue": "var(--t-spacing-2)",+ "description": "Inline padding around the field content, defaulting to the --t-spacing-2 theme token (8 pixels in the standard theme). Numbers use pixels; CSS padding values are also supported. Set 0 to align content with the row inset when no visible label is present."+ },{"name": "hasDivider","type": "boolean",diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.module.scss b/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.module.scssindex faf3b1707ea..3d1412e29d4 100644--- a/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.module.scss+++ b/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.module.scss@@ -49,7 +49,10 @@gap: var(--t-spacing-1);min-inline-size: 0;overflow-wrap: anywhere;- padding-inline: var(--t-spacing-2);+ padding-inline: var(+ --form-field-row-content-padding-inline,+ var(--t-spacing-2)+ );}.trailing {diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.tsx b/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.tsxindex daf6722f189..423a3ac3e85 100644--- a/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.tsx+++ b/packages/twenty-ui/src/components/input/FormFieldRow/FormFieldRow.tsx@@ -1,10 +1,10 @@import { useRender } from '@base-ui/react/use-render';-import { isNumber } from '@sniptt/guards';import { clsx } from 'clsx';import { type CSSProperties } from 'react';import { Separator } from '@ui/primitives/layout/Separator/Separator';import { Text } from '@ui/primitives/typography/Text/Text';+import { formatCssLength } from '@ui/utilities/internal/formatCssLength';import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';import { isDefined } from '@ui/utilities/utils/isDefined';@@ -18,6 +18,7 @@ export const FormFieldRow = ({trailingProps,children,labelWidth = 80,+ contentPaddingInline,isHoverable = false,hasDivider = true,render,@@ -28,10 +29,12 @@ export const FormFieldRow = ({}: FormFieldRowProps) => {const rowStyle: CSSProperties & {'--form-field-row-label-width': string;+ '--form-field-row-content-padding-inline'?: string;} = {- '--form-field-row-label-width': isNumber(labelWidth)- ? `${labelWidth}px`- : labelWidth,+ '--form-field-row-label-width': formatCssLength(labelWidth),+ '--form-field-row-content-padding-inline': isDefined(contentPaddingInline)+ ? formatCssLength(contentPaddingInline)+ : undefined,...style,};diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/__stories__/FormFieldRow.stories.tsx b/packages/twenty-ui/src/components/input/FormFieldRow/__stories__/FormFieldRow.stories.tsxindex 8ac028cde3c..2ed907bc69c 100644--- a/packages/twenty-ui/src/components/input/FormFieldRow/__stories__/FormFieldRow.stories.tsx+++ b/packages/twenty-ui/src/components/input/FormFieldRow/__stories__/FormFieldRow.stories.tsx@@ -256,7 +256,38 @@ export const NarrowLayout: Story = {};export const WithoutLabel: Story = {- args: { label: undefined, 'aria-label': 'Subject field' },+ parameters: { container: { width: 280 } },+ args: {+ label: undefined,+ 'aria-label': 'Recipients',+ contentPaddingInline: 0,+ children: (+ <>+ <Chip variant="soft">Ada</Chip>+ <Input+ variant="plain"+ aria-label="Recipients"+ placeholder="Add people or a channel"+ style={{ flex: '1 1 100px' }}+ />+ </>+ ),+ },+};++export const WithoutLabelKeyboardFocus: Story = {+ ...WithoutLabel,+ tags: ['!autodocs'],+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const group = canvas.getByRole('group', { name: 'Recipients' });+ const input = canvas.getByRole('textbox', { name: 'Recipients' });++ await expect(group.scrollWidth).toBeLessThanOrEqual(group.clientWidth);+ await userEvent.tab();+ await expect(input).toHaveFocus();+ await expect(getComputedStyle(input).outlineStyle).not.toBe('none');+ },};export const Disabled: Story = {diff --git a/packages/twenty-ui/src/components/input/FormFieldRow/types/FormFieldRowProps.ts b/packages/twenty-ui/src/components/input/FormFieldRow/types/FormFieldRowProps.tsindex 0a141b2603e..7e29307bdf4 100644--- a/packages/twenty-ui/src/components/input/FormFieldRow/types/FormFieldRowProps.ts+++ b/packages/twenty-ui/src/components/input/FormFieldRow/types/FormFieldRowProps.ts@@ -11,6 +11,7 @@ export type FormFieldRowProps = Omit<trailingProps?: Omit<ComponentProps<'div'>, 'children'>;children: ReactNode;labelWidth?: CSSProperties['width'];+ contentPaddingInline?: CSSProperties['paddingInline'];isHoverable?: boolean;hasDivider?: boolean;};diff --git a/packages/twenty-ui/src/primitives/input/Textarea/internal/formatInlineBlockSize.ts b/packages/twenty-ui/src/primitives/input/Textarea/internal/formatInlineBlockSize.tsindex 9968a83d6ac..b0d4cee92fe 100644--- a/packages/twenty-ui/src/primitives/input/Textarea/internal/formatInlineBlockSize.ts+++ b/packages/twenty-ui/src/primitives/input/Textarea/internal/formatInlineBlockSize.ts@@ -1,6 +1,6 @@-import { isNumber } from '@sniptt/guards';import { type CSSProperties } from 'react';+import { formatCssLength } from '@ui/utilities/internal/formatCssLength';import { isDefined } from '@ui/utilities/utils/isDefined';export const formatInlineBlockSize = (@@ -10,5 +10,5 @@ export const formatInlineBlockSize = (return '';}- return isNumber(blockSize) ? `${blockSize}px` : String(blockSize);+ return formatCssLength(blockSize);};diff --git a/packages/twenty-ui/src/utilities/internal/formatCssLength.ts b/packages/twenty-ui/src/utilities/internal/formatCssLength.tsnew file mode 100644index 00000000000..f3cde430446--- /dev/null+++ b/packages/twenty-ui/src/utilities/internal/formatCssLength.ts@@ -0,0 +1,4 @@+import { isNumber } from '@sniptt/guards';++export const formatCssLength = (value: string | number): string =>+ isNumber(value) ? `${value}px` : value;