code: 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
  
    if (typeof onLeavingFinalTabbable === 'function') {
      onLeavingFinalTabbable()
      return
    }
  
    event.preventDefault()
    const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0]
    target.focus()
  }
docs: ---
  category: utilities/a11y
  ---
  
  Scope tab in order to trap focus within a specified
  element.
  
  @param {ReactElement|DOMNode} element
  @param {Event} event the DOM Event that was fired
  @param {function} function executed when leaving final tabbable instead of the default behavior