Accessibility

a11y/popup-button-expanded

A control that opens a popup (aria-haspopup or role="combobox") has aria-expanded that follows the open state.

seriousstaticWCAG 4.1.2 · Afe-a11y-menus

Why

aria-haspopup says a menu or list will appear; without aria-expanded a screen reader user cannot tell whether it is open now, so they do not know whether to look for it or press the button again. A combobox requires the attribute.

Fix

Add aria-expanded="false" to the trigger and switch it to true when the popup opens, from the same state that shows the popup. Close it on Escape and when focus leaves.

Examples

<!-- bad -->
<button type="button" aria-haspopup="menu">Actions</button>
<!-- good -->
<button type="button" aria-haspopup="menu" aria-expanded="false" aria-controls="row-actions">Actions</button>

Sources

Facts

Id
a11y/popup-button-expanded
Severity
serious
Check
static checked in the source by audit
Applies to
html angular vue svelte astro jsx
WCAG 2.2
4.1.2, level A
Taught by the skill
fe-a11y-menus Navigation, disclosures and menus
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain a11y/popup-button-expanded