Skip to content

USWDS - Validation: Adds complete/incomplete labels for screen readers. Resolves #4477#4719

Merged
thisisdano merged 16 commits into
developfrom
cm-validation-a11y
Jul 29, 2022
Merged

USWDS - Validation: Adds complete/incomplete labels for screen readers. Resolves #4477#4719
thisisdano merged 16 commits into
developfrom
cm-validation-a11y

Conversation

@mahoneycm

@mahoneycm mahoneycm commented May 26, 2022

Copy link
Copy Markdown
Contributor

Preview

Validation →

Description

Upon initialization, a new span is created for validation checklist items with the usa-sr-only class and a data-checklist-label=hidden data attribute. By default the span is set to "Incomplete"

When the validator updates the items to "checked", it will change the text content to Complete or Incomplete as necessary.

Resolves #4477

Additional information

This PR also changes the validation event listener from keyup change to input change so that keys like shift wouldn't trigger the function

Before you hit Submit, make sure you’ve done whichever of these applies to you:

  • Follow the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run npm test and make sure the tests for the files you have changed have passed.
  • Run your code through HTML_CodeSniffer and make sure it’s error free.
  • Title your pull request using this format: [Website] - [UI component]: Brief statement describing what this pull request solves.

Charlie Mahoney and others added 11 commits May 9, 2022 15:50
- Changes affect screen readers only
- packages/usa-validation/src/index.js now adds hidden "incomplete" span on initialization
- validate-input.js targets hidden data attribute for list items and sets complete/incomplete labels as necessary.
Updates the validation component's unit test and JS. The new hidden span
is created by traversing the parent of validation input until it finds the
checklist.

Previously it looked for the first validation checklist, which causes problems
when the component init's outside of document.body

- Replace `select` with `selectOrMatches` to get proper elem context
- Create constants for validation input and checklist item
- Create function for hidden label span
@mahoneycm mahoneycm requested a review from mejiaj June 13, 2022 17:10
@mahoneycm mahoneycm marked this pull request as ready for review June 13, 2022 17:11

@mejiaj mejiaj 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.

Nice work! Just a few changes.

Can we remove the usa-checklist__item--checked from usa-validation.twig:8 so it shows the correct initial state?

Comment thread packages/usa-validation/src/index.js Outdated
Comment thread packages/usa-validation/src/index.js Outdated
Comment thread packages/usa-validation/src/index.js
- Adds aria-controls to validation inputs
- Moves aria-live and aria-atomic to parent list instead of list items
- Sets aria-checked=false by default on initialization
@mahoneycm mahoneycm requested a review from mejiaj June 13, 2022 20:42
@mejiaj

mejiaj commented Jun 17, 2022

Copy link
Copy Markdown
Contributor

Placing hold so we can get additional a11y testing and feedback.

@brunerae

brunerae commented Jul 5, 2022

Copy link
Copy Markdown
Contributor

@thisisdano this is ready for final review!

Comment thread packages/usa-validation/src/test/template.html Outdated

@thisisdano thisisdano 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.

@thisisdano thisisdano merged commit 0b0e03f into develop Jul 29, 2022
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.

Validation: Add Aria-Label for Checked/Not Checked (508)

4 participants