mirror of
https://github.com/Microsoft/vscode
synced 2024-10-31 07:52:49 +00:00
Merge pull request #56491 from Microsoft/sbatten/returnContextMenuFocus
fixes #56225
This commit is contained in:
commit
9a7141e583
1 changed files with 8 additions and 0 deletions
|
@ -25,6 +25,7 @@ export class ContextMenuHandler {
|
|||
|
||||
private $el: Builder;
|
||||
private menuContainerElement: HTMLElement;
|
||||
private focusToReturn: HTMLElement;
|
||||
|
||||
constructor(element: HTMLElement, contextViewService: IContextViewService, telemetryService: ITelemetryService, notificationService: INotificationService) {
|
||||
this.setContainer(element);
|
||||
|
@ -53,6 +54,8 @@ export class ContextMenuHandler {
|
|||
return; // Don't render an empty context menu
|
||||
}
|
||||
|
||||
this.focusToReturn = document.activeElement as HTMLElement;
|
||||
|
||||
this.contextViewService.showContextView({
|
||||
getAnchor: () => delegate.getAnchor(),
|
||||
canRelayout: false,
|
||||
|
@ -110,6 +113,11 @@ export class ContextMenuHandler {
|
|||
}
|
||||
|
||||
this.contextViewService.hideContextView(false);
|
||||
|
||||
// Restore focus here
|
||||
if (this.focusToReturn) {
|
||||
this.focusToReturn.focus();
|
||||
}
|
||||
}
|
||||
|
||||
private onDidActionRun(e: IRunEvent): void {
|
||||
|
|
Loading…
Reference in a new issue