Problem/Motivation
- The relationship of toolbar buttons to their trays is not conveyed to assistive technology.
The Toolbar previously attempted to convey this using
aria-owns, but it was discovered that his usage was incorrect in this issue: #3066954: Admin toolbar not usable with latest versions of JAWS due to mis-use of aria-owns, andaria-ownswas removed in order to address a bug impacting screenreader users. The correct ARIA relationship attributes need to be implemented. -
The toolbar buttons incorrectly use
aria-pressed. The correct dynamic ARIA state for a disclosure control isaria-expanded. - A major benefit of using
aria-expandedis that the open/close behaviour is conveyed by assistive tech before the user operates the button, using standardized terms from the operating system and/or assistive tech. Currently the open/close behaviour is only conveyed after pressing the button, using a customDrupal.announce()message, in terms localized by Drupal. Usingaria-expandedcorrectly means we no longer needDrupal.announcehere. - When JavaScript is disabled, the elements still present to assistive tech as buttons and may also be announced with pressed / expanded state.
Example from VoiceOver with JavaScript disabled. It should be announced as a link:

Steps to reproduce
Setup
- Install Drupal core with the standard install profile.
- Use a screen reader.
- Log in and go to a page which displays the toolbar.
Case 1: JavaScript enabled (disclosure pattern behavior)
-
Press the
tabkey until the "Manage" toolbar item has focus. -
Press
enterto open the menu. -
Press
enterto close the menu.
Expected vs Actual Results
Only tested with VoiceOver. Other readers may use different words / patterns.
| Action | Expected Results | Actual Results |
|---|---|---|
First tab to the "Manage" item
|
|
|
| Menu opened |
|
|
| Menu closed |
|
|
Case 2: JavaScript disabled (standard link behavior)
- Disable JavaScript and reload the page.
-
Press the
tabkey until the "Manage" toolbar item has focus.
Expected vs Actual Results
| Action | Expected Results | Actual Results |
|---|---|---|
First tab to the "Manage" item
|
Screen reader announces it as a link (possibly as "visited"). VoiceOver announces: "[visted,] link, Manage, Toolbar items, navigation". |
Screen reader announces it as a toggle button. VoiceOver announces: "Manage, toggle button, Toolbar items, navigation". |
Proposed resolution
- ✅ Remove the
aria-pressedattribute from the toolbar buttons which control trays. - ✅ Use
aria-expandedto convey current state of a given tray. This attribute should be on the same element which has the button role. - ✅ Remove the
Drupal.announce()message about the tray being opened. It's no longer necessary after adding thearia-expandedproperty to the button. - ✅ Remove all "faux button" aspects (
aria-expanded,role) from the initial rendering and add them by progressive enhancement with JavaScript.
Scope:
This issue is just about the behaviour and semantics of the buttons in the top-level toolbar, which control the visibility of the second-level trays. The behaviour of sub-menus under "Manage" when the toolbar tray is in vertical alignment has a separate issue: #3093378: Use ARIA disclosure pattern for submenu buttons in vertical toolbar orientation.
Changes to the full-color and forced-colors designs when aria-role="button" is present are better addressed in separate issues such as #3097905: Add visual indicator to show which toolbar buttons have trays associated with them and #3269420: Toolbar icons may not meet contrast when in forced colors mode.
Remaining tasks
User interface changes
- Improved semantics for assistive technology.
- No changes to visual design or behaviour.
API changes
Data model changes
None.
Release notes snippet
Reference
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3090120-14-no-javascript-current-markup.png | 86.33 KB | kentr |
Issue fork drupal-3090120
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
andrewmacpherson commentedAdding this to the parent plan for improving toolbar accessibility. This improvement was already listed there, but it didn't have it's own issue until now. Thanks for filing this @bnjmnm.
There's another benefit to using
aria-expanded: we can ditch one of theDrupal.announce()calls, because it's conveyed programmatically in the a11y tree for the button itself. There is widespread support for this in browsers and AT.Comment #4
andrewmacpherson commentedThis would be a good one to work on at the Drupal Accessibility Bug Bash duing DrupalCon Global 2020.
Comment #5
andrewmacpherson commentedComment #12
benjifisherOddly, this issue does not show up when I search for "aria-expanded". Maybe that is because it appears inside a
codetag.If so, then it should show up now in the search.
Update: another theory is that "aria-expanded" gets tokenized as two words. I can find this issue by searching for "aria expanded".
Comment #13
kentr commentedWhen Javascript is disabled and those items behave as links, they still have
role="button"and (currently)aria-pressed="false".In this case, they may be wrongly announced to AT as buttons instead of as links. Attached a screencast of this in VoiceOver.
Based on a Slack discussion with @cwilcox808, I suggest:
aria-role,aria-expanded,aria-controls, etc).aria-role="button"that will style these as buttons instead of links when the progressive-enhancement has happened (both for full-color andforced-colorscases).@cwilcox808 said this about the full-color styling and
aria-controls:@cwilcox808 said this RE
forced-colorsstyling for the "pressed" state of the buttons:Comment #14
kentr commentedRemoved Global2020 because it's outdated.
Added SC 4.1.2 because this issue is related to the role and state of UI components and the notification of changes to assistive technologies.
Added progressive enhancement for all "faux button" properties to the Proposed resolution and changed to Bug report because it's a failure of SC 4.1.2 when javascript is disabled.
Added
forced-colorsCSS to Proposed resolution because it's probably just a color change, but left out the suggestion of changing the full-color styling to present as buttons because that's a bigger design change and should apply to all buttons in the toolbar. #3097905: Add visual indicator to show which toolbar buttons have trays associated with them is probably a good place to address that because it already requires related design.Comment #15
kentr commentedForgot to add SC 4.1.2.
Also adding Needs change record because of the UI / UX changes.
Comment #17
kentr commentedBased on @cwilcox808's comments and another related Slack discussion, I'm moving
aria-controlsto a separate issue.I'm moving the suggestion for
forced-colorsproper button coloring to another issue because it's pretty involved after all.Comment #18
kentr commentedActually, needs better STR.
Comment #19
kentr commentedAdded STR
Comment #20
kentr commentedComment #21
smustgrave commentedFor the UI changes can we get before/after screenshots added to the IS please, helps the review. Also possible to get one of the accessibility maintainers to sign off on it.