How to use the @instructure/ui-dom-utils.containsActiveElement 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-forms / src / Select / SelectField / index.js View on Github external
setTimeout(() => {
              // timeout so we can check where focus went to
              if (!containsActiveElement(this._menu)) {
                // is focus still not on an option
                this.close(event)
              }
            }, 0)
          )
github instructure / instructure-ui / packages / ui-a11y / src / scopeTab.js View on Github external
function scopeTab (element, event, onLeavingFinalTabbable) {
  const node = findDOMNode(element)
  const tabbable = findTabbable(node)

  if (!tabbable.length) {
    event.preventDefault()
    return
  }

  // Account for a changing tabindex of the active element
  // (a case that happens with Menu for KO a11y)
  if (containsActiveElement(element)) {
    const activeElement = getActiveElement()
    if (tabbable.indexOf(activeElement) === -1) {
      tabbable.push(activeElement)
    }
  }

  const finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1]
  const leavingFinalTabbable = (
    isActiveElement(finalTabbable) ||
    // handle immediate shift+tab after opening with mouse
    isActiveElement(node) ||
    // already left final tabbable
    !containsActiveElement(element)
  )

  if (!leavingFinalTabbable) return
github instructure / instructure-ui / packages / ui-a11y / src / scopeTab.js View on Github external
// Account for a changing tabindex of the active element
  // (a case that happens with Menu for KO a11y)
  if (containsActiveElement(element)) {
    const activeElement = getActiveElement()
    if (tabbable.indexOf(activeElement) === -1) {
      tabbable.push(activeElement)
    }
  }

  const finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1]
  const leavingFinalTabbable = (
    isActiveElement(finalTabbable) ||
    // handle immediate shift+tab after opening with mouse
    isActiveElement(node) ||
    // already left final tabbable
    !containsActiveElement(element)
  )

  if (!leavingFinalTabbable) return

  if (typeof onLeavingFinalTabbable === 'function') {
    onLeavingFinalTabbable()
    return
  }

  event.preventDefault()
  const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0]
  target.focus()
}
github instructure / instructure-ui / packages / ui-a11y / src / KeyboardFocusRegion.js View on Github external
get focused () {
    return containsActiveElement(this._contextElement)
  }
github instructure / instructure-ui / packages / ui-pages / src / Pages / index.js View on Github external
get focused () {
    return containsActiveElement(this._contentElement)
  }
github instructure / instructure-ui / packages / ui-menu / src / Menu / index.js View on Github external
focused () {
    if (this.shown) {
      return containsActiveElement(this._menu) || this.state.hasFocus
    } else {
      return containsActiveElement(this._trigger)
    }
  }
github instructure / instructure-ui / packages / ui-menu / src / Menu / index.js View on Github external
focused () {
    if (this.shown) {
      return containsActiveElement(this._menu) || this.state.hasFocus
    } else {
      return containsActiveElement(this._trigger)
    }
  }
github instructure / instructure-ui / packages / ui-a11y / src / KeyboardFocusRegion.js View on Github external
requestAnimationFrame(() => {
          if (containsActiveElement(this._contextElement)) {
            return
          }
          this.focusDefaultElement()
        })
      )
github instructure / instructure-ui / packages / ui-popover / src / Popover / index.js View on Github external
this._raf.push(requestAnimationFrame(() => {
        if (!containsActiveElement(this._view)) {
          this.hide(event)
        }
      }))
    }