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 and va-radio-option: Improved a11y #1442

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Andrew565
Copy link
Contributor

@Andrew565 Andrew565 commented Dec 19, 2024

Chromatic

https://3363-redo-radios-and-checks--65a6e2ed2314f7b8f98609d8.chromatic.com


Description

Closes #3363

Reworks some of the HTML for the va-checkbox and va-radio-option components to be more accessible.

QA Checklist

  • Component maintains 1:1 parity with design mocks
  • Text is consistent with what's been provided in the mocks
  • Component behaves as expected across breakpoints
  • Accessibility expert has signed off on code changes (if applicable. If not applicable provide reason why)
  • Designer has signed off on changes (if applicable. If not applicable provide reason why)
  • Tab order and focus state work as expected
  • Changes have been tested against screen readers (if applicable. If not applicable provide reason why)
  • New components are covered by e2e tests; updates to existing components are covered by existing test suite
  • Changes have been tested in vets-website using Verdaccio (if applicable. If not applicable provide reason why)

Screenshots

Before:
Screenshot 2024-12-18 at 10 51 13 AM
After:
Screenshot 2024-12-18 at 10 51 25 AM

Acceptance criteria

  • QA checklist has been completed
  • Screenshots have been attached that cover desktop and mobile screens

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)

@Andrew565 Andrew565 added the patch Patch change in semantic versioning label Dec 19, 2024
@Andrew565 Andrew565 requested review from rsmithadhoc and a team December 19, 2024 16:38
@Andrew565 Andrew565 self-assigned this Dec 19, 2024
@Andrew565 Andrew565 requested a review from a team as a code owner December 19, 2024 16:38
@babsdenney
Copy link

babsdenney commented Dec 19, 2024

@Andrew565 Could we fix the box size and radius to align with the USWDS? Attached shows the USWDS with a 20x20 square size and border radius of 2px.
image

The focus state in the Figma design has a gap between the focus state and the gold outline, USWDS is showing the same thing. Could we follow that design for the focus state. The USWDS also shows a gap.

Checkbox in this PR
image
VADS
image
USWDS
image

Copy link
Contributor

@rsmithadhoc rsmithadhoc left a comment

Choose a reason for hiding this comment

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

@Andrew565 This looked good to me. I was able to confirm that this resolves the Axe issues. I also gave it a quick test in VoiceOver and everything sounded as expected.

One minor thing I saw was when initially tabbing to the radio group, there's an additional outline next to the first item. My guess is that a stray pseudo or hidden element might be getting styled.
image

@babsdenney
Copy link

Similar to the checkboxes, could we increase the size of the radio button to match the USWDS?

  • Increase the size from 16x16 to 20x20
  • Create a gap between the focus ring and the radio circle

VADS
image

USWDS
image

@Andrew565
Copy link
Contributor Author

@rsmithadhoc Fixed the ghost outline, thanks for pointing that out.

@babsdenney I fixed the outline gaps and made sure the sizing was consistent for both radios and checkboxes. If you inspect a non-checked checkbox or radio, it will appear in the sizing model as though it's 16x16, but this isn't including the 2px border on all sides, which raises the 'total size' to 20x20. Screenshots attached.

Screenshot 2024-12-20 at 4 18 56 PM
Screenshot 2024-12-20 at 4 25 21 PM
Screenshot 2024-12-20 at 4 25 34 PM

@babsdenney
Copy link

@Andrew565 That makes sense! I don't know where the sizing strays, I overlayed the USWDS elements with the VADS and you can still see that the VADS radio buttons and checkboxes are slightly smaller. It looks like the selected radio button is accurate and matches the USWDS but the selected checkbox state and unselected radio and checkbox states are smaller than USWDS.

checkbox and radio

I also am not sure if this makes a difference but the click area for the USWDS checkboxes and radio buttons is larger than the VADS checkboxes. You can click farther to the right on the UWDS elements.

This doesn't make a difference, so it is not necessary to change, but the example we use for the name is misspelled in the storybook for the radio buttons.
image

@Andrew565
Copy link
Contributor Author

@babsdenney Figured out that the USWDS components were 20x20 PLUS a 2px box-shadow, making them effectively 24x24, which is why the size discrepancy. Fixed this for the checkboxes and radio-options, and also fixed the "Soujourner" typo. Should be good for re-review again now.

});
return (
<div class="usa-radio">
Copy link
Contributor

@jamigibbs jamigibbs Jan 7, 2025

Choose a reason for hiding this comment

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

It looks like this update will require us to diverge almost completely from the USWDS packages with these classes being removed:

  • usa-radio__input
  • usa-radio

There are similar USWDS classes for va-checkbox too.

Is it possible to keep some USWDS style for padding/margin, spacing, font-size, border-radius by keeping those USWDS classes there and just override whatever we need to override in the component stylesheet? Otherwise we will no longer be receiving any of those upstream updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, the usa-radio class is still there, it's just moving to the containerClass variable.

As for the rest of the classes that are changing, yes, they are diverging quite a bit from the original USWDS classes, which is why I felt it made sense to replace those classes wholesale rather than try and override them.

For the usa-radio__input vs. va-radio-option__input, as an example, in our old stylesheet we were overriding just the margin and position, the USWDS doesn't provide any other styles beyond those. In the new stylesheet, we're overriding the margin, position, height, width, border, and box-shadow properties.

In the old styles and layout, the radio button and checkbox "icons" were being generated on the labels using a ::before pseudo-element. In the new styles and layout, we're generating those "icons" on the inputs themselves.

Getting the 'tile' variant to display correctly likewise required moving the styles to the div container, rather than having them live with the label element, due to the label not encompassing the input element.

So we aren't really getting anything useful from USWDS for these elements any more, so I don't see us needing to receive any upstream updates, unless USWDS completely restructures these components in a way similar to how we've done it.

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.

Fix incorrect markup on radio buttons and checkbox components to support accessibility
4 participants