Skip to content

feat(prompt-field): add collapsed/expanded layout with animated transition - #6585

Draft
rubencarvalho wants to merge 5 commits into
mainfrom
ruben/feat-prompt-field-collapsed-expanded
Draft

feat(prompt-field): add collapsed/expanded layout with animated transition#6585
rubencarvalho wants to merge 5 commits into
mainfrom
ruben/feat-prompt-field-collapsed-expanded

Conversation

@rubencarvalho

@rubencarvalho rubencarvalho commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

Adds an expanded boolean property to swc-prompt-field, matching the collapsed/expanded variant naming used in the Figma AI Prompt Field spec.

  • Collapsed (default): single-line row; send/stop button sits inline with the textarea, no upload button.
  • expanded: taller card with a separate action bar below the textarea (upload button + send/stop).
  • Toggling expanded animates smoothly: the box's padding/gap transition directly, and the action bar's height animates via the calc-size() progressive-enhancement pattern already used in accordion-item.css. The send/stop button itself is conditionally rendered in only one location at a time (not duplicated/hidden), so it has no separate fade of its own — it appears/disappears instantly as the surrounding box/action-bar reshapes around it, and .swc-PromptField-send/.swc-PromptField-stop stay unambiguous single-match selectors.
  • Border radius is a constant corner-radius-800 token in both layouts (no computed "pill" radius) — this originally computed a dynamic stadium radius from the collapsed row's height, which both risked the border-radius: 50%-on-a-non-square-box ellipse bug (see below) and didn't match the reference implementation, which uses one constant radius regardless of layout.
  • Fixes a rendering bug found while implementing this: the collapsed layout's border-radius: token("corner-radius-full") resolves to 50%, which renders an ellipse on a non-square box rather than a stadium shape (see linear-progress-base.css for the same class of issue). Superseded by the constant-radius fix above.
  • The always-visible "Prompt" label is now visually hidden (but still associated via aria-labelledby) in the collapsed layout, matching the Figma mock, via the shared swc-VisuallyHidden utility.
  • Added an automated ARIA-snapshot test for the expanded layout (prompt-field.a11y.spec.ts), alongside the existing collapsed/default one.
  • The leading icon before the textarea (both layouts) is a static placeholder for now (reusing the existing ThreeDotsIcon) — it reserves the spot for the pixel-loader idle/generating indicator, which is intentionally out of scope here.
  • Caps textarea growth at 40vh (via --swc-prompt-field-max-block-size, overridable), combined with the existing max-rows cap via min() — guards against max-rows worth of text overflowing small/embedded viewports.

Branding colors (the --brand OKLCH gradient system from the design spec's implementation) are intentionally out of scope for this PR.

Motivation and context

Bringing the AI Prompt Field branding/behavior over to SWC; this PR is the first piece — the collapsed/expanded layout toggle — split out from the branding-colors work.

Related issue(s)

Screenshots (if appropriate)

Collapsed vs. expanded (see Layout story under Options):

Collapsed (default) Expanded
Single-line row, send button inline Card with label, textarea, and action bar (upload + send)

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed the Accessibility Practices for this feature.
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Toggle expanded layout

    1. Go to Storybook: Conversational AI / Prompt field / Playground
    2. Toggle the expanded control on and off
    3. Expect a smooth animated transition between the single-line row and the expanded card with action bar; no layout jump or flash
  • Collapsed default has no upload button

    1. Go to the Overview story (expanded unset)
    2. Expect only the textarea and send button, no upload (+) button, no visible "Prompt" label

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Accessibility testing checklist

  • Keyboard (required — document steps below)

    1. Tab into the Playground story's swc-prompt-field; confirm the textarea receives focus and Tab reaches exactly one send/stop button, matching the currently visible layout
    2. Toggle expanded and repeat; confirm Tab order updates immediately to the new layout's button, and (when expanded) also reaches the upload button
    3. Expect no focus trap and a visible focus indicator on all reachable controls
  • Screen reader (required — document steps below)

    1. With expanded unset, navigate to the field with VoiceOver/NVDA; confirm the textarea's accessible name still resolves to "Prompt" (via aria-labelledby) even though the label is visually hidden
    2. Confirm exactly one "Send"/"Stop generating" button is announced, matching the currently visible layout
    3. Toggle expanded and confirm the upload button ("Add attachment") becomes announced/reachable, and disappears again when collapsed

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 04ef5c5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

📚 Branch Preview Links

🔍 Gen1 Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-6585

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@rubencarvalho
rubencarvalho force-pushed the ruben/feat-prompt-field-collapsed-expanded branch 2 times, most recently from 5a2bcb2 to ca6c91f Compare August 6, 2026 12:22
…ition

Adds an `expanded` boolean property to `swc-prompt-field`, matching the
Figma design's collapsed/expanded variant naming. Defaults to the
single-line collapsed pill (send button inline with the textarea);
`expanded` renders the taller layout with a separate action bar
(upload button + send/stop button on their own row).

Also fixes a rendering bug uncovered while implementing this: the
collapsed pill's border-radius used `corner-radius-full` (50%), which
renders an ellipse on a non-square box instead of a stadium shape.
Radius is now derived from half of the pill's own fixed block-size,
mirroring the existing fix in linear-progress-base.css.

The toggle between layouts is animated: box shape (border-radius,
padding, gap) transitions directly, and the action bar's height
animates via the calc-size() progressive-enhancement pattern already
used in accordion-item.css. The send/stop button crossfades between
its inline and action-bar positions; the inactive copy is marked
inert + aria-hidden, following the same pattern as AccordionItem's
collapsed content.
@rubencarvalho
rubencarvalho force-pushed the ruben/feat-prompt-field-collapsed-expanded branch from ca6c91f to f668f67 Compare August 6, 2026 13:28
rubencarvalho and others added 4 commits August 6, 2026 16:12
…duplicated+hidden

Replaces the duplicate-button crossfade (one inline copy, one action-bar
copy, inactive one marked inert/aria-hidden) with a single conditionally
rendered button per layout. Simpler, and removes the class of bugs the
duplication caused: ambiguous .swc-PromptField-send/-stop queries,
inert-vs-focus interactions, and the compensating negative-margin hack
needed to cancel the row's gap around the crossfading copy.

The box shape and action bar height still animate on expand/collapse;
only the button itself now appears/disappears instantly rather than
fading, since there's no second instance to fade into.
…om property

Adds --swc-prompt-field-max-block-size (default 40vh) to the textarea's
max-block-size, combined with the existing max-rows cap via min() so
whichever is smaller wins. Guards against max-rows worth of text
overflowing the viewport on small/embedded surfaces; textareas already
scroll internally once content exceeds this, so no extra overflow rule
is needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant