Skip to content

Commit

Permalink
fix(overlay): only "tab trap" when you mean to
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook Johnson authored and Westbrook committed Sep 15, 2020
1 parent 250a5c6 commit 74e1bd2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/overlay/src/overlay-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export class OverlayStack {

public constructor() {
this.addEventListeners();
this.initTabTrapping();
}

private canTabTrap = true;
private trappingInited = false;
private tabTrapper!: HTMLElement;
private overlayHolder!: HTMLElement;

Expand Down Expand Up @@ -90,6 +90,11 @@ export class OverlayStack {
}

private startTabTrapping(): void {
if (!this.trappingInited) {
this.initTabTrapping();
this.trappingInited = true;
}
/* c8 ignore next 3 */
if (!this.canTabTrap) {
return;
}
Expand All @@ -99,7 +104,7 @@ export class OverlayStack {

private stopTabTrapping(): void {
/* c8 ignore next 3 */
if (!this.canTabTrap) {
if (!this.canTabTrap || !this.trappingInited) {
return;
}
this.tabTrapper.removeAttribute('tabindex');
Expand Down

0 comments on commit 74e1bd2

Please sign in to comment.