import { trapFocus } from 'ngwr/utils';
@HostListener('keydown', ['$event']) onKey(e: KeyboardEvent) {
trapFocus(dialogRef.nativeElement, e);
}trapFocus
Keeps Tab and Shift+Tab cycling inside a container, such as a dialog.
Usage
API
| Name | Description | Type | Default |
|---|---|---|---|
trapFocus(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 | — |