How to use the @instructure/ui-dom-utils.findTabbable function in @instructure/ui-dom-utils

To help you get started, we’ve selected a few @instructure/ui-dom-utils 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 instructure / instructure-ui / packages / ui-pagination / src / Pagination / index.js View on Github external
componentWillReceiveProps (nextProps) {
    if (!nextProps.shouldHandleFocus) {
      return
    }

    if (!propsHaveCompactView(this.props) && !propsHaveCompactView(nextProps)) {
      return
    }

    const focusable = findTabbable(this._root)
    if (
      focusable[0] === document.activeElement &&
      !shouldShowPrevButton(nextProps)
    ) {
      // Previous Page button has focus, but will no longer be rendered
      this._moveFocusTo = 'first'
      return
    }

    if (
      focusable[focusable.length - 1] === document.activeElement &&
      !shouldShowNextButton(nextProps)
    ) {
      // Next Page button has focus, but will no longer be rendered
      this._moveFocusTo = 'last'
      return
github instructure / instructure-ui / packages / ui-pages / src / Pages / index.js View on Github external
this._timeouts.push(setTimeout(() => {
      const activePage = this._activePage

      // Attempt to focus active page
      if (activePage && activePage.focusable) {
        activePage.focus()
      } else {
        // Use first tabbable as last ditch effort
        const tabbable = findTabbable(this._contentElement)
        const element = tabbable && tabbable[0]

        element && element.focus()
      }
    }))
  }
github instructure / instructure-ui / packages / ui-pages / src / Pages / Page / index.js View on Github external
get defaultFocusElement () {
    let { defaultFocusElement } = this.props

    if (typeof defaultFocusElement === 'function') {
      defaultFocusElement = defaultFocusElement()
    }

    if (defaultFocusElement) {
      defaultFocusElement = findDOMNode(defaultFocusElement)
    }

    if (!defaultFocusElement) {
      const tabbable = findTabbable(this._content)
      defaultFocusElement = tabbable && tabbable[0]
    }

    error(
      defaultFocusElement && defaultFocusElement.focus,
      '[Page] A default focusable element is required or focus will be lost.'
    )

    return defaultFocusElement
  }
github instructure / instructure-ui / packages / ui-pagination / src / Pagination / index.js View on Github external
componentDidUpdate () {
    if (this.props.shouldHandleFocus === false || this.compactView === false) {
      return
    }

    if (this._moveFocusTo != null) {
      const focusable = findTabbable(this._root)
      const focusIndex =
        this._moveFocusTo === 'first' ? 0 : focusable.length - 1
      focusable[focusIndex].focus()
      delete this._moveFocusTo
    }
  }