fix(a11y): set aria-expanded on sidebar links that toggle a sub-sidebar - #2809
Open
gagan-baghel wants to merge 1 commit into
Open
gagan-baghel wants to merge 1 commit into
gagan-baghel wants to merge 1 commit into
Conversation
The active page link collapses and expands its sub-sidebar when it is activated, but it exposed no expanded state, so screen readers could not announce it. Set aria-expanded when the sub-sidebar is rendered and update it whenever the link toggles the sub-sidebar.
|
@gagan-baghel is attempting to deploy a commit to the Docsify Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The active sidebar page link expands and collapses its sub-sidebar (the list of the page's headings) when it is activated, but it has no
aria-expandedstate, so it is exposed to assistive technology as a plain link with no expanded or collapsed state.This sets
aria-expanded="true"on the active link when its sub-sidebar is rendered, and updates the value whenever the link toggles the sub-sidebar, the same way the collapsible group titles already do. Links without a sub-sidebar (pages that are not active, or pages without headings) get noaria-expanded, since activating them only navigates.Before/after, checked on the docs site served locally (
node server --dev) on the Quick start page:aria-expandedattribute, before or after pressing Enter on it, and Chrome's accessibility tree reports it aslink "Quick start".aria-expandedistrue, becomesfalsewhen Enter collapses the list, andtrueagain on the next Enter. Chrome's accessibility tree reports the link aslink "Quick start" [expanded].Verification:
npm run lint,npm run typecheck,npm run test:unit,npm run test:integrationandnpm run test:consume-typespass.test/e2e/sidebar.test.jsfails without the change.Related issue, if any:
Closes #2615
What kind of change does this PR introduce?
For any code change,
Does this PR introduce a breaking change?
Tested in the following browsers: