Skip to content

fix: Improve form error feedback accessibility#1120

Closed
web3blind wants to merge 2 commits into
Vets-Who-Code:masterfrom
web3blind:fix-accessible-form-error-feedback
Closed

fix: Improve form error feedback accessibility#1120
web3blind wants to merge 2 commits into
Vets-Who-Code:masterfrom
web3blind:fix-accessible-form-error-feedback

Conversation

@web3blind

Copy link
Copy Markdown

Summary

  • Add accessible IDs to shared form feedback messages.
  • Mark error feedback as role="alert" so screen readers announce validation errors.
  • Connect invalid inputs and textareas to their error text with aria-describedby and aria-invalid.
  • Add focused tests for the shared Input and Textarea components.

Accessibility impact

This improves the shared form components used across application forms. When a field has validation feedback, assistive technology can now identify the field as invalid and read the matching error message.

Relates to #895.

Validation

  • npm test -- src/components/ui/form-elements/__tests__/accessible-feedback.test.tsx — passed
  • npx biome check src/components/ui/form-elements/__tests__/accessible-feedback.test.tsx src/components/ui/form-elements/feedback.tsx src/components/ui/form-elements/input.tsx src/components/ui/form-elements/textarea.tsx src/components/ui/form-elements/types.ts — passed with existing complexity warnings in input.tsx and textarea.tsx
  • npm run typecheck — blocked by pre-existing unrelated test typing errors in __tests__/lib/j0di3 and __tests__/pages/api/j0di3

@vercel

vercel Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

@web3blind is attempting to deploy a commit to the vetswhocode-web-app Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves accessibility of shared form elements by ensuring validation errors are programmatically associated with their corresponding inputs/textareas and announced by assistive technology.

Changes:

  • Add feedbackId support and generate stable error-message IDs for form elements.
  • Mark error feedback as role="alert" and wire aria-invalid / aria-describedby on Input and Textarea.
  • Add unit tests validating the default error ID/linking behavior for Input and Textarea.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/ui/form-elements/types.ts Adds a new feedbackId prop to shared input props to support stable error message IDs.
src/components/ui/form-elements/input.tsx Sets aria-invalid/aria-describedby and assigns an ID to the rendered error feedback.
src/components/ui/form-elements/textarea.tsx Mirrors Input accessibility wiring for textarea error feedback.
src/components/ui/form-elements/feedback.tsx Adds optional id and announces error feedback via role="alert".
src/components/ui/form-elements/__tests__/accessible-feedback.test.tsx Adds tests asserting default ${id}-error linkage and alert role behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 12 to 18
export interface IInputProps extends IFeedback {
className?: string;
disabled?: boolean;
readonly?: boolean;
feedbackText?: string;
feedbackId?: string;
id: string;
Comment on lines +5 to +23
describe("form element error feedback accessibility", () => {
it("connects input errors with aria-describedby and alert feedback", () => {
render(
<Input
id="email"
name="email"
state="error"
feedbackText="Enter a valid email address"
/>
);

const input = screen.getByRole("textbox");
const alert = screen.getByRole("alert");

expect(input).toHaveAttribute("aria-invalid", "true");
expect(input).toHaveAttribute("aria-describedby", "email-error");
expect(alert).toHaveAttribute("id", "email-error");
expect(alert).toHaveTextContent("Enter a valid email address");
});
@web3blind

Copy link
Copy Markdown
Author

Updated the PR to address the Copilot feedback around feedbackId:

  • scoped the custom feedback id prop to the text input/textarea components that implement it;
  • added regression coverage for custom feedback IDs.

Local validation:

  • npm test -- src/components/ui/form-elements/__tests__/accessible-feedback.test.tsx passed.
  • npm run typecheck still reports existing unrelated __tests__/lib/j0di3 / __tests__/pages/api/j0di3/* test typing errors.

Note: the Vercel status is still blocked by the existing Vercel team authorization gate, not by a build log from this change.

@web3blind web3blind closed this by deleting the head repository Jun 25, 2026
@web3blind

Copy link
Copy Markdown
Author

Withdrawing this stale accessibility PR as part of fork cleanup. Thanks for the consideration.

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