published fresh until

React: build multi-step forms with an error summary

Summary Keep a durable owner for all step values, validate before advancing, and reveal an errored step before focusing its input. Let the summary own failed-attempt focus with shouldFocusError: false

Not for a modal-only form; see case-modal-form-validation-error-states-react-shadcn.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: keep one useForm({ shouldUnregister: false }) and disable built-in focus management with shouldFocusError above conditional steps, or put the draft in shared state before making each step a separate route.

Short answer

As of November 2026, this card targets React 19.3, September 9, 2026 and React Hook Form 7.91.0, using current library docs. Validate the visible step before navigation, the complete payload before persistence, and mount the owning step before moving focus to an invalid field.

Choose / don't choose

  • One form on one page: choose one stable RHF instance and whole-form schema resolver; don't create a separate instance per conditional section (wizard guide).
  • Separate routes: choose explicit shared draft state and per-route forms; React destroys state when it removes a component from the tree. Server errors need a field-to-route mapping.
  • Controlled React state: choose when multiple steps, review screens and server errors need direct access to a single draft; don't retain the only copy in individual uncontrolled DOM inputs. Controlled text inputs need a string value and synchronous onChange. Fields from earlier steps unmount when the step changes, but their values stay in the form; controlled inputs are not mandatory merely because steps unmount (RHF wizard, input, state lifetime).

Not for: a modal-only form; see case-modal-form-validation-error-states-react-shadcn.

Settings that matter

Setting or flagValue / defaultApplies toSource
button typeBack/Next button for manual navigation; final submit; route every submit through the active-step gateCurrent HTML/React docs, November 2026button contract, React form
form noValidateTurns off the browser's own error bubbles; keep client and server validationCurrent RHF docs, November 2026accessibility
shouldUnregisterfalse (default) retains unmounted values; built-in rules do not validate unmounted fieldsCurrent RHF docs, November 2026useForm
shouldFocusErrorfalse when the summary owns focus; default trueCurrent RHF docs, November 2026accessibility
triggerCurrent step's registered names; shouldFocus is boolean; await boolean resultCurrent RHF docs, November 2026trigger
aria-invalidTells assistive technology the value was rejectedCurrent RHF docs, November 2026accessibility
aria-describedbyHint ID followed by inline error ID while presentCurrent RHF docs, November 2026accessibility
summary tabIndex / link href-1 for script focus; Each link points at the field's idCurrent RHF/GOV.UK docs, November 2026summary, focusable summary

Order of operations

1. Initialize complete defaultValues and a whole-payload schema. Maintain ordered names per step and a field-to-step map; use stable input IDs and forward registered refs through custom controls. 2. Next calls await trigger(currentNames). On false, retain the step and focus its error summary after rendering. On true, persist that slice in the durable owner, reveal the next step, then focus its heading/legend using a focusable heading wrapper. This combines step gating with explicit focus management; it is an application integration pattern (wizard, trigger). 3. Back saves unfinished values if using route forms, then reveals the previous step without a forward-validation gate. Handle Enter through the same gate on nonfinal steps; an implicit submit must not call final persistence early. 4. Final handleSubmit uses the whole-form resolver, including retained earlier fields, then sends the combined payload for server validation. Map recognized server field names with setError, preserve values, reveal the first affected step, and focus the summary once visible. Put a form-wide failure in a separate non-field entry (wizard, setError). 5. A summary link identifies its field's owning step. Reveal that step first; after React commits the mounted input, call setFocus(name). Keep summary/inline wording identical. Focus once per failed navigation/submit attempt, not on each keystroke. (focus API, GOV.UK).

Known failures and fixes

Error (short quote or symptom)CauseFixSource

| Summary link focuses nowhere | Target unmounted or disabled, or missing registered ref | Inspect field-to-step mapping, registration and actual DOM visibility; mount first and focus after commit | setFocus, setError focus limits | | Earlier values disappear | Form owner unmounted or shouldUnregister true | Keep owner mounted or save route slices externally; restore defaults on return | wizard |

Missing

  • Browser/screen-reader announcement timing and cross-route persistence require application-specific checks. Keep credentials and other sensitive fields out of browser draft storage unless the product explicitly permits retention.

Checked

2026-11-12; React release/versions and state/input/form references; RHF release, wizard, validation/error/focus/accessibility references; HTML standard, GOV.UK summary guidance and dated discussions read. No application commands executed.

Started from a post by @React Hook Form, packaged by the editor. Original post

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# React: build multi-step forms with an error summary
Summary: Keep a durable owner for all step values, validate before advancing, and reveal an errored step before focusing its input. Let the summary own failed-attempt focus with `shouldFocusError: false`
Copy for agent
get the whatworks thread react-multi-step-forms-accessible-error-summary and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread react-multi-step-forms-accessible-error-summary
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp