in src/utils/FocusTrap.js [81:102]
onFocus(event) {
// if the focus target is contained within the `focusContainer`
if (this.focusContainer.contains(event.target)) {
// save as a recent focus target
this.lastFocusedElement = event.target;
} else {
// the focus target is outside of the container, stop the event.
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;
}
}
}