Repository navigation
feat(react-core): summarize form validation errors under the submit button - #1831
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a form instrument is submitted with missing or invalid answers:
The per-field error messages are unchanged.
FormContenttracks libuiForm'sonErrorand clears the notice on a successful submit. It finds the field through libui'sdata-field-groupwrapper anderror-message-textmarkers. Both in-app assessments (apps/web) and remote assignments (apps/gateway) render forms throughFormContent, so both get it.Verification
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.tsxis at 100% coverage.testing/src/specs/form-error-summary.spec.tscovers an in-app session: notice visible, first invalid field in the viewport and focused.testing/src/specs/gateway-assignment.spec.tsasserts the notice on a remote assignment's empty submit.pnpm --filter @opendatacapture/react-core lintandpnpm --filter @opendatacapture/testing lintpass.pnpm test:coveragewas not run either.Co-Authored-By: Claude Opus 5.5 [email protected]