Skip to content

Commit

Permalink
[context menus] Restore the focus (fixes #481)
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Efftinge <[email protected]>
  • Loading branch information
svenefftinge committed Sep 21, 2017
1 parent c7c46de commit f2ec970
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/core/src/browser/menu/browser-context-menu-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ export class BrowserContextMenuRenderer implements ContextMenuRenderer {
render(path: string, anchor: Anchor, onHide?: () => void): void {
const contextMenu = this.menuFactory.createContextMenu(path);
const { x, y } = anchor instanceof MouseEvent ? { x: anchor.clientX, y: anchor.clientY } : anchor;
if (onHide) {
contextMenu.aboutToClose.connect(() => onHide());
}
const previouslyActive = window.document.activeElement as HTMLElement;
contextMenu.aboutToClose.connect(() => {
previouslyActive.focus();
if (onHide) {
onHide();
}
});
contextMenu.open(x, y);
}

Expand Down

0 comments on commit f2ec970

Please sign in to comment.