How to use the @uifabric/utilities.elementContains function in @uifabric/utilities

To help you get started, we’ve selected a few @uifabric/utilities 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 microsoft / fluent-ui-react / src / components / FocusZone / FocusZone.tsx View on Github external
private updateTabIndexes(onElement?: HTMLElement) {
    let element = onElement
    if (!element && this._root.current) {
      this._defaultFocusElement = null
      element = this._root.current
      if (this._activeElement && !elementContains(element, this._activeElement)) {
        this._activeElement = null
      }
    }

    // If active element changes state to disabled, set it to null.
    // Otherwise, we lose keyboard accessibility to other elements in focus zone.
    if (this._activeElement && !isElementTabbable(this._activeElement)) {
      this._activeElement = null
    }

    const childNodes = element && element.children

    for (let childIndex = 0; childNodes && childIndex < childNodes.length; childIndex++) {
      const child = childNodes[childIndex] as HTMLElement

      if (!isElementFocusZone(child)) {
github microsoft / fluent-ui-react / src / components / FocusZone / FocusZone.tsx View on Github external
) {
        const ownerZoneElement = this.getOwnerZone(this._root.current) as HTMLElement

        if (ownerZoneElement !== this._root.current) {
          const ownerZone =
            _allInstances[ownerZoneElement.getAttribute(FOCUSZONE_ID_ATTRIBUTE) as string]

          return !!ownerZone && ownerZone.focusElement(this._root.current)
        }

        return false
      }
      if (
        !forceIntoFirstElement &&
        this._activeElement &&
        elementContains(this._root.current, this._activeElement) &&
        isElementTabbable(this._activeElement)
      ) {
        this._activeElement.focus()
        return true
      }

      const firstChild = this._root.current.firstChild as HTMLElement

      return this.focusElement(getNextElement(this._root.current, firstChild, true) as HTMLElement)
    }
    return false
  }