Skip to content

Commit

Permalink
Prevent tabbing outside of dialog overlay
Browse files Browse the repository at this point in the history
Fixes #9894
  • Loading branch information
martin-fleck-at committed Dec 18, 2024
1 parent 4e3b183 commit 4891fa2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/core/src/browser/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,17 @@ export abstract class AbstractDialog<T> extends BaseWidget {
this.addAcceptAction(this.acceptButton, 'click');
}
this.addCloseAction(this.closeCrossNode, 'click');
this.toDisposeOnDetach.push(this.preventTabbingOutsideDialog());
// TODO: use DI always to create dialog instances
this.toDisposeOnDetach.push(DialogOverlayService.get().push(this));
}

protected preventTabbingOutsideDialog(): Disposable {
const nonInertSiblings = Array.from(this.node.ownerDocument.body.children).filter(child => child !== this.node && !(child.hasAttribute('inert')));
nonInertSiblings.forEach(child => child.setAttribute('inert', ''));
return Disposable.create(() => nonInertSiblings.forEach(child => child.removeAttribute('inert')));
}

protected handleEscape(event: KeyboardEvent): boolean | void {
this.close();
}
Expand Down

0 comments on commit 4891fa2

Please sign in to comment.