Repository navigation
Description
Context
AskUserFormCard has two rows={1} textareas, and they size inconsistently:
- The free-text question answer measures itself on every input:
style.height = "auto", thenstyle.height = scrollHeight(onInput,packages/ui-kit/src/decisions/AskUserFormCard.tsx:424-428). That forces a synchronous layout per keystroke. The height also lives outside React, so a value that changes without an input event (a restored or cleared answer) keeps a stale height. - The "Other" answer under a choice question (
packages/ui-kit/src/decisions/AskUserFormCard.tsx:802-820) never grows. A multi-line answer scrolls inside a one-row box.
Both are styled by .bk-askform .bk-field textarea (packages/ui-kit/src/tokens.css:2255), which already sets width: 100%, min-height: 44px and max-height: calc(4.5em + 22px).
The composer solved the same problem with field-sizing: content. The composer follows soft wrap (docs/decisions/design-kit/components-and-interactions.md:820-824) refuses scrollHeight measurement because it is "a forced synchronous layout per keystroke".
Guide forms/form-fields-automatically-fit-contents: "Setting field-sizing: content on inputs, selects, or textareas allows them to resize dynamically as the user types". It also warns that "Explicit width and height properties override field-sizing: content".
Support: Chrome Android 123, Samsung 27, Firefox Android 152 (MDN browser-compat-data). Without it, the field stays at its current fixed height and scrolls.
Scope
- Add
field-sizing: contentto.bk-askform .bk-field textareaintokens.css. Keep the existingmin-height/max-heightas floor and cap. Keepwidth: 100%, because it stops a long placeholder from changing the width. - Delete the two
style.heightwrites in the text answer'sonInput. Thechange(...)call stays. - Both textareas, the text answer and "Other", grow from one line to the cap and then scroll.
Out of scope
- The other ask-user cards (
AskUserCard,AskUserListCard,AskUserRankCard,AskUserGroupCard) andComposer. - Changing the cap, padding, font or
maxLength. - A JavaScript fallback for browsers without
field-sizing.
Acceptance criteria
-
git grep -n "scrollHeight" -- packages/ui-kit/src/decisionsreturns nothing. - A real-browser story test fails on the tree before the change and passes after:
- Typing three lines into the "Other" textarea makes it taller than its empty height.
- Typing ten lines stops at the
max-heightcap withscrollHeight > clientHeight.
- The same test passes for the free-text answer.
- Setting the text answer's controlled value programmatically to three lines (no input event) gives the same height as typing them.
- Android support:
field-sizingis not in a Chromium target below its baseline, so no detection is needed. The PR states that browsers without support keep the 44px field and scroll.
Verification
node scripts/visual.mjs --project=storybook --filter=AskUserFormCard.stories
bun run visual
bun run test
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
@schlessera/brain-ui-kit: the "Other" field now grows. No integration-contract surface is involved.
Activity