import { wrTrapFocus } from 'ngwr/utils';
@HostListener('keydown', ['$event']) onKey(e: KeyboardEvent) {
wrTrapFocus(dialogRef.nativeElement, e);
}wrTrapFocus
Keeps Tab and Shift+Tab cycling inside a container, such as a dialog.
Usage
API
| Name | Description | Type | Default |
|---|---|---|---|
wrTrapFocus(root, event) | Cycles Tab focus inside root. Call it from a keydown handler; returns true when it handled a Tab. | (root: HTMLElement, e: KeyboardEvent) => boolean | — |
See also
Util wrGetFocusableElementsLists the focusable descendants of an element, in DOM order.Guide OverlayStyle ngwr's floating panels and control where focus goes.Component DialogOpen any component as a modal dialog and await its result.Component DrawerA side panel that slides in from any edge of the screen.