import { getFocusableElements } from 'ngwr/utils';
const els = getFocusableElements(menuRef.nativeElement);
els[0]?.focus();getFocusableElements
Lists the focusable descendants of an element, in DOM order.
Usage
API
| Name | Description | Type | Default |
|---|---|---|---|
getFocusableElements(root) | Every focusable descendant of root, in DOM order. Skips disabled and tabindex="-1" elements, and unrendered ones unless they hold focus. A positive tabindex is not sorted. | (root: HTMLElement) => readonly HTMLElement[] | — |