Skip to content

feat(react-core): summarize form validation errors under the submit button - #1831

Merged
joshunrau merged 2 commits into
mainfrom
feat/form-error-summary
Oct 28, 2026
Merged

joshunrau merged 2 commits into
mainfrom
feat/form-error-summary

Conversation

@thomasbeaudry

@thomasbeaudry thomasbeaudry commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

What

When a form instrument is submitted with missing or invalid answers:

  • A red notice appears under the submit button: "Some fields are incomplete or invalid. Please resolve the errors above before continuing." (en/es/fr).
  • The page scrolls the first invalid field (in render order) to the centre of the viewport and focuses its first control. Before this, a failed submit left the page wherever the layout shift put it.

The per-field error messages are unchanged.

FormContent tracks libui Form's onError and clears the notice on a successful submit. It finds the field through libui's data-field-group wrapper and error-message-text markers. Both in-app assessments (apps/web) and remote assignments (apps/gateway) render forms through FormContent, so both get it.

Verification

  • Unit: packages/react-core/src/components/FormContent/__tests__/FormContent.test.tsx: 13/13 pass. They cover the notice (absent before submit, shown on failure, cleared after a corrected submit), focus on the first invalid field, and no scroll when the only error is form-level. FormContent.tsx is at 100% coverage.
  • E2E: new testing/src/specs/form-error-summary.spec.ts covers an in-app session: notice visible, first invalid field in the viewport and focused. testing/src/specs/gateway-assignment.spec.ts asserts the notice on a remote assignment's empty submit.
  • pnpm --filter @opendatacapture/react-core lint and pnpm --filter @opendatacapture/testing lint pass.
  • Manually tested in a local instance.
  • Exception: Playwright was not run locally because a dev API server was bound to port 5599. CI is the first e2e run. The full pnpm test:coverage was not run either.

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

…utton

When a form instrument fails validation on submit, show a red notice under the
submit button telling the user that fields are incomplete or invalid and must
be resolved before continuing. Per-field messages are unchanged. Applies to
in-app assessments and gateway remote assignments alike, since both render
through FormContent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A failed submit left the page wherever the layout shift put it. Scroll the
first field carrying an error, in render order, to the centre of the viewport
and focus its first control.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@joshunrau
joshunrau merged commit f6e12ec into main Oct 28, 2026
6 checks passed
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.

2 participants