-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gatsby-remark-autolink-headers): improve accessibility of generat…
…ed links (#11635) ## Description The plugin for auto-linking Markdown headers is super slick, but it had some accessibility issues. Specifically: - With `icon` being truthy, the plugin introduces an anchor tag wrapping an SVG icon inside of the heading. - The link receives `aria-hidden="true"` but isn't disabled from the keyboard with `tabindex="-1"`, so it effectively becomes a "ghost control" in screen readers since the accessibility information is stripped out. Instead of hiding them, this PR makes those links keyboard and screen reader accessible so they can be used by more people. - Added an `aria-label` to the link using a version of the header slug with spaces instead of dashes and the word "permalink" at the end making it clear what these links are for. - Added `focusable: false` to the default SVG so it won't receive focus in some assistive technologies (since it's not supposed to be interactive). ## To-do I could use some help with the tests, if we want some test coverage for this. There wasn't any precedent for testing the links, only header IDs and icon children.
- Loading branch information
1 parent
1d44f95
commit 2059424
Showing
2 changed files
with
14 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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