Problem/Motivation
- When the admin toolbar is collapsed, the icon links labels don’t get read aloud to screen reader users.
- This is because CSS is used to hide them with
display: none; which is not the correct technique.
- Per Drupal’s documentation Hide Content Properly, the CSS class
.visually-hidden should be used instead.
WCAG success criteria
2.4.4 Link Purpose (In Context)
4.1.2 Name, Role, Value
Steps to reproduce
- Login as admin. Navigate to /admin/structure/block. Chrome browser, desktop. Collapse the sidebar.
- Verify the problem exists with an automated accessibility checker.
- Run SiteImprove accessibility checker (Chrome browser extension).
- “Link without a text alternative” should be one of the issues it reports.
- Verify the problem exists manually.
- Inspect with Chrome Dev Tools.
- Find the tags that are associated with the toolbar icons (listed below under Code Snippet).
Code snippet
HTML
<a href="/en/admin/appearance" class="toolbar-link toolbar-link--has-icon toolbar-link--appearance">
<span>Appearance</span>
</a>
CSS
html:not([data-admin-toolbar="expanded"]) .toolbar-menu__item--level-1:not(.toolbar-menu__item--has-dropdown) .toolbar-link span {
display: none;
}
Paths:
/en/admin/appearance
/en/admin/modules
/en/admin/people
/en/admin/content
/en/admin/content/block
/admin/content/files
/admin/content/media
/admin/help
Potential resolution
- In mobile only, add .visually-hidden CSS class to the link text so that it’s hidden to sighted users but available to screen reader users
Note: This will need additional CSS and/or JS to toggle between mobile and desktop
- Add aria-label attribute with meaningful value to each linked icon
Note: See: https://www.w3.org/WAI/WCAG21/Understanding/link-purpose-in-context.html#techniques
- Remove
display: none; from the following selector
HTML
<a href="/en/admin/appearance" class="toolbar-link toolbar-link--has-icon toolbar-link--appearance">
<span class=”visually-hidden”>Appearance</span>
</a>
CSS
html:not([data-admin-toolbar="expanded"]) .toolbar-menu__item--level-1:not(.toolbar-menu__item--has-dropdown) .toolbar-link span {}
Comments
Comment #4
ckrinaComment #5
ckrinaComment #6
claireristow commentedWorking on this now
Comment #8
claireristow commentedThis is ready for review!
Noting that I didn't follow the proposed resolution in the issue description exactly because I was seeing the accessibility error on all screen sizes. I believe this css solution is sufficient but please let me know if that's not the case.
Comment #9
finnsky commentedLGTM! Thank you!
Comment #10
claireristow commentedMerged!