Skip to content

Commit aede0db

Browse files
Westbrook JohnsonWestbrook
authored andcommitted
fix(overlay): only "tab trap" when you mean to
1 parent 250a5c6 commit aede0db

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/overlay/src/overlay-stack.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export class OverlayStack {
3333

3434
public constructor() {
3535
this.addEventListeners();
36-
this.initTabTrapping();
3736
}
3837

3938
private canTabTrap = true;
39+
private trappingInited = false;
4040
private tabTrapper!: HTMLElement;
4141
private overlayHolder!: HTMLElement;
4242

@@ -90,6 +90,11 @@ export class OverlayStack {
9090
}
9191

9292
private startTabTrapping(): void {
93+
if (!this.trappingInited) {
94+
this.initTabTrapping();
95+
this.trappingInited = true;
96+
}
97+
/* c8 ignore next 3 */
9398
if (!this.canTabTrap) {
9499
return;
95100
}
@@ -99,7 +104,7 @@ export class OverlayStack {
99104

100105
private stopTabTrapping(): void {
101106
/* c8 ignore next 3 */
102-
if (!this.canTabTrap) {
107+
if (!this.canTabTrap || !this.trappingInited) {
103108
return;
104109
}
105110
this.tabTrapper.removeAttribute('tabindex');

0 commit comments

Comments
 (0)