Skip to content

Commit

Permalink
Prevent tabbing outside of dialog overlay (#14647)
Browse files Browse the repository at this point in the history
Fixes #9894
  • Loading branch information
martin-fleck-at authored Jan 8, 2025
1 parent 9edbf2c commit 11ea9e6
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 11ea9e6

Please sign in to comment.