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.jsto report the open/closed state, usingaria-expanded, together witharia-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
Comment #2
andrewmacpherson commentedSome interesting quirks in our dropbutton. These might make it a poor match for the W3C menu button 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.Update (3rd Feb 2021): Some of these aren't relevant to us. See comment #18 for explanation.
Comment #3
andrewmacpherson commentedComment #4
andrewmacpherson commentedComment #7
andrewmacpherson commentedJust 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.
Comment #8
andrewmacpherson commentedChanging the parent issue, making this part of the larger plan for improving dropbutton.
Comment #10
andrewmacpherson commentedI'm sure we should be using
aria-expandedto convey the open/closed state, but I don't thinkaria-haspopupis appropriate for all instances of dropbutton.Now
aria-haspopuphas a predefined list of roles which the pop-up can be (dialog, menu, etc). So if we sayaria-haspopup="menu"(or evenaria-haspopup="true"), then this implies that:role="menu"role="menuitem"role="menuitem"doesn't permit operable descendants.The drop button is a general-purpose widget. It could be used for:
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 forrole="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(andaria-controls) withoutaria-haspopupis fine, and well supported.Comment #11
skaughtre: 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.
Comment #14
andrewmacpherson commentedRe. #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.
Comment #17
andrewmacpherson commentedUpdating the proposed resolution:
aria-haspopup, it's not appropriate, see #10aria-controlshas limited support; nonetheless, it works in the assistive tech which supports it. It is appropriate, per the ARIA recommendation foraria-expanded: "If the element with thearia-expandedattribute controls the expansion of another grouping container that is not 'owned by' the element, the author SHOULD reference the container by using thearia-controlsattribute." Our button + list relationship matches this.Comment #18
andrewmacpherson commentedFurther to #2:
It also makes it awkward to use
aria-controlsappropriately. 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 ofaria-controlswitharia-expanded; it's recommended, but we could get away with omitting it here, because the controlled items are immediately after the button.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.
This is no longer relevant. It's relevant to the ARIA menubutton pattern, but isn't expected for a simple disclosure button.
Comment #21
mweiler commentedIt'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.
Comment #25
mgiffordLooks like https://www.w3.org/WAI/WCAG21/Understanding/status-messages.html