How to use the dom-helpers/activeElement function in dom-helpers

To help you get started, we’ve selected a few dom-helpers 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 jquense / react-widgets / packages / react-widgets / src / DateTimePicker.js View on Github external
focus() {
    if (this.inputRef && activeElement() !== findDOMNode(this.inputRef))
      this.inputRef.focus()
  }
github zendeskgarden / react-containers / packages / focusjail / src / useFocusJail.ts View on Github external
const getInitialFocusNode = () => {
    const doc = environment ? environment : document;
    const activeElem = activeElement(doc);
    const containerElem = currentRef;

    return containerElem!.contains(activeElem) ? activeElem : containerElem;
  };
github jquense / react-widgets / packages / react-widgets / src / NumberInput.js View on Github external
isSelectingAllText() {
    const node = canUseDOM && findDOMNode(this)
    return (
      canUseDOM &&
      activeElement() === node &&
      node.selectionStart === 0 &&
      node.selectionEnd === node.value.length
    )
  }
github deranjer / goTorrent / goTorrentWebUI / node_modules / material-ui / es / Menu / MenuList.js View on Github external
}, this.handleKeyDown = event => {
      const list = findDOMNode(this.list);
      const key = keycode(event);
      const currentFocus = activeElement(ownerDocument(list));

      if ((key === 'up' || key === 'down') && (!currentFocus || currentFocus && !contains(list, currentFocus))) {
        if (this.selectedItem) {
          findDOMNode(this.selectedItem).focus();
        } else {
          list.firstChild.focus();
        }
      } else if (key === 'down') {
        event.preventDefault();
        if (currentFocus.nextElementSibling) {
          currentFocus.nextElementSibling.focus();
        }
      } else if (key === 'up') {
        event.preventDefault();
        if (currentFocus.previousElementSibling) {
          currentFocus.previousElementSibling.focus();
github react-bootstrap / react-overlays / src / Modal.js View on Github external
autoFocus() {
    if (!this.props.autoFocus) return;

    const currentActiveElement = activeElement(ownerDocument(this));

    if (this.dialog && !contains(this.dialog, currentActiveElement)) {
      this.lastFocus = currentActiveElement;
      this.dialog.focus();
    }
  }
github deranjer / goTorrent / goTorrentWebUI / node_modules / material-ui / es / Menu / MenuList.js View on Github external
resetTabIndex() {
    const list = findDOMNode(this.list);
    const currentFocus = activeElement(ownerDocument(list));
    const items = [...list.children];
    const currentFocusIndex = items.indexOf(currentFocus);

    if (currentFocusIndex !== -1) {
      return this.setTabIndex(currentFocusIndex);
    }

    if (this.selectedItem) {
      return this.setTabIndex(items.indexOf(findDOMNode(this.selectedItem)));
    }

    return this.setTabIndex(0);
  }
github zendeskgarden / react-components / packages / modals / src / containers / FocusJailContainer.js View on Github external
getInitialFocusNode = () => {
    const doc = getDocument ? getDocument(this.props) : document;
    const activeElem = activeElement(doc);

    return this.container.contains(activeElem) ? activeElem : this.container;
  };