Problem/Motivation

  1. 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, and aria-owns was removed in order to address a bug impacting screenreader users. The correct ARIA relationship attributes need to be implemented.

  2. The toolbar buttons incorrectly use aria-pressed. The correct dynamic ARIA state for a disclosure control is aria-expanded.
  3. A major benefit of using aria-expanded is 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 custom Drupal.announce() message, in terms localized by Drupal. Using aria-expanded correctly means we no longer need Drupal.announce here.
  4. 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:

    Screenshot when javascript is disabled of "manage" link, using current markup. aria role is incorrect.

Steps to reproduce

Setup
  1. Install Drupal core with the standard install profile.
  2. Use a screen reader.
  3. Log in and go to a page which displays the toolbar.
Case 1: JavaScript enabled (disclosure pattern behavior)
  1. Press the tab key until the "Manage" toolbar item has focus.
  2. Press enter to open the menu.
  3. Press enter to 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
  • Screen reader announces it as a show/hide button that is collapsed.

    VoiceOver announces: "Manage, collapsed, button, Toolbar items, navigation".
  • Screen reader announces it as a toggle button, and does not announce the collapsed state.

    VoiceOver announces: "Manage, toggle button, Toolbar items, navigation"
Menu opened
  • Screen reader announces that the item is expanded.

    VoiceOver announces: "Manage, expanded, button".

     
  • Screen reader does not announce "Tray 'Administration menu' opened".
  • Screen reader announces that the item is selected / toggled.

    VoiceOver announces: "selected, Manage, toggle button".

     
  • Screen reader announces "Tray 'Administration menu' opened".
Menu closed
  • Screen reader announces that the item is collapsed.

    VoiceOver announces: "Manage, collapsed, button"

     
  • Screen reader does not announce "Tray 'Administration menu' closed".
  • Screen reader does not announce the "collapsed" state.

    VoiceOver announces: "Manage, toggle button".

     
  • Screen reader announces  "Tray 'Administration menu' closed".
Case 2: JavaScript disabled (standard link behavior)
  1. Disable JavaScript and reload the page.
  2. Press the tab key 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

  1. ✅ Remove the aria-pressed attribute from the toolbar buttons which control trays.
  2. ✅ Use aria-expanded to convey current state of a given tray. This attribute should be on the same element which has the button role.
  3. ✅ Remove the Drupal.announce() message about the tray being opened. It's no longer necessary after adding the aria-expanded property to the button.
  4. ✅ 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

Issue fork drupal-3090120

Command icon 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

bnjmnm created an issue. See original summary.

andrewmacpherson’s picture

Title: ARIA implementation needed for Toolbar buttons and trays » Use ARIA disclosure pattern for Toolbar buttons with trays
Issue summary: View changes
Issue tags: +Accessibility, +aria
Parent issue: » #3084529: [META] improve accessibility of toolbar
Related issues: +#2893640: Modernize ARIA usage, in line with ARIA 1.1 and the ARIA Authoring Practices guide.

Adding 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 the Drupal.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.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andrewmacpherson’s picture

Issue summary: View changes
Issue tags: +JavaScript, +Global2020

This would be a good one to work on at the Drupal Accessibility Bug Bash duing DrupalCon Global 2020.

andrewmacpherson’s picture

Issue tags: +Bug Smash Initiative

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

benjifisher’s picture

Issue tags: -JavaScript +JavaScript

Oddly, this issue does not show up when I search for "aria-expanded". Maybe that is because it appears inside a code tag.

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".

kentr’s picture

StatusFileSize
new121.86 KB

When 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:

  1. Rendering these items as plain links without any HTML button properties (aria-role, aria-expanded, aria-controls, etc).
  2. Adding those button properties in Javascript as part of the progressive-enhancement.
  3. Adding CSS based on aria-role="button" that will style these as buttons instead of links when the progressive-enhancement has happened (both for full-color and forced-colors cases).

@cwilcox808 said this about the full-color styling and aria-controls:

I think that's a good idea independent of the forced-colors state, something like:

.toolbar a[role="button"] {
  text-decoration: none;
}

Instead of .toolbar .toolbar-item including text-decoration: none.

That does open up the use of adding the underline on :hover and :focus. I really like strongly associating underlines with links (behaving as links) so I'd like to see something else used when they have [role="button"]. Without JS, the line thickness could be changed, e.g.

.toolbar a[href]:not([role="button"]):is(:focus, :hover) {
  text-decoration-thickness: 0.1875em;
}

Note that only a single assistive technology, JAWS, makes use of aria-controls so it's not very useful. The better practice is to instead have the associated element immediately follow the control so users don't have to navigate through other content from the control.

@cwilcox808 said this RE forced-colors styling for the "pressed" state of the buttons:

For aria-pressed="true", you could maybe set border-color: Highlight;, buttons in that state wouldn't have a visual change on hover but focused buttons would still have the addition of the outline.

kentr’s picture

Category: Task » Bug report
Issue summary: View changes
Issue tags: -Global2020
StatusFileSize
new86.33 KB

Removed 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-colors CSS 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.

kentr’s picture

Issue tags: +wcag412, +Needs change record

Forgot to add SC 4.1.2.

Also adding Needs change record because of the UI / UX changes.

kentr’s picture

Title: Use ARIA disclosure pattern for Toolbar buttons with trays » Improve accessibility semantics for Toolbar buttons with trays
Issue summary: View changes
Status: Active » Needs review

Based on @cwilcox808's comments and another related Slack discussion, I'm moving aria-controls to a separate issue.

I'm moving the suggestion for forced-colors proper button coloring to another issue because it's pretty involved after all.

kentr’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Actually, needs better STR.

kentr’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Added STR

kentr’s picture

Issue summary: View changes
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs screenshots, +Needs accessibility review

For 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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.