src/utils/FocusTrap.js
/**
   * Handles globally focusing on elements
   * @param {FocusEvent} event
   */
Handles globally focusing on elements
@param {FocusEvent} event
Handles globally focusing on elements @param { FocusEvent } event
onFocus(event) {
    if (this.focusContainer.contains(event.target)) {
      this.lastFocusedElement = event.target;
    } else {
      event.preventDefault();
      this.collectTabTargets();
      if (this.lastFocusedElement === this.lastTabTarget || !this.lastFocusedElement) {
        this.firstTabTarget.focus();
        this.lastFocusedElement = this.firstTabTarget;
        return;
      }
      if (this.lastFocusedElement === this.firstTabTarget) {
        this.lastTabTarget.focus();
        this.lastFocusedElement = this.lastTabTarget;
      }
    }
  }
onFocus ( event ) { if ( this . focusContainer . contains ( event . target ) ) { this . lastFocusedElement = event . target ; } else { event . preventDefault ( ) ; this . collectTabTargets ( ) ; if ( this . lastFocusedElement === this . lastTabTarget || ! this . lastFocusedElement ) { this . firstTabTarget . focus ( ) ; this . lastFocusedElement = this . firstTabTarget ; return ; } if ( this . lastFocusedElement === this . firstTabTarget ) { this . lastTabTarget . focus ( ) ; this . lastFocusedElement = this . lastTabTarget ; } } }
Handles globally focusing on elements
 @param {FocusEvent} event
Handles globally focusing on elements @param { FocusEvent } event
// if the focus target is contained within the `focusContainer` // save as a recent focus target // the focus target is outside of the container, stop the event.