UtilUpdated in v16Optional

wrTrapFocus

Keeps Tab and Shift+Tab cycling inside a container, such as a dialog.

Usage

import { wrTrapFocus } from 'ngwr/utils';

@HostListener('keydown', ['$event']) onKey(e: KeyboardEvent) {
  wrTrapFocus(dialogRef.nativeElement, e);
}

API

NameDescriptionTypeDefault
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