Ngx focus control

Library to provide tools to work with focus and focusable elements to improve user interfaces and accessibility.

npm versionCircleCICoverage StatusGitHub issuesnpm bundle sizeNPMdemostack blitzGitter
logo
Angular library to provide tools to work with focus and focusable elements to improve user interfaces and accessibility.
npm install ngx-focus-control --save

Focus history directive and service

Directive stores focused elements into history and thanks to history service FocusHistoryService you can go back in focus history using focusHistoryService.focusPrevious(). Put FocusHistoryService into app module providers and then inject it into the component constructor(public readonly focusHistoryService: FocusHistoryService) from the ngx-focus-control package.


Example inputs and also history from History service (elements are mapped to only ids). Focus inputs multiple times and then click on the button, see history.


Code


    <input type="text" placeholder="Input 1" class="input" id="input-1" fuHistory>
    <input type="text" placeholder="Input 2" class="input" id="input-2" fuHistory>
    <button class="button is-info" (click)="focusHistoryService.focusPrevious()">Focus previous</button>