focusChild
Commons
stable
Focus the first, last, next, or previous focusable descendant inside an element. When no location is given it focuses the first child unless focus already lives inside the element.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- elrequiredElement
- The container element to search for focusable descendants.
- locationTFocusLocation
- Optional direction: 'first' | 'last' | 'next' | 'prev' | number (index). When omitted, focuses the first child unless focus already lives inside the element.
API
Return value
The value returned by this util.
- No return value — the side effect is a focus move.
Usage
Examples
Ready-to-paste usage snippets.
Focus first focusable child on mount