Dropdown needs accessibility improvements
See original GitHub issueThe Dropdown component (I only tried the first one on the code page) has several accessibility problems:
- Having a label that disappears is not considered very accessible (similar to placeholder in text input not being considered very accessible). I have seen devs try to give this a label with
<label>
(which doesn’t work here) or hook up a span with aria-labelledby. Fixing this “disappearing label” problem may involve a slight redesign. 😃 - Typing Esc closes the list, but it also closes the side nav, so the key handler for Esc needs to stop propagation and maybe also prevent default.
- The markup is confusing to screen readers:
- it thinks this is a “list with 2 items”: the bx–dropdown-text item and the item containing the dropdown list. It may help to to change the outer
<ul>
and the 2<li>
into divs (or give them role=“presentation”). - it doesn’t know that the dropdown list drops down, so it doesn’t tell the user that there’s a dropdown available
- it reads all of the items in the dropdown list right away, even though they are not showing
- it thinks this is a “list with 2 items”: the bx–dropdown-text item and the item containing the dropdown list. It may help to to change the outer
Some aria may be needed to make this more understandable (maybe aria-haspopup=“listbox” and aria-expanded=“true/false”). Please read the “menu button” pattern and the “combobox” pattern in the ARIA Authoring Practices Guide to see what makes the most sense. They are both similar to what you are trying to achieve, I think.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Accessibility improvements to item list dropdown - Drupal
There are a few accessibility issues with the current implementation of item list dropdown. As suggested by lighthouse report ...
Read more >Are Drop Down Menus WCAG 2.1 Accessible?
Wondering if your website's drop down menu is accessible? Learn more about the WCAG 2.1 requirements for navigation.
Read more >Dropdown: accessibility improvements · Issue #1452 - GitHub
It will improve the accessibility experience for everyone who relies on the default DropdownEntry rendering and keep the current broken ...
Read more >Building Accessible Menu Systems - Smashing Magazine
Navigation submenus (or "dropdowns" to some) work well with a mouse ... Not only is it easier to make responsive, and requires less...
Read more >CSS-Only Accessible Dropdown Navigation Menu
This technique explores using: animation with CSS `transition` and `transform`, using the `:focus-within` pseudo-class, CSS grid, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m planning on breaking this issue up in to multiple PRs just to keep the size of the changes easier for reviewing. The first PR will have HTML/styles (with minor JS changes just to keep it “working”) and the second PR will contain more robust JS changes for complete a11y updates.
I combined the two PRs because the JavaScript wasn’t as big of updates as anticipated. This PR should close this issue as the first 2 items were already fixed so I focused on the screen reader experience updates.