How to use the tabbable.isTabbable function in tabbable

To help you get started, we’ve selected a few tabbable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / tabbable_v3.x.x / test_tabbable_v3.x.x.js View on Github external
// @flow

import tabbable from 'tabbable';

const div = document.createElement('div');
const tabbables: Array = tabbable(div, {
  includeContainer: true,
});

tabbable(div);

tabbables.map(node => node.nodeName);

const isTabbable: boolean = tabbable.isTabbable(document.createElement('a'));
const isFocusable: boolean = tabbable.isFocusable(
  document.createElement('button')
);

const untouchabilityChecker = new (class {
  hasDisplayNone() {
    return true;
  }
  isUntouchable() {
    return false;
  }
})();

const isTabbableWithUntouchabilityChecker: boolean = tabbable.isTabbable(
  document.createElement('a'),
  untouchabilityChecker
github flow-typed / flow-typed / definitions / npm / tabbable_v3.x.x / test_tabbable_v3.x.x.js View on Github external
const isTabbable: boolean = tabbable.isTabbable(document.createElement('a'));
const isFocusable: boolean = tabbable.isFocusable(
  document.createElement('button')
);

const untouchabilityChecker = new (class {
  hasDisplayNone() {
    return true;
  }
  isUntouchable() {
    return false;
  }
})();

const isTabbableWithUntouchabilityChecker: boolean = tabbable.isTabbable(
  document.createElement('a'),
  untouchabilityChecker
);

const isFocusableWithUntouchabilityChecker: boolean = tabbable.isFocusable(
  document.createElement('button'),
  untouchabilityChecker
);

const isFocusable2: boolean = tabbable.isFocusable(
  document.createElement('button'),
  // $ExpectError
  3
);

const isTabbable2: boolean = tabbable.isFocusable(
github SAP / fundamental-react / src / Popover / Popover.js View on Github external
handleEscapeKey = () => {
        this.handleOutsideClick();

        if (this.controlRef) {
            if (tabbable.isTabbable(this.controlRef)) {
                this.controlRef.focus();
            } else {
                const firstTabbableNode = tabbable(this.controlRef)[0];
                firstTabbableNode && firstTabbableNode.focus();
            }
        }
    }

tabbable

Returns an array of all tabbable DOM nodes within a containing node.

MIT
Latest version published 1 year ago

Package Health Score

82 / 100
Full package analysis