Skip to content

feat(forms): one form kit — field wiring, group fields, choice cards, one field height - #501

Merged
Ardnived merged 5 commits into
mainfrom
ux/form-kit
Nov 26, 2026
Merged

Ardnived merged 5 commits into
mainfrom
ux/form-kit

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Every form builds from FormField around the shared atoms. FormField passes each control its wiring, and has a fieldset mode for choice groups.
  • One field height utility, field-height: 40px with a mouse, 44px on touch, as fields already drew. Short choices use a form-size ToggleGroup; longer or described choices use RadioGroup choice cards.
  • Report an issue and Registration take every field's wiring from FormField. The registration start date is now a dropdown (the Select atom).

Change outline

Components — FormField hands its control the wiring

The caller no longer builds the id, describedby or invalid state itself. A group of controls has a single legend naming it.

 FormField                                         src/components/molecules/FormField/FormField.tsx
-  children: ReactNode                             # each form assembled id / aria-describedby itself
+  children: ReactNode | (control: FieldControlProps) => ReactNode
+    control = { id, aria-labelledby, aria-describedby, aria-required, isInvalid }
+  target (type-level union)
+    htmlFor             → <label for>, ids keyed by the control's id
+    name, no htmlFor    → a control that labels itself (checkbox): ids keyed by name, no second <label>
+    as="fieldset", name → <fieldset><legend id=name-label>; the group points back at it
   help | error (the error replaces the help; announced unless announceError=false)

Behaviour — the kit atoms

 fieldChrome                                       src/components/atoms/Select/Select.tsx
-  base … pointer-coarse:min-h-11; trigger/plain: h-10
+  single-line: field-height                       # globals.css: h-10, pointer-coarse:h-11
+  multiline: h-auto                               # @/styles/tv registers field-height as a height
 Select, Checkbox
+  Checkbox takes aria-labelledby, aria-required, so the wiring spreads onto it
 Select
+  forwardRef → trigger; takes id, aria-labelledby, aria-required
 ToggleGroup                                       src/components/atoms/ToggleGroup/ToggleGroup.tsx
