ARIA Activedescendant Needs A Focusable Element
ID |
javascript.jsx_aria_activedescendant_tabindex |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
JavaScript |
Tags |
accessibility, jsx, reliability |
Description
Reports aria-activedescendant on a JSX element that cannot hold focus, because it is neither
natively focusable nor given a tabIndex.
Rationale
aria-activedescendant is how a composite widget says "the focus is really on this child" while the
DOM focus stays on the container. That indirection only works if the container is the focused
element: a screen reader reads the active descendant of whatever holds focus, so on an element that
never receives focus the attribute is never consulted and the widget’s keyboard navigation is
silent.
<ul aria-activedescendant="opt-1"><li id="opt-1">One</li></ul> // FLAW - a ul takes no focus
<p aria-activedescendant="opt-1">Text</p> // FLAW - same
<ul aria-activedescendant="opt-1" tabIndex={0}>...</ul> // OK
<input aria-activedescendant="opt-1" /> // OK - natively focusable
<div aria-activedescendant="opt-1" {...rest} /> // OK - attributes may be spread in
A natively focusable element needs nothing further — input, select, textarea and button are
in the tab order already, and that is the usual shape of a combobox. Everything else has to opt in
with a tabIndex, and its mere presence is enough: whether it is 0, -1 or computed, the author
has thought about focus.