Problem/Motivation

The drop-button UI widget does not report the open/closed state to assistive tech like screen readers. The more-actions button has a good text alternative to let the user know what to expect, but after pressing it there is no confirmation about what happened.

Proposed resolution

Use ARIA states and properties to describe the dropbutton behaviour to assistive technology APIs.

  • Update dropbutton.js to report the open/closed state, using aria-expanded, together with aria-controls.
  • Possibly use the menu button pattern from the W3C ARIA Authoring Practices (APG)? Is it an appropriate match for our existing behaviour or markup? The existing drop button is keyboard accessible, but uses the TAB key to select the action. The W3C APG pattern encourages use of arrow keys to select the action. NO, this isn't appropriate for our existing uses of dropbutton. See #14.

Remaining tasks

  • Decide on the markup/DOM pattern. Does this require any markup changes? Would be great if we can implement this without changing any CSS selectors.
  • Write a patch
  • FunctionalJavascript tests - operate the more-actions button, and assert that the aria state attributes have changed.

User interface changes

Accessibility improvements, principally benefiting screen reader users.
No visual design changes.

API changes

None expected.

Data model changes

None expected.

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

Some interesting quirks in our dropbutton. These might make it a poor match for the W3C menu button pattern.

  • The more-actions button is INSIDE the list container which it controls! I have a feeling that this is an unusual pattern.
  • It's possible to drop off the end of it by tabbing. The W3C pattern examples use arrow keys to select an action, and loop around the first/last items.
  • Pressing escape does nothing in our dropbutton. The W3C pattern collapses the menu button.
  • The menu collapses automatically when focus is no longer inside it. This is only a minor point. So long as the aria-expanded state is up to date, I wouldn't expect any confusion when returning to it.

Update (3rd Feb 2021): Some of these aren't relevant to us. See comment #18 for explanation.

andrewmacpherson’s picture

Title: Dropbutton does not report open/closed state to assistive technology » Dropbutton should report open/closed state to assistive technology

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andrewmacpherson’s picture

Just found #2278473: Simplify Dropbutton markup in line with our CSS standards. The proposed new markup there would make it much easier to implement the Menu Button pattern from the WAI-ARIA Authoring Practices. In particular, the "more actions" button is NOT inside the list which it controls.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andrewmacpherson’s picture

I'm sure we should be using aria-expanded to convey the open/closed state, but I don't think aria-haspopup is appropriate for all instances of dropbutton.

Now aria-haspopup has a predefined list of roles which the pop-up can be (dialog, menu, etc). So if we say aria-haspopup="menu" (or even aria-haspopup="true"), then this implies that:

  • the associated pop-up has role="menu"
  • which in turn implies that it has descendants with role="menuitem"
  • which in turn means that the descendants CANNOT have a link role. role="menuitem" doesn't permit operable descendants.

The drop button is a general-purpose widget. It could be used for:

  • A list navigation links (e.g. Views UI has some links to view a standalone page display), or
  • "actions" (e.g. entity operations like edit, delete, etc.) Even though many of these are actually links to other pages, they could be described as actions for which role="menuitem" is appropriate.

So I don't think we can just put aria-haspopup="menu" on all instances of dropbutton, because we won't know for sure if the items are navigation links, or whether they are a good match for role="menuitem".

Possibly we could split the dropbutton into "NavigationDropButton" and "MenuDropButton", but that might lead to a lot of refactoring and maybe developer confusion too.

It doesn't help that web devs/designers routinely speak of "navigation menus" without distinguishing these.

Using aria-expanded (and aria-controls) without aria-haspopup is fine, and well supported.

skaught’s picture

re: use cases
I maintain the contrib module Dropdown Language that uses dropbutton in a non-admin circumstance. Please feel free to use to it overview related a11y issues.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). 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 tags: -JavaScript +JavaScript

Re. #11: That's great to know. Looking at the Dropdown Language module, the use case is clearly navigation to other pages.

That's highly relevant to the worries I have in comment #10. I've been reading more opinions around the accessibility community; I'm not alone in worrying about this. It's become a bit controversial as to whether the ARIA menubutton pattern (with menu and menuitem roles) is appropriate for site navigation. The main complaint is that "menuitem" overrides the "link" role, so it's potentially confusing because there's no prior warning that a new page will load.

This issue is overlapping with #2278473: Simplify Dropbutton markup in line with our CSS standards. I was thinking of closing this as a duplicate, but that issue is now proposing a new element, instead of updating dropbutton. Leaving this one open for now, because it's relevant to the current dropbutton.

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.

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.

andrewmacpherson’s picture

Issue summary: View changes

Updating the proposed resolution:

  • Deleting aria-haspopup, it's not appropriate, see #10
  • aria-controls has limited support; nonetheless, it works in the assistive tech which supports it. It is appropriate, per the ARIA recommendation for aria-expanded: "If the element with the aria-expanded attribute controls the expansion of another grouping container that is not 'owned by' the element, the author SHOULD reference the container by using the aria-controls attribute." Our button + list relationship matches this.
  • Striking the ARIA menu button pattern. Not appropriate, see #14.
andrewmacpherson’s picture

Further to #2:

The more-actions button is INSIDE the list container which it controls! I have a feeling that this is an unusual pattern.

It also makes it awkward to use aria-controls appropriately. It would be neater if the button was controlling the visibility of a single UL element, not multiple LI elements. Note the ARIA recommendation doesn't strictly require the use of aria-controls with aria-expanded; it's recommended, but we could get away with omitting it here, because the controlled items are immediately after the button.

It's possible to drop off the end of it by tabbing. The W3C pattern examples use arrow keys to select an action, and loop around the first/last items.

Actually, that's fine. It's the normal behaviour of a simple disclosure button. (Compare with a HTML details group, which doesn't use arrow keys or constrain tabbing either). The arrow keys and tabbing constraint is only expected for the menubutton pattern, which is no longer proposed here since #14.

Pressing escape does nothing in our dropbutton. The W3C pattern collapses the menu button.

This is no longer relevant. It's relevant to the ARIA menubutton pattern, but isn't expected for a simple disclosure button.

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.

mweiler’s picture

It's Feb 14, 2022 and I'm flying into this thread (last updated in Feb 2021) from a thread I started in Nov 2021. The issue I'm arriving from (#325075) focuses on the dropdown button from the perspective of the aural interface (as created by JAWS) in comparison with the visual interface.

The issue includes demonstration videos and visualizations of the aural interface of the dropdown button.

While I now think the proposed solution I put for in #3250775 is incorrect, I agree with a point in this thread that the dropdown button does not put "expanded" or "collapsed" messages into the aural interface.

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.

mgifford’s picture

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.