+  size: sm (h-8, 44px floors on touch, as before) | md (field-height; the caller's grid sizes items)
+  required (single): an item click on the chosen item is prevented, so the answer stays
+  aria-required only on the single choice's radiogroup
 RadioGroup                                        src/components/atoms/RadioGroup/RadioGroup.tsx
+  option { icon, hint } → a choice card: the icon's circle stands in for the sr-only radio,
+    the card draws the focus ring
+  root takes the caller's layout (grid grid-cols-2)
-  collapseAfter / moreLabel reveal link           # its only caller, the date list, is now a Select

Components — the forms on the kit

 ReportIssueForm › AuthoredField                   src/components/organisms/ReportIssueForm/ReportIssueForm.tsx
-  typed = { id, aria-describedby: fieldDescribedBy(…), aria-required, … }
+  FormField(htmlFor=id | name=id for a checkbox) { wiring => control({ ...wiring, isInvalid }) }
+    checkbox: spreads the wiring too, so it points at its help and error
+    select: ref → trigger, named by its linked <label> (aria-label dropped)
 RegistrationForm › RegistrationFields             src/components/organisms/RegistrationForm/RegistrationForm.tsx
-  startingAt: RadioGroup, 3 dates + "Show more dates"
+  startingAt: Select of every upcoming date, ref → trigger
-  LabeledInput / LabeledTextarea: hand-wired <input>/<textarea> on fieldChrome
+  LabeledInput / LabeledTextarea: Input / Textarea from the render prop

Preview

Preview pending: Cloudflare has not built the branch yet. Once it has, open:

  • Component library, Molecules / Form Field, "Form atoms" section: Input, Textarea, Select, RadioGroup cards, ToggleGroup and Checkbox.
  • Component library: Atoms / Inputs / Radio Group (choice cards) and Atoms / Inputs / Toggle Group ("In a form" section).
  • App at 390×844: settings cog, then Report an issue; and any class's Register panel (the date dropdown).

Test results

  • Lean gate: ✓ lint, typecheck, test:run (2549 passed), rebased on current main
  • New specs: FormField wiring and group mode, ToggleGroup SSR and a jsdom spec for required (watched failing with the guard off), RadioGroup choice cards, fieldChrome height merging (watched failing without the tailwind-merge registration)
  • Accessibility gate (scripts/check-a11y.mjs, 390×844, coarse pointer), on the five changed stories: clean
  • Build: N/A locally (CI)

Manual verification

  1. In Ladle's Molecules / Form Field, check every field is 40px with a mouse. At 390×844 with touch emulation they should be 44px; the seven day pills measure ~45px wide and fit the row. A Report-an-issue checkbox shows its label once.
  2. Filter panel on a phone: its selects and date fields are unchanged (44px on touch, as on main).
  3. Report an issue at 390×844: tap each label and its field takes focus.
  4. Register for a class: the date dropdown lists every upcoming date ("Next week - Wed, …"). A failed submit focuses the first invalid field.

Notes for reviewer

  • No field changes height. main already drew 44px on touch through pointer-coarse:min-h-11; field-height states the same sizes as one utility a textarea's h-auto can replace.
  • Add-a-class (feat(widget): submit or correct a class, and opt into a mailing list #318) is not in this PR, because it is not on main yet. Once this merges, feat(widget): submit or correct a class, and opt into a mailing list #318 rebases onto the kit and drops ValidatedInput, ChoiceCard and radioKeys.
  • registration.form.show_more_dates has no caller left, so it is listed in RETIRING_KEYS. chore(translations): drop the retired registration.form.show_more_dates atlas key SahajCloud#1282 drops it from sy-atlas-translations.
  • The registration date is a dropdown (the register-form-calm card's change), as asked. The option text keeps main's wording.
  • Dismissed review findings:
    • ReportIssueForm marks a field invalid without error text. Kept on purpose, as on main: a required block with no copy of ours is still invalid, and fallback text would be new copy.
    • The shared story fixtures and the label/legend classes are duplicated. Kept: two short strings, and stories stay self-contained.
    • Combobox takes no id or ref. No form uses it in a FormField yet, so it is left out of the kit list instead.
Detail
  • field-height asks the tap-floor question (pointer-coarse), the same as The atlas widget can be used with a keyboard and a screen reader #432, rather than field-size's zoom question. So a narrow desktop window keeps 40px fields.
  • required on ToggleGroup started as a filter on onValueChange. That missed the uncontrolled case: with defaultValue, Radix's own state still cleared. It now prevents the item's click, and Radix skips its toggle when the click is prevented.
  • Choice cards are relative. Otherwise the sr-only radio's containing block sits outside a scrolling drawer body, so it does not scroll with its card.
  • Review passes run: /simplify (reuse, simplification, efficiency, altitude), /code-review at medium, /security-review (styles path trigger; no findings), and the comment lint (clean).

🤖 Generated with Claude Code

@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running
✋ handed back: address-review did not finish after 3 attempts

recent dispatches
  • 03:21Z address-review · attempt 3 · session · timed out
  • 03:21Z address-review · attempt 3 · session
  • 20:38Z address-review · attempt 2 · session · timed out
  • 20:38Z address-review · attempt 2 · session
  • 16:19Z address-review · attempt 1 · session · timed out

Written by the sydevs dispatcher. Sessions never edit this comment.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design c536549 Nov 26 2026, 05:53 PM

@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 26, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 26, 2026
@Ardnived
Ardnived enabled auto-merge November 26, 2026 16:11

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The shape is right. One FormField render prop replaces the wiring each form assembled by hand, and the registration date as a Select beats a collapsing radio list.

Two claims do not hold. The headline change — fields grow 40→44px on touch — is a no-op: pointer-coarse:min-h-11 already won over h-10, so every fieldChrome field was already 44px there. And the new kit paragraph enrols Combobox and Checkbox, neither of which can take FieldControlProps; the diff's own checkbox branch proves it.

No contract surface is touched: no Payload types, no docs/embedding.md, no CSP. show_more_dates is correctly retired against sydevs/SahajCloud#1282.

Findings

  • should-fix — Select.tsx:25: the 40→44px claim is a no-op. Correct the body and step 2.
  • should-fix — DESIGN_SYSTEM.md:83: the kit names two atoms the render prop cannot wire.
  • should-fix — Streamline: ToggleGroup.tsx:126 (required, which SearchFilters.tsx:266 does at the caller), FormField.tsx:130 (fieldDescribedBy, one caller), FormField.stories.tsx:162 (copy).
  • consider — RadioGroup.tsx:24: three capabilities land with no caller on main.
  • consider — FormField.tsx:150: a self-labelled control gets a second visible label.

What was checked

Read whole on the branch: FormField, Select, ToggleGroup, RadioGroup, Input, Textarea, Combobox, Checkbox, both forms, tv.ts, globals.css, and both docs. Ladder walked for field-height, FieldControlProps, FieldTarget, withIcon.

Grepped every caller of the removed and added API: collapseAfter, moreLabel, show_more_dates, size="md", required, as="fieldset", atoms/RadioGroup. SortMenu and SettingsMenu use Radix's own. Every path the body names exists.

Streamliner: 16 pieces covered, 12 kept, 3 of 4 sketches posted.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/components/atoms/Select/Select.tsx Resolved
Comment thread DESIGN_SYSTEM.md Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 26, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 26, 2026
Ardnived and others added 5 commits November 26, 2026 10:51
… one field height

Every form now builds from FormField around the shared atoms, and no form
hand-rolls a field shell, radio or segmented control.

- FormField hands its control the wiring (id, aria-describedby,
  aria-required, isInvalid) through a render prop, and gains a group form
  (`as="fieldset"`: a legend, keyed by `name`, that the group points back at).
- `field-height` (globals.css): 40px with a mouse, 44px on touch, on
  `fieldChrome`, so every field in every form is one size. It replaces the
  fixed h-10 and the pointer-coarse min-height (#432).
- ToggleGroup: `size="md"` (the field height), `required` (a re-press keeps the
  answer), aria-labelledby/aria-required.
- RadioGroup: an option with `icon` and `hint` is a choice card; the root takes
  a caller's layout.
- Select forwards its ref to the trigger and takes an `id`, so a label names it
  and react-hook-form can focus it after a failed submit.
- Report an issue and Registration wire every field through FormField. The
  registration start date is a Select dropdown; `registration.form.show_more_dates`
  has no caller left and is listed as retiring.
- Ladle: Molecules / Form Field with a "Form atoms" section showing the set.
- DESIGN_SYSTEM.md and src/components/AGENTS.md say every form is one kit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tailwind-merge did not know our `field-height` utility, so a textarea
shipped `field-height h-auto` and stylesheet order alone decided its
height. `@/styles/tv` now registers it as a height, and a spec pins it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- ToggleGroup: the minimum widths belong to `sm`; `md` is the field height
  alone, and the caller's grid sets its own gap (the md gap compound never
  reached the root). `required` is enforced at the item click, so it holds
  uncontrolled too; `aria-required` only on the single choice's radiogroup.
- RadioGroup: the collapse-and-reveal feature lost its only caller with the
  date dropdown, so it goes; a choice card is `relative`, keeping its hidden
  radio inside the card in a scrolling body.
- FormField: a fieldset must name itself (type-level); a self-labelled
  control (the report form's checkbox) keys its help and error by `name`,
  so its aria-describedby now resolves. The id helpers leave the barrels.
- Report: the select drops an aria-label that overrode its linked label.
- Registration: options are plain strings (Radix reads type-ahead from the
  item text); an empty value is '' rather than undefined.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… checkbox

- Checkbox takes aria-labelledby and aria-required, so ReportIssueForm
  spreads the field's wiring onto it as it does every other control.
- FormField renders no <label> for a control that labels itself (`name`
  without `htmlFor`); the checkbox showed its label twice.
- fieldDescribedBy had one call site left, so it folds into FormField.
- The kit list drops Combobox, which takes no wiring; the Form Field story
  describes what a viewer sees, not the API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Ardnived
Ardnived merged commit 04f0836 into main Nov 26, 2026
14 checks passed
@Ardnived
Ardnived deleted the ux/form-kit branch November 26, 2026 17:55
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Done in SYDevelopers Technical Roadmap Nov 26, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 26, 2026
Ardnived added a commit that referenced this pull request Nov 26, 2026
…eld (#510)

* feat(a11y): one focus outline, and forms that start in their first field

Keyboard focus drew three styles: Button's ring with an offset, every other
atom's ring without one, the geocoder's box-shadow, and Mapbox's blue halo on
its credits button even for a mouse click. A `focus-ring` utility replaces all
of them: a 2px inset outline in the focus colour with a 2px band of the panel's
colour inside it, so it survives an overflow clip and shows on a filled
control of its own hue. `focus-ring.test.ts` refuses a control's own ring.

`touch-target` now asks `useCoarsePointer`'s question, `(hover: none) and
(pointer: coarse)`, so a touchscreen laptop's mouse meets no invisible area.
The geocoder's 20px clear button gains the same 44px area through its sheet.

The Modal atom starts a dialog holding a field in that field rather than on
its ×; on a touch-only screen the dialog itself takes focus, so no keyboard
rises unasked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(a11y): the choice card draws the shared focus outline

#501's choice card rings itself with `has-[:focus-visible]:ring-2 ring-focus`
while its radio is hidden behind the icon: a third style, and on the checked
card in dark mode a ring in the fill's own colour. It takes
`focus-ring-within`, the same drawing as `focus-ring` on a box whose focus
lands on a hidden control inside it. The drawing itself is `focus-outline`,
which the Mapbox rules also apply now, since their selectors already name the
state. The drift spec reads a ring behind any focus state, `has-[…]` included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(a11y): keep the guide and gate edits to their own lines

The first pass ran Prettier over the whole of src/components/AGENTS.md and
scripts/check-a11y.mjs, re-padding tables and requoting strings no change here
touched. Both now carry only the touch-target query and the focus-outline note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor: simplify per /simplify pass

- One `TOUCH_ONLY_QUERY` in `config/responsive.ts`, read by `useCoarsePointer` and the Modal,
  and pinned against `touch-target` by the spec rather than a second literal.
- `focus-outline` is Tailwind's own outline and inset-ring utilities, not a hand-copied
  `--tw-*` shadow stack. The choice card takes it behind `has-[:focus-visible]:`, so the
  one-call-site `focus-ring-within` goes. Of the Mapbox resets only the credits button's halo
  needed one.
- The geocoder's clear button takes `touch-target` and `focus-ring` from `MapSearch`'s wrapper:
  search-js-web nests no shadow root, so the copied `::after` and outline in its sheet go.
- The Modal focuses the dialog, then the first field once one exists, so the report form
  behind its spinner starts in its first field too; a dialog with no field no longer opens
  on its ×. The swallowed `<select>` and hidden fields leave the selector.
- The carousel's touch spacing follows the tap areas it makes room for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* style(select): class order after the rebase

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(changelog): link the focus and tap-area entries to #510

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(a11y): address the adversarial review

- The Modal's field selector and finder fold into their one caller.
- The component guide points at `TOUCH_ONLY_QUERY` and the focus spec instead of
  restating the query, the outline's mechanism and the spec's rule.
- `focus-ring.test.ts` pins the geocoder field's hand-copied outline against
  `focus-outline`, which its sheet cannot apply.
- MapSearch's wrapper reaches the clear × by its seeded `--ClearBtn` suffix,
  not every `<button>` under it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Ardnived added a commit that referenced this pull request Nov 26, 2026
…t stop

The walk presses Tab once per tabbable element, but a roving-tabindex
group (#501's weekday picker) is one Tab stop holding seven, so on
molecules--form-field the walk outlasted the page, wrapped to ff-name and
reported it as a backwards jump. main has failed the gate since #501
and #510 landed together.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ardnived added a commit that referenced this pull request Nov 26, 2026
…isitor's own format (#509)

* feat(dates): every date and time through one Intl formatter, in the visitor's own format

Dates and times now go through src/lib/time.ts in regionalLocale(locale):
the browser's first language decides, so an en-GB browser reads
"17:45–18:45" and "Wed 18 Nov", en-US "5:45 – 6:45 PM" and "Wed, Nov 18",
and a browser whose first language is another keeps that language's clock
on the English page (cs-CZ "17:45", a Brazilian browser on en-BR-u-hc-h23).

- Times use timeStyle 'short', so whole hours keep their minutes.
- A range that wraps past midnight and runs 12 hours or more writes both
  day periods ("5:00 PM – 12:00 PM", not "5:00 – 12:00 PM").
- A year joins a date only when it is not this year.
- Callers: useEventDisplay, the filter time labels, ActiveFilterPills,
  SearchFilters (weekdayNames instead of luxon's Info.weekdays), the
  registration dates, and the calendar header; the Schedule-X grid runs
  regional English as en-GB or en-US by date order (scheduleXLocale).
- Distances follow the same locale: miles for a UK or US region.
- src/AGENTS.md gains the "Dates and times" rule.

Main's #380 clock rule is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor: simplify per /simplify pass

- useLocale() returns formatLocale, so callers stop deriving regionalLocale
  themselves, and formatTimePeriods takes it like its siblings. The specs'
  useLocale mocks pin it, so they no longer read the machine's own locale
  (use-event-display.test.ts failed on an en-GB machine).
- formatTimeRange: the wrap-past-midnight join fires only when formatRange
  actually collapsed a day period, reading the separator off the same parts;
  a 24-hour locale keeps its own range and suffix ("17:00–12:00 Uhr").
- wallClock replaces events.ts's hourClock; formatDate drops its test-only
  `now` for luxon's Settings.now; usesMiles and dayFirst lose catches that
  guarded nothing; scheduleXLocale loses an unreachable row.
- Shorter comments and src/AGENTS.md rule; duplicate tests removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(dates): a Portuguese browser keeps the calendar grid in Portuguese

The regional locale hands Schedule-X the browser's own Portuguese tag
(pt-PT, pt), which matched no entry and fell back to en-US. Key the
table by language so every Portuguese tag runs pt-BR, as main did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(dates): state the rule in the spec comments, not who asked for it

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(dates): a webview with no navigator.languages formats in the page's locale

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(i18n): formatLocale formats, and is never a locale the widget fetches

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(changelog): link the date-format entry to #509

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(calendar): Schedule-X's locale lives with the calendar shaping, not the formatters

scheduleXLocale is calendar configuration with one caller, so it moves from
lib/time.ts into lib/shape/calendar.ts beside the other Schedule-X helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(dates): the dates rule names the module, not its exports

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(a11y-gate): end the keyboard walk when Tab wraps back to the first stop

The walk presses Tab once per tabbable element, but a roving-tabindex
group (#501's weekday picker) is one Tab stop holding seven, so on
molecules--form-field the walk outlasted the page, wrapped to ff-name and
reported it as a backwards jump. main has failed the gate since #501
and #510 landed together.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(a11y-gate): index the last stop so the walk typechecks

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(a11y-gate): an unstamped keyboard stop is not a jump to the top

A stop the page rendered after the audit carries no data-a11y-order, and
Number(null) is 0, so views--event-·-sticky-register failed tab-order at
random whenever the audit read the story before it finished rendering.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher sydevs-dispatcher Bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 27, 2026
@sydevs-dispatcher

Copy link
Copy Markdown
Contributor

The session for address-review did not finish after 3 attempts. I have stopped retrying. A @sydevs-bot verb or mention from you starts me again.

🤖 sydevs dispatcher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants