department-of-veterans-affairs / vets-design-system-documentation

Repository for design.va.gov website
https://design.va.gov
59 stars 65 forks source link

Fix incorrect markup on radio buttons and checkbox components to support accessibility #3363

Open laflannery opened 1 month ago

laflannery commented 1 month ago

Bug Report

What happened

When doing foundational testing, my team noticed that multiple axe errors were being flagged on the radio button component regarding ARIA attributes being used incorrectly - in this case the role and subsequently the aria-checked attributes are not allowed on a <label> tag: Image

This is also the case on the checkbox component, the same attributes are being used incorrectly here as well.

What I expected to happen

I would expect that no axe errors would be flagged for the component and that ARIA attributes would be used correctly.

However, after investigating the reason for adding the attributes and the various requirements, this was a complex issue and I wanted to propose a solution rather than just stating the issue.

I did some research and I may have a possible solution that is accessible and support voice control: This is the codepen I was working on. It currently just has the radio button example I was working on though I may work on a checkbox one as well.

I also was able to briefly change the component to my implemention and test, because I wanted to see how the shadow DOM might impact this. And while Voice Control did work, I am not able to test thoroughly. I still do feel that using the semantic elements (vs the current implementation with the axe errors) is a better option but I would recommend more testing of the component itself.

Urgency

How urgent is this request? Please select the appropriate option below and/or provide details

Details

While it's not blocking work, the current implementation has incorrect markup and is used quite often throughout the VA.gov site. It would be a great improvement to address this and to pass it along to USWDS

caw310 commented 1 month ago

Hey team! Please add your planning poker estimate with Zenhub @Andrew565 @ataker @harshil1793 @it-harrison @jamigibbs @micahchiang @powellkerry @rsmithadhoc

laflannery commented 1 week ago

@caw310 @coforma-jamie and I just discovered that the current markup (having the role on the <label>) is causing screen readers to think the number of elements - radio buttons an checkboxes - is duplicated. For example, if there is a question with 5 radio buttons, the screen reader will incorrectly announce "1 of 10" instead of "1 of 5". This will cause confusion for users as they will think they are missing half of the field options. Is there a way this ticket can be looked at sooner rather than later as it is impacting every where these fields are used?

coforma-jamie commented 1 week ago

@caw310, here's a clip of the "number of elements is duplicated" issue using JAWS.

This also happens using NVDA and TalkBack.