Skip to content

feat(frontend): form primitives on React Aria - #158

Merged
sgomez merged 8 commits into
frontend-rebuildfrom
agent/frontend/137
Nov 25, 2026
Merged

sgomez merged 8 commits into
frontend-rebuildfrom
agent/frontend/137

Conversation

@sgomez

@sgomez sgomez commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Closes #137. Part of #135.

Summary

 design-system/
-├── Input.tsx       <input>
+├── Input.tsx       RAC Input            (data-invalid, data-hovered, data-focus-visible)
-├── TextArea.tsx    <textarea>
+├── TextArea.tsx    RAC TextArea
-├── Field.tsx       <div> + <label htmlFor={id}>
+├── Field.tsx       RAC TextField + Label + Text slot="description" + FieldError
-├── Segmented.tsx   <nav> of links or aria-pressed buttons
+├── Segmented.tsx   Segmented: ToggleButtonGroup (radiogroup) · LinkSegmented: <nav> + RAC Link, aria-current
-├── Editor.tsx      <textarea>
+├── Editor.tsx      RAC TextArea inside the gutter markup
-├── Switch.tsx      native input
+├── Switch.tsx      useSwitch on the visible native input
-├── Check.tsx       native checkbox or radio
+├── Check.tsx       useCheckbox on the visible native input
+├── Radios.tsx      useRadioGroup + useRadio on visible native inputs
 ├── Select.tsx      native <select> (unchanged, now with a story)
+└── props.ts        defined(), moved out of Button.tsx

Field owns the value, so the label, help and error are wired by React Aria:

-<Field id="publish-comment" label="Comment" optional>
-  <TextArea id="publish-comment" rows={3} value={comment} onChange={onComment} />
+<Field label="Comment" optional value={comment} onChange={onComment}>
+  <TextArea rows={3} />
 </Field>

console.css: three [data-…] selectors added to existing rules, with the same values: .input[data-invalid] (next to .input.is-error), .seg button[data-selected] and .seg a[data-current] (next to .seg button.on and .seg a.on). Link segments follow the link tabs of #157: React Aria Link under LinkRouter.

Evidence

  • Stories with play functions and axe for Input, TextArea, Field, Segmented, Editor, Select, Switch, Check and Radios: default, hover, focus-visible, keyboard, disabled, invalid, help, optional, marks, busy, go to line.
  • npm test: every file passes, coverage 99 % lines. npm run lint, npm run typecheck, composer static and composer test pass.
  • npm run test:visual: three runs, zero diffs. No reference screenshot changes.
  • composer build: no diff.

Departures and notes

  • API changes. Field takes value/onChange and no id; Input and TextArea lose id. Link segments move to LinkSegmented, button segments to Segmented (ToggleButtonGroup: radiogroup/radio aria-checked in place of aria-pressed, arrow keys move between segments). Call sites updated: EntityList and PublishPanel.
  • Radio. Check no longer takes type="radio": a single radio has no meaning in React Aria. Radios is a group with its own label (.field + .label, existing classes). The board shows radios inline in a demo row, with no group label; the group is not on a board, so it is open to the maintainer.
  • Field error. role="alert" moves from the .msg-error box to the text inside it, because FieldError does not accept role. The error is now also the input's accessible description.
  • New dependencies. react-aria 3.53.1 and react-stately 3.51.0, the versions react-aria-components already pins, added as direct dependencies for useSwitch/useCheckbox/useRadio. Recorded in SPEC.md 3.7.
  • Hover stories. storybook/test hovers with synthetic events, and the real pointer's first move into the frame can end that hover, so the hover stories retry until it holds.
  • The old jsdom tests for these primitives (Inputs.test.tsx, Navigation.test.tsx, which held only Segmented after Overlay and navigation primitives on React Aria #157, the Editor part of Text.test.tsx) are replaced by the stories.

Merge Danger

Door: two-way

Blast Radius: forms

Pages look the same (zero screenshot diffs). Behaviour changes: arrow-key navigation in button segments, label/description/error wiring in fields.

@sgomez
sgomez force-pushed the agent/frontend/137 branch from db6886b to 1f7b542 Compare November 25, 2026 19:07
@sgomez
sgomez merged commit 390272e into frontend-rebuild Nov 25, 2026
16 checks passed
@sgomez
sgomez deleted the agent/frontend/137 branch November 25, 2026 19:11
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