aria-activedescendant-has-tabindex
Configuration
rslint.config.ts
Rule Details
Enforces that any DOM element managing focus via aria-activedescendant is itself reachable by keyboard. An element using aria-activedescendant to indicate the currently focused descendant must either be a natively focusable element (<input>, <button>, <select>, etc.) or carry a tabIndex of -1 or greater. A tabIndex of -2 or lower removes the element from the focus tree, which defeats the activedescendant pattern.
The rule fires on a JSX opening element when all of the following hold:
- The element has an
aria-activedescendantprop (case-insensitively; the boolean form<div aria-activedescendant />and explicit-undefined value<div aria-activedescendant={undefined} />both count as present). - The resolved element name is in the HTML DOM set (custom React components,
SVG-namespaced tags like
<svg:path>, and dotted-namespace tags like<Foo.Bar>are skipped — the rule does not know what low-level element they render to). - The element is not both inherently interactive (
<input>,<button>,<select>, …) and missing atabIndexprop. Inherently interactive elements rely on the browser-native tab order, so they don't need an explicittabIndex. - The element's resolved
tabIndexvalue is less than-1(or cannot be statically resolved to a number>= -1).
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Rule Options
This rule takes no options.
Resources
- WAI-ARIA —
aria-activedescendant - WAI-ARIA Authoring Practices — Managing Focus in Composites Using aria-activedescendant
- MDN —
aria-activedescendant - MDN —
tabindex