Skip to content

ui-kit: ask-form textareas grow with field-sizing instead of measuring scrollHeight #2598

Open

Description

@schlessera

Context

AskUserFormCard has two rows={1} textareas, and they size inconsistently:

  • The free-text question answer measures itself on every input: style.height = "auto", then style.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: content to .bk-askform .bk-field textarea in tokens.css. Keep the existing min-height/max-height as floor and cap. Keep width: 100%, because it stops a long placeholder from changing the width.
  • Delete the two style.height writes in the text answer's onInput. The change(...) 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) and Composer.
  • 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/decisions returns 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-height cap with scrollHeight > 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-sizing is 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 lint

Contract impact

  • This touches the integration contract, so it needs the contract label, a CONTRACT: 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

  1. added
    type: fix
    area: ui-kit
    priority: p3
    agent-ready
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-kitpriority: p3type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions