Build a keyboard-accessible accordion
Implement an accordion with correct ARIA relationships and roving keyboard navigation.Description
Requirements
The solution exports the required AccessibleAccordion API from the editable module.
Aria relationships works deterministically for the documented normal, boundary, and repeated-use scenarios.
Expand collapse works deterministically for the documented normal, boundary, and repeated-use scenarios.
Arrow navigation works deterministically for the documented normal, boundary, and repeated-use scenarios.
Home end navigation works deterministically for the documented normal, boundary, and repeated-use scenarios.
Disabled state works deterministically for the documented normal, boundary, and repeated-use scenarios.
Focus preserved works deterministically for the documented normal, boundary, and repeated-use scenarios.
Header navigation
Focus the first header and press End
Focus moves to the final enabled accordion header
Accordion navigation follows the WAI-ARIA keyboard pattern without unexpectedly opening a panel.
Constraints
Use native buttons for headersConnect each header and panel with stable unique IDsDo not move DOM focus when expanding or collapsing
Hints
Hint 1
Keep open state separate from the index of the currently focused header.
Hint 2
Store header refs in item order so Arrow, Home, and End keys can move focus.
Hint 3
Let disabled buttons remain in the structure while excluding them from toggle behavior.