fix(theme-default): code group accessibility #1445
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before submitting the PR, please make sure you do the following
close #123
).What is the purpose of this pull request?
Description
While doing some accessibility testing on my site written in the RC release of Vuepress 2 I came across some accessibility issues with the code group and code group item components.
I have been testing with the latest version of the axe chrome extension.
It reported on the code block item component that
Elements must only use supported ARIA attributes
.https://dequeuniversity.com/rules/axe/4.8/aria-allowed-attr?application=AxeChrome
The code group item component renders the
aria-selected
attribute which should only be on elements with the rolesgridcell
,cell
,row
, ortab
.Looking through the MDN documentation at ARIA attributes and tab roles the code group item should actually have the
tabpanel
role and the button to select the tab should have thetab
role.The changes in this PR were modeled after the example on MDN. Also, since the roles have requirements of being direct parent/child of each other I removed the wrapping
ul
andli
elements and only had to slightly alter the CSS to keep the same visual result.I also added a few color variables for some hard coded colors while I was in there.
Screenshots
Before
After
Other Accessibility Issues
The only other accessibility I came across was that all of the heading anchors have
aria-hidden
attributes but are still focusable via keyboard navigation. There was a bit of discussion around this already in themarkdown-it-anchor
repo and you can address this by just using theheaderLink
render function instead of theariaHidden
render function since it wraps the entire header in an anchor. I applied this change in my site config directly but I am happy to create a PR to make that the default behavior if that is desired.