How to use the tabbable.isFocusable 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
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(
  document.createElement('button'),
  // $ExpectError
  3
);
github flow-typed / flow-typed / definitions / npm / tabbable_v3.x.x / test_tabbable_v3.x.x.js View on Github external
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(
  document.createElement('button'),
  // $ExpectError
  3
);
github davidtheclark / focus-trap / index.js View on Github external
function checkPointerDown(e) {
    if (container.contains(e.target)) return;
    if (config.clickOutsideDeactivates) {
      deactivate({
        returnFocus: !tabbable.isFocusable(e.target)
      });
      return;
    }
    // This is needed for mobile devices.
    // (If we'll only let `click` events through,
    // then on mobile they will be blocked anyways if `touchstart` is blocked.)
    if (config.allowOutsideClick && config.allowOutsideClick(e)) {
      return;
    }
    e.preventDefault();
  }
github Blazored / Modal / src / Blazored.Modal / FocusTrap.ts View on Github external
private checkPointerDown(e): void {
        if (this.container.contains(e.target)) return;

        if (this.config.clickOutsideDeactivates) {
            this.deactivate({
                returnFocus: !tabbable.isFocusable(e.target)
            });

            return;
        }

        // This is needed for mobile devices.
        // (If we'll only let `click` events through,
        // then on mobile they will be blocked anyways if `touchstart` is blocked.)
        if (this.config.allowOutsideClick && this.config.allowOutsideClick(e)) {
            return;
        }

        e.preventDefault();
    }
github davidtheclark / focus-trap / demo / demo-bundle.js View on Github external
function checkPointerDown(e) {
            if (container.contains(e.target)) return;
            if (config.clickOutsideDeactivates) {
              deactivate({
                returnFocus: !tabbable.isFocusable(e.target)
              });
            } else {
              e.preventDefault();
            }
          }
github skbkontur / retail-ui / packages / retail-ui / lib / dom / getFocusableElements.ts View on Github external
export const getClosestFocusableElement = (current: HTMLElement | null): HTMLElement | null => {
  if (!current) {
    return null;
  }

  return tabbable.isFocusable(current) ? current : getClosestFocusableElement(current.parentElement);
};

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