eng-a11y-focus-scope
eng-a11y-focus-scope
npm i eng-a11y-focus-scope
eng-a11y-focus-scope

eng-a11y-focus-scope

Accessibility util for scoping focus to an element.

by cloudflare

1.1.3-1 (see all)License:BSD-3-ClauseTypeScript:Not Found
npm i eng-a11y-focus-scope
Readme

a11y-focus-scope

Accessibility util for scoping focus to an element.

Installation

$ npm install --save a11y-focus-scope

Import

In SystemJS configuration file add the following line in paths:

'a11y-focus-scope': 'node_modules/eng-a11y-focus-scope/index.js'

In your Component add the following lines in imports:

import {scopeFocus, unscopeFocus} from 'a11y-focus-scope';

Usage

document.body.innerHTML = `
  <button id="outer-button">Outer Button</button>

  <div id="container">
    <button id="inner-button">Inner Button</button>
  </div>
`;

var container = document.getElementById('container');
var innerButton = document.getElementById('inner-button');
var outerButton = document.getElementById('outer-button');

scopeFocus(container);
// document.activeElement === container;

innerButton.focus();
// document.activeElement === innerButton;

outerButton.focus();
// document.activeElement === container;

unscopeFocus();
outerButton.focus();
// document.activeElement === outerButton;

Downloads/wk

15

GitHub Stars

32

LAST COMMIT

6yrs ago

MAINTAINERS

1

CONTRIBUTORS

3

OPEN ISSUES

2

OPEN PRs

0
VersionTagPublished
1.1.3-1
latest
5yrs ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate