The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Align input and textarea integration (#27589)
Raphaël Bosi1cb897b9e7cb
diff --git a/packages/twenty-docs/snippets/ui/generated/input/input-group.mdx b/packages/twenty-docs/snippets/ui/generated/input/input-group.mdxindex 72d4955926a..bb1611988f0 100644--- a/packages/twenty-docs/snippets/ui/generated/input/input-group.mdx+++ b/packages/twenty-docs/snippets/ui/generated/input/input-group.mdx@@ -15,15 +15,16 @@Content rendered after the input, such as a suffix or a button.</ParamField>-<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>">- Allows you to replace the component's HTML element- with a different tag, or compose it with another component.+<ParamField body="ref" type="Ref<HTMLDivElement>">+ Ref to the layout element, a div by default.+</ParamField>- Accepts a `ReactElement` or a function that returns the element to render.+<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>">+ Customizes the layout element. Forward its props, children and ref. Native control props belong on the child input.</ParamField><ParamField body="size" type=""md" | "sm"" default="md">- Visual size of the group and its input.+ Visual size of the layout and default size for inputs that omit size. Defaults to md.</ParamField><ParamField body="startElement" type="ReactNode">diff --git a/packages/twenty-docs/snippets/ui/generated/input/input.mdx b/packages/twenty-docs/snippets/ui/generated/input/input.mdxindex 8a268f94aeb..7d9168d514b 100644--- a/packages/twenty-docs/snippets/ui/generated/input/input.mdx+++ b/packages/twenty-docs/snippets/ui/generated/input/input.mdx@@ -21,18 +21,19 @@</ParamField><ParamField body="onValueChange" type="((value: string, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)">- Callback fired when the `value` changes. Use when controlled.+ Receives the next string value and Base UI details, including the native event, reason and cancellation methods.</ParamField>-<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, InputState>">- Allows you to replace the component's HTML element- with a different tag, or compose it with another component.+<ParamField body="ref" type="Ref<HTMLInputElement>">+ Ref to the native input element.+</ParamField>- Accepts a `ReactElement` or a function that returns the element to render.+<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, InputState>">+ Composes the native input with a custom element or render callback. Forward the supplied props and ref to an input.</ParamField><ParamField body="size" type=""md" | "sm"">- Visual size of the input. Inside an `InputGroup`, the group's size applies.+ Visual size. Explicit input size takes precedence over the InputGroup default, then md applies. Group layout still sets the surrounding height.</ParamField><ParamField body="style" type="CSSProperties | ((state: InputState) => CSSProperties | undefined)">diff --git a/packages/twenty-docs/snippets/ui/generated/input/textarea.mdx b/packages/twenty-docs/snippets/ui/generated/input/textarea.mdxindex 6946de2c9ff..875e4172392 100644--- a/packages/twenty-docs/snippets/ui/generated/input/textarea.mdx+++ b/packages/twenty-docs/snippets/ui/generated/input/textarea.mdx@@ -12,7 +12,7 @@*/}<ParamField body="autoResize" type="boolean" default="false">- Grows the textarea with its content instead of showing a scrollbar.+ Measures committed controlled values or uncontrolled edits, form resets, row and size changes, and width changes. Overrides blockSize while enabled.</ParamField><ParamField body="className" type="string | ((state: InputState) => string | undefined)">@@ -21,19 +21,19 @@</ParamField><ParamField body="maxRows" type="number">- Maximum number of rows the textarea grows to when `autoResize` is set.- Longer content scrolls.+ Caps automatic height growth. Content beyond this row limit scrolls.</ParamField><ParamField body="onValueChange" type="((value: string, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)">- Called with the new value when the textarea value changes.+ Receives the next string value and Base UI details, including the native event, reason and cancellation methods.</ParamField>-<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>" default="<textarea />">- Allows you to replace the component's HTML element- with a different tag, or compose it with another component.+<ParamField body="ref" type="Ref<HTMLTextAreaElement>">+ Ref to the native textarea element.+</ParamField>- Accepts a `ReactElement` or a function that returns the element to render.+<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, InputState>">+ Composes the native textarea with a custom element or callback receiving textarea props and Field state. Forward the supplied props and ref to a textarea.</ParamField><ParamField body="size" type=""md" | "sm"" default="md">diff --git a/packages/twenty-docs/ui/primitives/input/input-group.mdx b/packages/twenty-docs/ui/primitives/input/input-group.mdxindex a13cb232a8c..085c9385073 100644--- a/packages/twenty-docs/ui/primitives/input/input-group.mdx+++ b/packages/twenty-docs/ui/primitives/input/input-group.mdx@@ -7,7 +7,7 @@ import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';import InputGroupReference from '/snippets/ui/generated/input/input-group.mdx';-`InputGroup` gives an [Input](/ui/primitives/input/input) a shared border and optional leading or trailing content. Set `size` on the group to size both the container and its input.+`InputGroup` gives an [Input](/ui/primitives/input/input) a shared border and optional leading or trailing content. Set `size` on the group to size the container and provide a default for its input. Explicit child size takes precedence over that default; the group still controls the shared layout height.<StoryEmbedstoryId="ui-input-inputgroup--default"@@ -92,6 +92,12 @@ export const PasswordField = () => {Put labels, validation, and value handling on the field or input. Give adornment buttons their own accessible names and use `type="button"` when they should not submit the form. The group supports `sm` and `md` sizes and defaults to `md`.+## Customize the layout++Native props, `className`, `style`, `render`, and `ref` target the layout div. A custom `render` element receives the layout props and children. Keep the supplied ref on that layout element.++Put `value`, `defaultValue`, `onValueChange`, `name`, `required`, `readOnly`, `disabled`, and the native control ref on `Input`. The group does not manage input state or replace Field label association.+## PropsThe reference is generated from the public component types. Native attributes, including accessible names and event handlers, are also accepted on parts that render elements.diff --git a/packages/twenty-docs/ui/primitives/input/input.mdx b/packages/twenty-docs/ui/primitives/input/input.mdxindex df4952a154e..9c8a148e3c5 100644--- a/packages/twenty-docs/ui/primitives/input/input.mdx+++ b/packages/twenty-docs/ui/primitives/input/input.mdx@@ -65,7 +65,7 @@ export const EmailField = () => {## Add an adornment-`InputGroup` owns the surrounding border and sizes its input. The default size is `md`; use `sm` for a compact field. Set `size` on the group: a grouped input stretches to the group's height, so its own `size` has no visible effect.+`InputGroup` owns the surrounding border and layout height. Input size resolves from the explicit child `size`, then the group default, then `md`. The grouped input stretches within the shared border, so use the group's `size` to change the overall field height.```tsximport { IconSearch } from 'twenty-ui/icon';@@ -78,8 +78,16 @@ export const CompactSearch = () => ();```+## Native control and wrapper customization++Native attributes, handlers, `className`, `style`, and `ref` target the input. The ref receives an `HTMLInputElement`. Use `render` to compose another input component and forward the supplied props and ref to its native input.++`onChange` receives a React change event for the native input. `onValueChange(value, details)` receives the next string and Base UI event details, including `event`, `reason`, `cancel`, and `allowPropagation`. The event targets the input. Canceling the details preserves Base UI's validation policy; it does not undo a native edit. Controlled callers decide which value to commit.++Put layout styles, attributes, and refs on `InputGroup` when customizing the surrounding wrapper. The group owns no value. Native `name`, `form`, `required`, `readOnly`, `disabled`, submission, and reset behavior remain on the input, with Field naming and validation supplied through `Field.Root`.+## Props-The reference includes component-specific and inherited Base UI props. Native input attributes are also accepted. A standalone input defaults to `md`; inside a group, the group's `size` applies.+The reference includes component-specific and inherited Base UI props. Native input attributes are also accepted. A standalone input defaults to `md`; inside a group, an omitted input `size` inherits the group's size.<InputReference />diff --git a/packages/twenty-docs/ui/primitives/input/textarea.mdx b/packages/twenty-docs/ui/primitives/input/textarea.mdxindex f61eea6502a..8ab1c1396ab 100644--- a/packages/twenty-docs/ui/primitives/input/textarea.mdx+++ b/packages/twenty-docs/ui/primitives/input/textarea.mdx@@ -84,7 +84,17 @@ export const DescriptionField = () => {};```-`autoResize` adjusts the textarea's height as its content changes. Use `maxRows` to cap the height. Keep keyboard focus on the textarea while the user types and use helper text for limits.+`autoResize` measures the committed value after controlled updates and measures uncontrolled edits directly. Rejected controlled edits do not change the height. It also updates after native form resets, `rows`, `size`, `maxRows`, and available width changes. Use `maxRows` to cap growth and scroll longer content.++Automatic sizing owns inline `blockSize` while enabled. Turning it off restores the current `style.blockSize`, or clears the automatic size if none is supplied. With automatic sizing off, `rows` and native styles control height. Manual resizing is disabled by default; set `style={{ resize: 'vertical' }}` when callers should resize the control themselves.++## Native control and render composition++Native textarea attributes and handlers, `className`, `style`, and `ref` target the textarea. The ref receives an `HTMLTextAreaElement`. `render` accepts a textarea element or a callback receiving native textarea props and Field state. Forward the supplied props and ref to the native textarea so labels, validation, events, and automatic measurement keep working. Add a separate layout element when wrapper customization is needed.++`onChange` receives a React change event for the native textarea. `onValueChange(value, details)` retains the Base UI signature, including the native `event`, `reason`, `cancel`, and `allowPropagation`. The native event targets the textarea. Canceling the details preserves Base UI's validation policy; it does not undo the native value. Controlled callers choose the committed value.++Native `name`, `form`, `required`, `readOnly`, `disabled`, submission, and reset behavior remain available. Field supplies label, description, name, and validation association. Enter inserts a line break in the textarea.## Propsdiff --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 5252a51c64f..987540eae2a 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@@ -6,6 +6,9 @@ component stories. Each fixture has React and Preact stories built withPreact stories need Preact 11, which passes `ref` to function components as aregular prop like React 19. Preact 10 hands that ref to the component instance,so Dropdown-based popups never open there.+The field-controls fixture checks native input/textarea refs and change targets, typed textarea render composition, Field labels and controlled multiline value updates in React and Preact.+Textarea auto-resize growth and shrinking remain known renderer failures. Geometry reads use cached host snapshots, so resetting inline height and reading scrollHeight in the same turn cannot measure the updated layout. The growth failure also reproduces with main's unchanged Textarea. The fixture pins them with the existing known-failure helper; these assertions do not count as resize acceptance. Standalone Textarea browser checks pass.+Typography composition checks constrained text, explicit links, semantic elements, refs and native focus handlers in both runtimes. Overflow tooltip popup acceptance still depends on renderer portal and geometry support.Scenarios share their checks between runtimes where behavior matches. The storydiff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-field-controls.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-field-controls.front-component.tsxindex 7e560099177..1ee6b4a4757 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-field-controls.front-component.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-field-controls.front-component.tsx@@ -1,6 +1,7 @@-import { useState } from 'react';+import { createElement, useRef, useState } from 'react';import { defineFrontComponent } from 'twenty-sdk/define';import {+ Button,Field,Input,InputGroup,@@ -12,6 +13,10 @@ import {import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';const FieldControls = () => {+ const inputRef = useRef<HTMLInputElement>(null);+ const textareaRef = useRef<HTMLTextAreaElement>(null);+ const [nativeTarget, setNativeTarget] = useState('');+ const [controlValues, setControlValues] = useState('');const [email, setEmail] = useState('');const [notes, setNotes] = useState('');const [reportedValues, setReportedValues] = useState('');@@ -39,8 +44,18 @@ const FieldControls = () => {</Field.Root><Field.Root><Field.Label>Email</Field.Label>- <InputGroup startElement="@" endElement=".com">- <Input value={email} onValueChange={setEmail} />+ <InputGroup+ size="sm"+ startElement="@"+ endElement=".com"+ aria-label="Email layout"+ >+ <Input+ ref={inputRef}+ size="md"+ value={email}+ onValueChange={setEmail}+ /></InputGroup><Field.Description>Use your work email</Field.Description></Field.Root>@@ -49,9 +64,27 @@ const FieldControls = () => {<Field.Control defaultValue="" /><Field.Error match>Name is required</Field.Error></Field.Root>- <Field.Root>+ <Field.Root invalid><Field.Label>Notes</Field.Label>- <Textarea value={notes} onValueChange={setNotes} rows={2} />+ <p id="notes-help">Additional guidance</p>+ <Textarea+ ref={textareaRef}+ aria-describedby="notes-help"+ value={notes}+ onValueChange={setNotes}+ onChange={(event) => setNativeTarget(event.currentTarget.tagName)}+ rows={1}+ autoResize+ maxRows={6}+ render={(props, state) =>+ createElement('textarea', {+ ...props,+ 'data-filled': state.filled || undefined,+ })+ }+ />+ <Field.Description>Team context</Field.Description>+ <Field.Error match>Notes need review</Field.Error></Field.Root><Field.Root invalid><Field.Label>Reference</Field.Label>@@ -63,11 +96,25 @@ const FieldControls = () => {<p role="status">Email: {email}; Notes: {notes}</p>- <button- onClick={() => setReportedValues(`Email: ${email}; Notes: ${notes}`)}+ <Button type="button" onClick={() => setNotes('First\nSecond\nThird')}>+ Apply notes+ </Button>+ <Button type="button" onClick={() => setNotes('')}>+ Clear notes+ </Button>+ <p data-testid="native-target">{nativeTarget}</p>+ <p data-testid="control-values">{controlValues}</p>+ <Button+ type="button"+ onClick={() => {+ setReportedValues(`Email: ${email}; Notes: ${notes}`);+ setControlValues(+ `${inputRef.current?.value}/${textareaRef.current?.value}`,+ );+ }}>Read values- </button>+ </Button><p data-testid="reported-values">{reportedValues}</p></TwentyUiGalleryCard>);diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/fieldControlsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/fieldControlsTest.tsindex 163a42fc00e..6eed3c0787e 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/fieldControlsTest.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/fieldControlsTest.ts@@ -2,6 +2,7 @@ import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponeimport { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';import { TYPING_DELAY } from '@/__stories__/shared/test-utils/timeouts';import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';+import { expectAssertionToKeepFailing } from '@/__stories__/twenty-ui-gallery/utils/expectAssertionToKeepFailing';import { expect, userEvent, waitFor, within } from 'storybook/test';export const fieldControlsTest: TwentyUiGalleryPlayFunction = async ({@@ -30,6 +31,9 @@ export const fieldControlsTest: TwentyUiGalleryPlayFunction = async ({expect(important).not.toBeChecked();expect(email).toHaveAccessibleDescription('Use your work email');+ expect(notes).toHaveAccessibleDescription(+ 'Additional guidance Team context Notes need review',+ );expect(canvas.getByRole('textbox', { name: 'Required name' }),).toHaveAttribute('aria-invalid', 'true');@@ -53,5 +57,23 @@ export const fieldControlsTest: TwentyUiGalleryPlayFunction = async ({'Email: alice; Notes: Follow up',),);+ expect(canvas.getByTestId('native-target')).toHaveTextContent('TEXTAREA');+ expect(canvas.getByTestId('control-values')).toHaveTextContent(+ 'alice/Follow up',+ );+ expect(notes.tagName).toBe('TEXTAREA');+ expect(notes).toHaveAttribute('data-filled');+ const editedHeight = notes.clientHeight;+ await userEvent.click(canvas.getByRole('button', { name: 'Apply notes' }));+ await waitFor(() => expect(notes).toHaveValue('First\nSecond\nThird'));+ await expectAssertionToKeepFailing(() =>+ expect(notes.clientHeight).toBeGreaterThan(editedHeight),+ );+ const multilineHeight = notes.clientHeight;+ await userEvent.click(canvas.getByRole('button', { name: 'Clear notes' }));+ await waitFor(() => expect(notes).toHaveValue(''));+ await expectAssertionToKeepFailing(() =>+ expect(notes.clientHeight).toBeLessThan(multilineHeight),+ );expect(errorHandler).not.toHaveBeenCalled();};diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex 007bb3c4625..8de6000d5d5 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -1,3 +1,6 @@+import { TEXTAREA_PROP_DESCRIPTIONS } from './textareaPropDescriptions';+import { INPUT_GROUP_PROP_DESCRIPTIONS } from './inputGroupPropDescriptions';+import { INPUT_PROP_DESCRIPTIONS } from './inputPropDescriptions';import { COUNTRY_SELECT_PROP_DESCRIPTIONS } from './countrySelectPropDescriptions';import { CURRENCY_PICKER_PART_PROP_DESCRIPTIONS } from './currencyPickerPartPropDescriptions';import { OVERFLOWING_LIST_PROP_DESCRIPTIONS } from './overflowingListPropDescriptions';@@ -286,12 +289,14 @@ export const DOCUMENTED_COMPONENTS = [source: 'primitives/input/Input/Input.tsx',entryPoint: 'twenty-ui/primitives/input',slug: 'input/input',+ propDescriptions: INPUT_PROP_DESCRIPTIONS,},{name: 'InputGroup',source: 'primitives/input/InputGroup/InputGroup.tsx',entryPoint: 'twenty-ui/primitives/input',slug: 'input/input-group',+ propDescriptions: INPUT_GROUP_PROP_DESCRIPTIONS,},{name: 'NumberStepper',@@ -305,6 +310,7 @@ export const DOCUMENTED_COMPONENTS = [source: 'primitives/input/Textarea/Textarea.tsx',entryPoint: 'twenty-ui/primitives/input',slug: 'input/textarea',+ propDescriptions: TEXTAREA_PROP_DESCRIPTIONS,},{name: 'Checkbox',diff --git a/packages/twenty-ui/docs/inputGroupPropDescriptions.ts b/packages/twenty-ui/docs/inputGroupPropDescriptions.tsnew file mode 100644index 00000000000..e3db839df00--- /dev/null+++ b/packages/twenty-ui/docs/inputGroupPropDescriptions.ts@@ -0,0 +1,8 @@+import { type InputGroupProps } from '../src/primitives/input/InputGroup/types/InputGroupProps';++export const INPUT_GROUP_PROP_DESCRIPTIONS = {+ size: 'Visual size of the layout and default size for inputs that omit size. Defaults to md.',+ ref: 'Ref to the layout element, a div by default.',+ render:+ 'Customizes the layout element. Forward its props, children and ref. Native control props belong on the child input.',+} satisfies Partial<Record<keyof InputGroupProps, string>>;diff --git a/packages/twenty-ui/docs/inputPropDescriptions.ts b/packages/twenty-ui/docs/inputPropDescriptions.tsnew file mode 100644index 00000000000..039e4497fd7--- /dev/null+++ b/packages/twenty-ui/docs/inputPropDescriptions.ts@@ -0,0 +1,10 @@+import { type InputProps } from '../src/primitives/input/Input/types/InputProps';++export const INPUT_PROP_DESCRIPTIONS = {+ size: 'Visual size. Explicit input size takes precedence over the InputGroup default, then md applies. Group layout still sets the surrounding height.',+ ref: 'Ref to the native input element.',+ render:+ 'Composes the native input with a custom element or render callback. Forward the supplied props and ref to an input.',+ onValueChange:+ 'Receives the next string value and Base UI details, including the native event, reason and cancellation methods.',+} satisfies Partial<Record<keyof InputProps, string>>;diff --git a/packages/twenty-ui/docs/textareaPropDescriptions.ts b/packages/twenty-ui/docs/textareaPropDescriptions.tsnew file mode 100644index 00000000000..5da65f0759e--- /dev/null+++ b/packages/twenty-ui/docs/textareaPropDescriptions.ts@@ -0,0 +1,13 @@+import { type TextareaProps } from '../src/primitives/input/Textarea/types/TextareaProps';++export const TEXTAREA_PROP_DESCRIPTIONS = {+ ref: 'Ref to the native textarea element.',+ render:+ 'Composes the native textarea with a custom element or callback receiving textarea props and Field state. Forward the supplied props and ref to a textarea.',+ onValueChange:+ 'Receives the next string value and Base UI details, including the native event, reason and cancellation methods.',+ autoResize:+ 'Measures committed controlled values or uncontrolled edits, form resets, row and size changes, and width changes. Overrides blockSize while enabled.',+ maxRows:+ 'Caps automatic height growth. Content beyond this row limit scrolls.',+} satisfies Partial<Record<keyof TextareaProps, string>>;diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex 8e6c1d1d626..8c208a0f758 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -2508,21 +2508,28 @@"type": "((value: string, eventDetails: { reason: \"none\"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)","required": false,"defaultValue": null,- "description": "Callback fired when the `value` changes. Use when controlled."+ "description": "Receives the next string value and Base UI details, including the native event, reason and cancellation methods."+ },+ {+ "name": "ref",+ "type": "Ref<HTMLInputElement>",+ "required": false,+ "defaultValue": null,+ "description": "Ref to the native input element."},{"name": "render","type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, InputState>","required": false,"defaultValue": null,- "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ "description": "Composes the native input with a custom element or render callback. Forward the supplied props and ref to an input."},{"name": "size","type": "\"md\" | \"sm\"","required": false,"defaultValue": null,- "description": "Visual size of the input. Inside an `InputGroup`, the group's size applies."+ "description": "Visual size. Explicit input size takes precedence over the InputGroup default, then md applies. Group layout still sets the surrounding height."},{"name": "style",@@ -2552,19 +2559,26 @@"defaultValue": null,"description": "Content rendered after the input, such as a suffix or a button."},+ {+ "name": "ref",+ "type": "Ref<HTMLDivElement>",+ "required": false,+ "defaultValue": null,+ "description": "Ref to the layout element, a div by default."+ },{"name": "render","type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>","required": false,"defaultValue": null,- "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."+ "description": "Customizes the layout element. Forward its props, children and ref. Native control props belong on the child input."},{"name": "size","type": "\"md\" | \"sm\"","required": false,"defaultValue": "md",- "description": "Visual size of the group and its input."+ "description": "Visual size of the layout and default size for inputs that omit size. Defaults to md."},{"name": "startElement",@@ -2739,7 +2753,7 @@"type": "boolean","required": false,"defaultValue": "false",- "description": "Grows the textarea with its content instead of showing a scrollbar."+ "description": "Measures committed controlled values or uncontrolled edits, form resets, row and size changes, and width changes. Overrides blockSize while enabled."},{"name": "className",@@ -2753,21 +2767,28 @@"type": "number","required": false,"defaultValue": null,- "description": "Maximum number of rows the textarea grows to when `autoResize` is set.\nLonger content scrolls."+ "description": "Caps automatic height growth. Content beyond this row limit scrolls."},{"name": "onValueChange","type": "((value: string, eventDetails: { reason: \"none\"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)","required": false,"defaultValue": null,- "description": "Called with the new value when the textarea value changes."+ "description": "Receives the next string value and Base UI details, including the native event, reason and cancellation methods."+ },+ {+ "name": "ref",+ "type": "Ref<HTMLTextAreaElement>",+ "required": false,+ "defaultValue": null,+ "description": "Ref to the native textarea element."},{"name": "render",- "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, InputState>","required": false,- "defaultValue": "<textarea />",- "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."+ "defaultValue": null,+ "description": "Composes the native textarea with a custom element or callback receiving textarea props and Field state. Forward the supplied props and ref to a textarea."},{"name": "size",diff --git a/packages/twenty-ui/src/primitives/input/Input/__stories__/InputInteractions.stories.tsx b/packages/twenty-ui/src/primitives/input/Input/__stories__/InputInteractions.stories.tsxindex f263a9696f3..8635fd9bb11 100644--- a/packages/twenty-ui/src/primitives/input/Input/__stories__/InputInteractions.stories.tsx+++ b/packages/twenty-ui/src/primitives/input/Input/__stories__/InputInteractions.stories.tsx@@ -2,6 +2,7 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';import { useState } from 'react';import { expect, fn, userEvent, within } from 'storybook/test';+import { Button } from '@ui/primitives/input/Button/Button';import { Field } from '@ui/primitives/input/Field/Field';import { ComponentDecorator } from '@ui/testing';@@ -15,9 +16,9 @@ const ControlledInputExample = (props: InputProps) => {return (<><Input {...props} value={value} />- <button type="button" onClick={() => setValue('ab')}>+ <Button type="button" onClick={() => setValue('ab')}>Apply value- </button>+ </Button></>);};@@ -30,9 +31,9 @@ const FieldInputExample = (props: InputProps) => {<Field.Root invalid disabled={disabled}><Input {...props} /></Field.Root>- <button type="button" onClick={() => setDisabled(true)}>+ <Button type="button" onClick={() => setDisabled(true)}>Disable input- </button>+ </Button></>);};diff --git a/packages/twenty-ui/src/primitives/input/Input/__tests__/Input.test.tsx b/packages/twenty-ui/src/primitives/input/Input/__tests__/Input.test.tsxindex a63dc7b7b8c..899b83bd251 100644--- a/packages/twenty-ui/src/primitives/input/Input/__tests__/Input.test.tsx+++ b/packages/twenty-ui/src/primitives/input/Input/__tests__/Input.test.tsx@@ -1,3 +1,10 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { createRef } from 'react';+import { vi } from 'vitest';++import { Field } from '@ui/primitives/input/Field/Field';+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';import { Input } from '../Input';@@ -10,3 +17,79 @@ runComponentConformance({ownClassName: styles.input,renderPropTagName: 'input',});++describe('Input native integration', () => {+ it('retains native events and Base UI value details on the input', async () => {+ const user = userEvent.setup();+ const ref = createRef<HTMLInputElement>();+ const onValueChange = vi.fn();+ const onChange = vi.fn();++ render(+ <Input+ ref={ref}+ aria-label="Name"+ onChange={onChange}+ onValueChange={onValueChange}+ />,+ );+ await user.type(screen.getByRole('textbox', { name: 'Name' }), 'a');++ expect(ref.current).toBeInstanceOf(HTMLInputElement);+ expect(onChange).toHaveBeenCalledTimes(1);+ expect(onValueChange).toHaveBeenCalledTimes(1);+ expect(onValueChange).toHaveBeenCalledWith(+ 'a',+ expect.objectContaining({+ reason: 'none',+ event: onChange.mock.calls[0]?.[0].nativeEvent,+ cancel: expect.any(Function),+ }),+ );+ });++ it('preserves Field naming, native form validation, submission and reset', async () => {+ const user = userEvent.setup();+ const ref = createRef<HTMLInputElement>();+ render(+ <form aria-label="Contact">+ <Field.Root name="email">+ <Field.Label>Email</Field.Label>+ <Input+ ref={ref}+ type="email"+ required+ defaultValue="[email protected]"+ />+ <Field.Description>Work address</Field.Description>+ </Field.Root>+ <Input+ name="reference"+ aria-label="Reference"+ defaultValue="REF-42"+ readOnly+ />+ <Input+ name="excluded"+ aria-label="Disabled"+ defaultValue="locked"+ disabled+ />+ </form>,+ );+ const form = screen.getByRole<HTMLFormElement>('form', { name: 'Contact' });+ const input = screen.getByRole('textbox', { name: 'Email' });+ await user.click(screen.getByText('Email'));+ expect(input).toHaveFocus();+ expect(input).toHaveAccessibleDescription('Work address');+ expect(ref.current?.checkValidity()).toBe(true);+ expect(Object.fromEntries(new FormData(form))).toEqual({+ email: '[email protected]',+ reference: 'REF-42',+ });+ await user.clear(input);+ expect(ref.current?.checkValidity()).toBe(false);+ form.reset();+ expect(input).toHaveValue('[email protected]');+ });+});diff --git a/packages/twenty-ui/src/primitives/input/Input/types/InputProps.ts b/packages/twenty-ui/src/primitives/input/Input/types/InputProps.tsindex 76c6efb968a..24794ab12cf 100644--- a/packages/twenty-ui/src/primitives/input/Input/types/InputProps.ts+++ b/packages/twenty-ui/src/primitives/input/Input/types/InputProps.ts@@ -3,6 +3,5 @@ import { type Input as InputPrimitive } from '@base-ui/react/input';import { type InputSize } from '@ui/primitives/input/types/InputSize';export type InputProps = Omit<InputPrimitive.Props, 'size'> & {- /** Visual size of the input. Inside an `InputGroup`, the group's size applies. */size?: InputSize;};diff --git a/packages/twenty-ui/src/primitives/input/InputGroup/__tests__/InputGroup.test.tsx b/packages/twenty-ui/src/primitives/input/InputGroup/__tests__/InputGroup.test.tsxindex cf4cf860582..66d4cd6cef2 100644--- a/packages/twenty-ui/src/primitives/input/InputGroup/__tests__/InputGroup.test.tsx+++ b/packages/twenty-ui/src/primitives/input/InputGroup/__tests__/InputGroup.test.tsx@@ -1,3 +1,8 @@+import { render, screen } from '@testing-library/react';+import { createRef } from 'react';++import inputStyles from '@ui/primitives/input/Input/Input.module.scss';+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';import { Input } from '@ui/primitives/input/Input/Input';@@ -15,3 +20,35 @@ runComponentConformance({refInstanceOf: HTMLDivElement,ownClassName: styles.root,});++it('keeps native layout customization separate from input props and child size precedence', () => {+ const groupRef = createRef<HTMLDivElement>();+ const inputRef = createRef<HTMLInputElement>();+ render(+ <InputGroup+ ref={groupRef}+ size="sm"+ aria-label="Search layout"+ style={{ maxWidth: 240 }}+ render={<section />}+ startElement="@"+ endElement=".com"+ >+ <Input aria-label="Inherited" />+ <Input ref={inputRef} aria-label="Explicit" name="email" size="md" />+ </InputGroup>,+ );+ const layout = screen.getByRole('region', { name: 'Search layout' });+ const explicitInput = screen.getByRole('textbox', { name: 'Explicit' });+ expect(groupRef.current).toBe(layout);+ expect(layout).toHaveStyle({ maxWidth: '240px' });+ expect(inputRef.current).toBe(explicitInput);+ expect(explicitInput).toHaveAttribute('name', 'email');+ expect(explicitInput).toHaveClass(inputStyles.md);+ expect(explicitInput).not.toHaveClass(inputStyles.sm);+ expect(screen.getByRole('textbox', { name: 'Inherited' })).toHaveClass(+ inputStyles.sm,+ );+ expect(screen.getByText('@')).toBeInTheDocument();+ expect(screen.getByText('.com')).toBeInTheDocument();+});diff --git a/packages/twenty-ui/src/primitives/input/InputGroup/types/InputGroupProps.ts b/packages/twenty-ui/src/primitives/input/InputGroup/types/InputGroupProps.tsindex 9d1b58ba369..9131b8b58fc 100644--- a/packages/twenty-ui/src/primitives/input/InputGroup/types/InputGroupProps.ts+++ b/packages/twenty-ui/src/primitives/input/InputGroup/types/InputGroupProps.ts@@ -4,7 +4,6 @@ import { type ReactNode } from 'react';import { type InputSize } from '@ui/primitives/input/types/InputSize';export type InputGroupProps = useRender.ComponentProps<'div'> & {- /** Visual size of the group and its input. */size?: InputSize;/** Content rendered before the input, such as a prefix or an icon. */startElement?: ReactNode;diff --git a/packages/twenty-ui/src/primitives/input/Textarea/Textarea.tsx b/packages/twenty-ui/src/primitives/input/Textarea/Textarea.tsxindex 6a98d5145a7..55b5ffceb2a 100644--- a/packages/twenty-ui/src/primitives/input/Textarea/Textarea.tsx+++ b/packages/twenty-ui/src/primitives/input/Textarea/Textarea.tsx@@ -6,19 +6,20 @@ import {useLayoutEffect,useMemo,useRef,+ useState,} from 'react';import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';import { isDefined } from '@ui/utilities/utils/isDefined';+import { TextareaControl } from './internal/TextareaControl';import { formatInlineBlockSize } from './internal/formatInlineBlockSize';import { mergeRefs } from './internal/mergeRefs';+import { observeTextareaWidth } from './internal/observeTextareaWidth';import { resizeTextareaToContent } from './internal/resizeTextareaToContent';import styles from './Textarea.module.scss';import { type TextareaProps } from './types/TextareaProps';-const TEXTAREA_RENDER_ELEMENT = <textarea />;-export const Textarea = ({size = 'md',autoResize = false,@@ -26,35 +27,63 @@ export const Textarea = ({className,style,ref,- render = TEXTAREA_RENDER_ELEMENT,+ render,onChange,value,rows,...props}: TextareaProps) => {- const textareaRef = useRef<HTMLTextAreaElement>(null);- // Base UI re-forks a merged ref whenever its identity changes, which would detach and reattach it on every render.- const mergedRef = useMemo(() => mergeRefs(ref, textareaRef), [ref]);+ const [textarea, setTextarea] = useState<HTMLTextAreaElement | null>(null);+ const mergedRef = useMemo(() => mergeRefs(ref, setTextarea), [ref]);const isControlled = isDefined(value);const consumerBlockSize = style?.blockSize;+ const wasAutoResize = useRef(false);useLayoutEffect(() => {- const textarea = textareaRef.current;-if (!isDefined(textarea)) {return;}- if (!autoResize) {+ const shouldRestoreBlockSize = wasAutoResize.current;+ wasAutoResize.current = autoResize;++ if (autoResize) {+ resizeTextareaToContent(textarea);+ return;+ }++ if (shouldRestoreBlockSize) {textarea.style.blockSize = formatInlineBlockSize(consumerBlockSize);+ }+ }, [textarea, autoResize, value, maxRows, rows, size, consumerBlockSize]);++ useLayoutEffect(() => {+ if (!autoResize || !isDefined(textarea)) {return;}- resizeTextareaToContent(textarea);- }, [autoResize, value, maxRows, rows, consumerBlockSize]);+ let isActive = true;+ const handleReset = (event: Event) => {+ requestAnimationFrame(() => {+ if (isActive && !event.defaultPrevented) {+ resizeTextareaToContent(textarea);+ }+ });+ };++ const form = textarea.form;+ const stopObservingWidth = observeTextareaWidth(textarea);++ form?.addEventListener('reset', handleReset);++ return () => {+ isActive = false;+ form?.removeEventListener('reset', handleReset);+ stopObservingWidth?.();+ };+ }, [textarea, autoResize, props.form]);const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {- // A controlled parent may reject the edit, so the layout effect measures the committed value instead.if (autoResize && !isControlled) {resizeTextareaToContent(event.currentTarget);}@@ -66,18 +95,43 @@ export const Textarea = ({? ({ ...style, '--tw-textarea-max-rows': maxRows } as CSSProperties): style;- // Base UI types its control for <input> but only reads currentTarget.value, so rendering a textarea through it is safe.- const primitiveProps = {- ...props,- rows,- onChange: handleChange,- } as unknown as InputPrimitive.Props;+ const {+ 'aria-describedby': ariaDescribedBy,+ id,+ name,+ disabled,+ autoFocus,+ defaultValue,+ onValueChange,+ ...nativeProps+ } = props;++ const controlProps = {+ 'aria-describedby': ariaDescribedBy,+ id,+ name,+ disabled,+ autoFocus,+ defaultValue,+ onValueChange,+ };return (<InputPrimitive- {...primitiveProps}- ref={mergedRef}- render={render}+ {...controlProps}+ render={(elementProps, state) => (+ <TextareaControl+ controlProps={elementProps}+ nativeProps={{+ ...nativeProps,+ rows,+ onChange: handleChange,+ ref: mergedRef,+ }}+ state={state}+ render={render}+ />+ )}value={value}className={mergeClassNames(clsx(styles.textarea, styles[size]),diff --git a/packages/twenty-ui/src/primitives/input/Textarea/__stories__/Textarea.stories.tsx b/packages/twenty-ui/src/primitives/input/Textarea/__stories__/Textarea.stories.tsxindex 94e423d55fe..12c7eebc67f 100644--- a/packages/twenty-ui/src/primitives/input/Textarea/__stories__/Textarea.stories.tsx+++ b/packages/twenty-ui/src/primitives/input/Textarea/__stories__/Textarea.stories.tsx@@ -1,5 +1,4 @@import { type Meta, type StoryObj } from '@storybook/react-vite';-import { expect, userEvent, within } from 'storybook/test';import {A11Y_DEFER_COLOR_CONTRAST,@@ -34,27 +33,6 @@ export const AutoResize: Story = {decorators: [ComponentDecorator],parameters: { container: { width: 240 } },args: { autoResize: true, rows: 1, maxRows: 4 },- play: async ({ canvasElement }) => {- const canvas = within(canvasElement);-- const textarea = canvas.getByRole('textbox', { name: 'Textarea' });- const initialHeight = textarea.clientHeight;-- await expect(- textarea.style.getPropertyValue('--tw-textarea-max-rows'),- ).toBe('4');-- await userEvent.type(textarea, 'one{enter}two{enter}three');-- await expect(textarea.clientHeight).toBeGreaterThan(initialHeight);-- await userEvent.type(- textarea,- '{enter}four{enter}five{enter}six{enter}seven{enter}eight',- );-- await expect(textarea.scrollHeight).toBeGreaterThan(textarea.clientHeight);- },};type TextareaCatalogState = 'default' | 'focus' | 'invalid' | 'disabled';diff --git a/packages/twenty-ui/src/primitives/input/Textarea/__stories__/TextareaAutoResize.stories.tsx b/packages/twenty-ui/src/primitives/input/Textarea/__stories__/TextareaAutoResize.stories.tsxindex 39bef001e25..d9546731b34 100644--- a/packages/twenty-ui/src/primitives/input/Textarea/__stories__/TextareaAutoResize.stories.tsx+++ b/packages/twenty-ui/src/primitives/input/Textarea/__stories__/TextareaAutoResize.stories.tsx@@ -1,7 +1,9 @@import { type Meta, type StoryObj } from '@storybook/react-vite';import { useState } from 'react';-import { expect, userEvent, within } from 'storybook/test';+import { expect, userEvent, waitFor, within } from 'storybook/test';+import { Button } from '@ui/primitives/input/Button/Button';+import { type InputSize } from '@ui/primitives/input/types/InputSize';import { ComponentDecorator } from '@ui/testing';import { Textarea } from '../Textarea';@@ -10,23 +12,41 @@ import { type TextareaProps } from '../types/TextareaProps';const TextareaResizeExample = ({ style, ...props }: TextareaProps) => {const [autoResize, setAutoResize] = useState(true);const [rows, setRows] = useState(1);+ const [maxRows, setMaxRows] = useState(props.maxRows);+ const [size, setSize] = useState<InputSize>('md');+ const [width, setWidth] = useState(240);const [blockSize, setBlockSize] = useState(style?.blockSize);return (- <>+ <form><Textarea{...props}rows={rows}+ maxRows={maxRows}+ size={size}autoResize={autoResize}- style={{ ...style, blockSize }}+ style={{ ...style, blockSize, width }}/>- <button type="button" onClick={() => setRows(3)}>+ <Button type="button" onClick={() => setMaxRows(2)}>+ Limit rows+ </Button>+ <Button type="button" onClick={() => setMaxRows(6)}>+ Expand row limit+ </Button>+ <Button type="reset">Reset notes</Button>+ <Button type="button" onClick={() => setSize('sm')}>+ Use small size+ </Button>+ <Button type="button" onClick={() => setWidth(120)}>+ Narrow notes+ </Button>+ <Button type="button" onClick={() => setRows(3)}>Show three rows- </button>- <button type="button" onClick={() => setAutoResize(false)}>+ </Button>+ <Button type="button" onClick={() => setAutoResize(false)}>Disable auto resize- </button>- <button+ </Button>+ <Buttontype="button"onClick={() => {setAutoResize(false);@@ -34,8 +54,36 @@ const TextareaResizeExample = ({ style, ...props }: TextareaProps) => {}}>Set fixed height- </button>- </>+ </Button>+ </form>+ );+};++const ReplaceableTextareaResizeExample = () => {+ const [controlKey, setControlKey] = useState(0);+ const [width, setWidth] = useState(240);++ return (+ <form>+ <Textarea+ aria-label="Notes"+ autoResize+ rows={1}+ defaultValue="One line of notes that wraps at a narrower width."+ style={{ width }}+ render={(props) => <textarea key={controlKey} {...props} />}+ />+ <Button+ type="button"+ onClick={() => setControlKey((previousKey) => previousKey + 1)}+ >+ Replace notes control+ </Button>+ <Button type="button" onClick={() => setWidth(120)}>+ Narrow notes+ </Button>+ <Button type="reset">Reset notes</Button>+ </form>);};@@ -110,3 +158,103 @@ export const ReplaceConsumerHeight: Story = {await expect(textarea.style.blockSize).toBe('120px');},};++export const SizeChange: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const textarea = canvas.getByRole('textbox', { name: 'Notes' });+ const initialHeight = textarea.clientHeight;+ await userEvent.click(+ canvas.getByRole('button', { name: 'Use small size' }),+ );+ await expect(textarea.clientHeight).toBeLessThan(initialHeight);+ },+};++export const WidthChange: Story = {+ args: { defaultValue: 'One line of notes that wraps at a narrower width.' },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const textarea = canvas.getByRole('textbox', { name: 'Notes' });+ const initialHeight = textarea.clientHeight;+ await userEvent.click(canvas.getByRole('button', { name: 'Narrow notes' }));+ await waitFor(() =>+ expect(textarea.clientHeight).toBeGreaterThan(initialHeight),+ );+ },+};++export const FormReset: Story = {+ tags: ['!dev'],+ args: { defaultValue: 'Initial' },+ play: async ({ canvasElement }) => {+ const { userEvent: trustedUserEvent } = await import('vitest/browser');+ const canvas = within(canvasElement);+ const textarea = canvas.getByRole('textbox', { name: 'Notes' });+ const initialHeight = textarea.clientHeight;+ await userEvent.type(textarea, '{enter}Second{enter}Third');+ await expect(textarea.clientHeight).toBeGreaterThan(initialHeight);+ await trustedUserEvent.click(+ canvas.getByRole('button', { name: 'Reset notes' }),+ );+ await expect(textarea).toHaveValue('Initial');+ await waitFor(() => expect(textarea.clientHeight).toBe(initialHeight));+ },+};++export const MaximumRows: Story = {+ args: { maxRows: 4 },+ play: async ({ canvasElement }) => {+ const textarea = within(canvasElement).getByRole('textbox', {+ name: 'Notes',+ });+ await userEvent.type(+ textarea,+ 'one{enter}two{enter}three{enter}four{enter}five{enter}six',+ );+ await expect(textarea.scrollHeight).toBeGreaterThan(textarea.clientHeight);+ },+};++export const MaximumRowsChange: Story = {+ args: { defaultValue: 'First\nSecond\nThird\nFourth' },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const textarea = canvas.getByRole('textbox', { name: 'Notes' });+ const initialHeight = textarea.clientHeight;+ await userEvent.click(canvas.getByRole('button', { name: 'Limit rows' }));+ await expect(textarea.clientHeight).toBeLessThan(initialHeight);+ await expect(textarea.scrollHeight).toBeGreaterThan(textarea.clientHeight);+ await userEvent.click(+ canvas.getByRole('button', { name: 'Expand row limit' }),+ );+ await expect(textarea.clientHeight).toBe(initialHeight);+ },+};++export const RenderedControlReplacement: Story = {+ render: () => <ReplaceableTextareaResizeExample />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const originalTextarea = canvas.getByRole('textbox', { name: 'Notes' });+ await userEvent.click(+ canvas.getByRole('button', { name: 'Replace notes control' }),+ );+ const textarea = canvas.getByRole('textbox', { name: 'Notes' });+ expect(textarea).not.toBe(originalTextarea);+ expect(originalTextarea).not.toBeInTheDocument();+ const replacementHeight = textarea.clientHeight;+ await userEvent.click(canvas.getByRole('button', { name: 'Narrow notes' }));+ await waitFor(() =>+ expect(textarea.clientHeight).toBeGreaterThan(replacementHeight),+ );+ const narrowedHeight = textarea.clientHeight;+ await userEvent.type(textarea, '{enter}Second{enter}Third');+ expect(textarea.clientHeight).toBeGreaterThan(narrowedHeight);+ await userEvent.click(canvas.getByRole('button', { name: 'Reset notes' }));+ expect(textarea).toHaveValue(+ 'One line of notes that wraps at a narrower width.',+ );+ await waitFor(() => expect(textarea.clientHeight).toBe(narrowedHeight));+ },+};diff --git a/packages/twenty-ui/src/primitives/input/Textarea/__stories__/TextareaInteractions.stories.tsx b/packages/twenty-ui/src/primitives/input/Textarea/__stories__/TextareaInteractions.stories.tsxindex 3ae1fb0ab7d..b59de948ef3 100644--- a/packages/twenty-ui/src/primitives/input/Textarea/__stories__/TextareaInteractions.stories.tsx+++ b/packages/twenty-ui/src/primitives/input/Textarea/__stories__/TextareaInteractions.stories.tsx@@ -2,6 +2,7 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';import { useState } from 'react';import { expect, fn, userEvent, within } from 'storybook/test';+import { Button } from '@ui/primitives/input/Button/Button';import { Field } from '@ui/primitives/input/Field/Field';import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';@@ -15,9 +16,9 @@ const ControlledTextareaExample = (props: TextareaProps) => {return (<><Textarea {...props} value={value} />- <button type="button" onClick={() => setValue('a\nb\nc')}>+ <Button type="button" onClick={() => setValue('a\nb\nc')}>Apply value- </button>+ </Button></>);};diff --git a/packages/twenty-ui/src/primitives/input/Textarea/__tests__/Textarea.test.tsx b/packages/twenty-ui/src/primitives/input/Textarea/__tests__/Textarea.test.tsxindex d89505f5db7..165990c8540 100644--- a/packages/twenty-ui/src/primitives/input/Textarea/__tests__/Textarea.test.tsx+++ b/packages/twenty-ui/src/primitives/input/Textarea/__tests__/Textarea.test.tsx@@ -1,3 +1,14 @@+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { isFunction } from '@sniptt/guards';+import { createRef } from 'react';+import { expectTypeOf, vi } from 'vitest';++import { Field } from '@ui/primitives/input/Field/Field';+import { type InputProps } from '@ui/primitives/input/Input/types/InputProps';++import { type TextareaProps } from '../types/TextareaProps';+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';import { Textarea } from '../Textarea';@@ -10,3 +21,162 @@ runComponentConformance({ownClassName: styles.textarea,renderPropTagName: 'textarea',});++describe('Textarea native integration', () => {+ it('types input and textarea native events and attributes separately', () => {+ expectTypeOf<NonNullable<InputProps['onChange']>>()+ .parameter(0)+ .toHaveProperty('currentTarget')+ .toEqualTypeOf<EventTarget & HTMLInputElement>();+ expectTypeOf<NonNullable<TextareaProps['onChange']>>()+ .parameter(0)+ .toHaveProperty('currentTarget')+ .toEqualTypeOf<EventTarget & HTMLTextAreaElement>();+ expectTypeOf<TextareaProps>().not.toHaveProperty('type');+ expectTypeOf<InputProps>().not.toHaveProperty('rows');+ expectTypeOf<TextareaProps['onValueChange']>().toEqualTypeOf<+ InputProps['onValueChange']+ >();+ });++ it('composes native handlers and refs through a textarea render callback', async () => {+ const user = userEvent.setup();+ const ref = createRef<HTMLTextAreaElement>();+ const renderRef = createRef<HTMLTextAreaElement>();+ const onValueChange = vi.fn();+ const onChange = vi.fn();+ const onRenderChange = vi.fn();+ render(+ <Field.Root invalid>+ <Textarea+ aria-label="Notes"+ ref={ref}+ onChange={onChange}+ onValueChange={onValueChange}+ render={(props, state) => {+ expectTypeOf(props.ref).toEqualTypeOf<TextareaProps['ref']>();+ return (+ <textarea+ {...props}+ ref={(node) => {+ renderRef.current = node;+ if (isFunction(props.ref)) return props.ref(node);+ }}+ data-field-invalid={state.valid === false}+ onChange={(event) => {+ onRenderChange(event.currentTarget);+ props.onChange?.(event);+ }}+ />+ );+ }}+ />+ </Field.Root>,+ );+ const textarea = screen.getByRole('textbox', { name: 'Notes' });+ await user.type(textarea, 'a{enter}b');+ expect(ref.current).toBe(textarea);+ expect(renderRef.current).toBe(textarea);+ expect(textarea).toHaveAttribute('data-field-invalid', 'true');+ expect(onRenderChange).toHaveBeenLastCalledWith(textarea);+ expect(onChange).toHaveBeenCalledTimes(3);+ expect(onValueChange).toHaveBeenCalledTimes(3);+ expect(onValueChange).toHaveBeenLastCalledWith(+ 'a\nb',+ expect.objectContaining({+ reason: 'none',+ event: onChange.mock.calls[2]?.[0].nativeEvent,+ cancel: expect.any(Function),+ }),+ );+ });++ it('combines caller descriptions with Field descriptions and errors', () => {+ render(+ <>+ <p id="notes-help">Additional guidance</p>+ <Field.Root invalid>+ <Field.Label>Notes</Field.Label>+ <Textarea aria-describedby="notes-help" />+ <Field.Description>Team context</Field.Description>+ <Field.Error match>Notes need review</Field.Error>+ </Field.Root>+ </>,+ );++ expect(+ screen.getByRole('textbox', { name: 'Notes' }),+ ).toHaveAccessibleDescription(+ 'Additional guidance Team context Notes need review',+ );+ });++ it('retains native textarea form and Field behavior', async () => {+ const user = userEvent.setup();+ const ref = createRef<HTMLTextAreaElement>();+ render(+ <>+ <form id="notes-form" aria-label="Notes form" />+ <Field.Root name="notes">+ <Field.Label>Notes</Field.Label>+ <Textarea+ form="notes-form"+ ref={ref}+ required+ rows={3}+ maxLength={20}+ defaultValue="Initial notes"+ />+ <Field.Description>Team context</Field.Description>+ </Field.Root>+ <Textarea+ form="notes-form"+ aria-label="Private"+ name="private"+ defaultValue="Excluded"+ disabled+ />+ <Textarea+ form="notes-form"+ aria-label="Reference"+ name="reference"+ defaultValue="Read only"+ readOnly+ />+ </>,+ );+ const form = screen.getByRole<HTMLFormElement>('form', {+ name: 'Notes form',+ });+ const textarea = screen.getByRole('textbox', { name: 'Notes' });+ await user.click(screen.getByText('Notes'));+ expect(textarea).toHaveFocus();+ expect(textarea).toHaveAccessibleDescription('Team context');+ expect(ref.current?.form).toBe(form);+ expect(ref.current?.checkValidity()).toBe(true);+ expect(Object.fromEntries(new FormData(form))).toEqual({+ notes: 'Initial notes',+ reference: 'Read only',+ });+ await user.type(textarea, '{enter}More content');+ expect(ref.current?.value).toHaveLength(20);+ await user.clear(textarea);+ expect(ref.current?.checkValidity()).toBe(false);+ form.reset();+ expect(textarea).toHaveValue('Initial notes');+ });+});++it('preserves native render height and manual resize styles when automatic sizing is off', () => {+ render(+ <Textarea+ aria-label="Manual notes"+ style={{ resize: 'vertical' }}+ render={<textarea style={{ blockSize: 120 }} />}+ />,+ );+ expect(screen.getByRole('textbox', { name: 'Manual notes' })).toHaveStyle({+ blockSize: '120px',+ resize: 'vertical',+ });+});diff --git a/packages/twenty-ui/src/primitives/input/Textarea/internal/TextareaControl.tsx b/packages/twenty-ui/src/primitives/input/Textarea/internal/TextareaControl.tsxnew file mode 100644index 00000000000..d513bbe619e--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Textarea/internal/TextareaControl.tsx@@ -0,0 +1,31 @@+import { type Input as InputPrimitive } from '@base-ui/react/input';+import { mergeProps } from '@base-ui/react/merge-props';+import { useRender } from '@base-ui/react/use-render';+import { type ComponentPropsWithRef } from 'react';++import { type TextareaProps } from '../types/TextareaProps';++type TextareaControlProps = {+ controlProps: ComponentPropsWithRef<'textarea'>;+ nativeProps: ComponentPropsWithRef<'textarea'>;+ state: InputPrimitive.State;+ render: TextareaProps['render'];+};++export const TextareaControl = ({+ controlProps,+ nativeProps,+ state,+ render,+}: TextareaControlProps) => {+ const { ref: controlRef, ...controlElementProps } = controlProps;+ const { ref: nativeRef, ...nativeElementProps } = nativeProps;++ return useRender({+ defaultTagName: 'textarea',+ render,+ state: { ...state },+ ref: [controlRef ?? null, nativeRef ?? null],+ props: mergeProps(controlElementProps, nativeElementProps),+ });+};diff --git a/packages/twenty-ui/src/primitives/input/Textarea/internal/observeTextareaWidth.ts b/packages/twenty-ui/src/primitives/input/Textarea/internal/observeTextareaWidth.tsnew file mode 100644index 00000000000..8da72e3d50e--- /dev/null+++ b/packages/twenty-ui/src/primitives/input/Textarea/internal/observeTextareaWidth.ts@@ -0,0 +1,39 @@+import { isDefined } from '@ui/utilities/utils/isDefined';++import { resizeTextareaToContent } from './resizeTextareaToContent';++export const observeTextareaWidth = (textarea: HTMLTextAreaElement) => {+ if (!isDefined(globalThis.ResizeObserver)) {+ return undefined;+ }++ let animationFrame: number | undefined;+ let previousWidth = textarea.clientWidth;+ const observer = new ResizeObserver(() => {+ const width = textarea.clientWidth;++ if (width === previousWidth) {+ return;+ }++ previousWidth = width;+ if (isDefined(animationFrame)) {+ cancelAnimationFrame(animationFrame);+ }++ animationFrame = requestAnimationFrame(() => {+ animationFrame = undefined;+ resizeTextareaToContent(textarea);+ });+ });++ observer.observe(textarea);++ return () => {+ observer.disconnect();++ if (isDefined(animationFrame)) {+ cancelAnimationFrame(animationFrame);+ }+ };+};diff --git a/packages/twenty-ui/src/primitives/input/Textarea/types/TextareaProps.ts b/packages/twenty-ui/src/primitives/input/Textarea/types/TextareaProps.tsindex f7f4789af04..01d0534c620 100644--- a/packages/twenty-ui/src/primitives/input/Textarea/types/TextareaProps.ts+++ b/packages/twenty-ui/src/primitives/input/Textarea/types/TextareaProps.ts@@ -4,7 +4,11 @@ import { type useRender } from '@base-ui/react/use-render';import { type InputSize } from '@ui/primitives/input/types/InputSize';export type TextareaProps = Omit<- useRender.ComponentProps<'textarea'>,+ useRender.ComponentProps<+ 'textarea',+ InputPrimitive.State,+ useRender.ElementProps<'textarea'>+ >,'className'> & {/**@@ -12,18 +16,12 @@ export type TextareaProps = Omit<* based on the input state.*/className?: string | ((state: InputPrimitive.State) => string | undefined);- /** Called with the new value when the textarea value changes. */onValueChange?: (value: string,eventDetails: InputPrimitive.ChangeEventDetails,) => void;/** Visual size of the textarea. */size?: InputSize;- /** Grows the textarea with its content instead of showing a scrollbar. */autoResize?: boolean;- /**- * Maximum number of rows the textarea grows to when `autoResize` is set.- * Longer content scrolls.- */maxRows?: number;};