Merge pull request #56491 from Microsoft/sbatten/returnContextMenuFocus

fixes #56225
This commit is contained in:
Isidor Nikolic 2018-08-16 16:07:12 +02:00 committed by GitHub
commit 9a7141e583
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {