Repository navigation
feat(components): accessible Field primitive + server-error mapping (#75) - #112
Merged
joelpeace48-cell merged 1 commit intoAug 30, 2026
Merged
Conversation
…inesseStudioLab#75) First slice of the shared form primitives: - components/forms/field.tsx: labelled Field wrapper with fieldAria() helper that wires aria-describedby (hint + error) and aria-invalid onto the control, so every form associates them identically. - lib/forms/server-errors.ts: mapServerErrors() maps backend validation errors (zod errors[] list or flat fieldErrors map) onto known fields, routing unmatched messages to a single form-level fallback rather than dropping them. Input, Select, Textarea, FileUpload and the shared-zod-schema validation build on these (the schema sharing depends on the shared schema package). Refs FinesseStudioLab#75
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.
Description
First slice of the shared form primitives (issue #75). No new deps.
components/forms/field.tsx— accessibleFieldwrapper: labelled viahtmlFor, with afieldAria(id, {hasHint, hasError})helper that returns the exactaria-describedby(hint + error ids) andaria-invalida control should spread onto itself, so every form associates them identically. Error renders withrole="alert".lib/forms/server-errors.ts—mapServerErrors(body, knownFields)maps a backend error body (zod-styleerrors: [{path, message}]list or a flatfieldErrorsmap) onto known fields; unmatched messages go to a singleformLevelfallback rather than being dropped or rendered as orphans.tests/unit/forms.test.tsx— a11y association assertions + server-error mapping cases (7 tests).Follow-up (same issue)
Input/Select/Textarea/FileUploadprimitives, the full lifecycle state (pristine → submitting → error/success, double-submit lock), input preservation on failure, and client validation sharing the backend zod schemas (blocked on the shared schema package).Testing
npm test(7 new tests pass),next lintclean locally.Closes #75