Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent tabbing outside of dialog overlay #14647

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prevent tabbing outside of dialog overlay
Fixes #9894
  • Loading branch information
martin-fleck-at committed Dec 18, 2024
commit 4891fa2480c4c71f4c5d5773dfc216bb7f1f5252
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
Loading