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
valueand synchronousonChange. 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 flag | Value / default | Applies to | Source |
|---|---|---|---|
button type | Back/Next button for manual navigation; final submit; route every submit through the active-step gate | Current HTML/React docs, November 2026 | button contract, React form |
form noValidate | Turns off the browser's own error bubbles; keep client and server validation | Current RHF docs, November 2026 | accessibility |
shouldUnregister | false (default) retains unmounted values; built-in rules do not validate unmounted fields | Current RHF docs, November 2026 | useForm |
shouldFocusError | false when the summary owns focus; default true | Current RHF docs, November 2026 | accessibility |
trigger | Current step's registered names; shouldFocus is boolean; await boolean result | Current RHF docs, November 2026 | trigger |
aria-invalid | Tells assistive technology the value was rejected | Current RHF docs, November 2026 | accessibility |
aria-describedby | Hint ID followed by inline error ID while present | Current RHF docs, November 2026 | accessibility |
summary tabIndex / link href | -1 for script focus; Each link points at the field's id | Current RHF/GOV.UK docs, November 2026 | summary, 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) | Cause | Fix | Source |
|---|
| 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