Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

va-checkbox | Add description id to aria-describedby #817

Merged
merged 5 commits into from
Aug 29, 2023

Conversation

Mottie
Copy link
Contributor

@Mottie Mottie commented Aug 25, 2023

Chromatic

https://56080-checkbox-description--60f9b557105290003b387cd5.chromatic.com

Description

See #56080

Our Supplemental Claim form has a large amount of legal text (8 paragraphs plus a bullet list) which would not work because the message-aria-describedby only accepts strings. So we moved the wall of content inside the description slot, but the screen reader still won't read out the content, so this PR adds a description ID to the input's aria-describedby inside the shadow DOM. It was tested and the screen reader does read out the slotted content (see screenshot)

Additionally, the error-message ID on the span was changed to checkbox-error-message so that the USWDS and original checkbox code better matches. This doesn't look like it will make any tests in vets-website fail because React-Testing Library doesn't support shadow DOM and appears to only check the outer error attribute, and looking through Cypress E2E tests reveals label checks more than anything else.

Testing done

Updated tests to check aria-describedby IDs

Screenshots

va-checkbox with Voiceover window showing the checkbox label and description being read out

Acceptance criteria

  • Descriptions read out by screen reader
  • Error message ID consistency
  • All tests passing

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

@Mottie Mottie added the patch Patch change in semantic versioning label Aug 25, 2023
@Mottie Mottie requested a review from a team as a code owner August 25, 2023 20:35
@Mottie Mottie self-assigned this Aug 25, 2023
const ariaDescribedbyIds = [
messageAriaDescribedby ? 'input-message' : '',
error ? 'checkbox-error-message' : '',
hasDescription ? 'description' : '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Would there ever be a scenario when we wouldn't want the description content associated with aria-describedby?

Copy link
Contributor Author

@Mottie Mottie Aug 28, 2023

Choose a reason for hiding this comment

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

I think if no description is provided? We don't want to add IDs if they don't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see what you're saying... Monday was really cray-cray for me. I can't think of any scenario like that. If it ever came up, we could modify the code to accommodate the need.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I think that's a fine strategy. I see the description slot being used in a couple of different places already though so just mentioning that here for awareness.

Screenshot 2023-08-29 at 8 48 41 AM

@Mottie Mottie merged commit 4c97574 into main Aug 29, 2023
5 checks passed
@Mottie Mottie deleted the 56080-checkbox-description branch August 29, 2023 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Patch change in semantic versioning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants