diff --git a/src/Explorer/Panes/ContextualPaneBase.ts b/src/Explorer/Panes/ContextualPaneBase.ts index 11aed8786..0f51620a8 100644 --- a/src/Explorer/Panes/ContextualPaneBase.ts +++ b/src/Explorer/Panes/ContextualPaneBase.ts @@ -9,6 +9,7 @@ import Explorer from "../Explorer"; // TODO: Use specific actions for logging telemetry data export abstract class ContextualPaneBase extends WaitsForTemplateViewModel { + private initalFocusedElement: HTMLElement | undefined; public id: string; public container: Explorer; public firstFieldHasFocus: ko.Observable; @@ -49,9 +50,11 @@ export abstract class ContextualPaneBase extends WaitsForTemplateViewModel { this.visible(false); this.isExecuting(false); this.resetData(); + this.resetFocus(); } public open() { + this.initalFocusedElement = document.activeElement as HTMLElement; this.visible(true); this.firstFieldHasFocus(true); this.resizePane(); @@ -123,4 +126,11 @@ export abstract class ContextualPaneBase extends WaitsForTemplateViewModel { $(paneElement).height(newPaneElementHeight); } + + private resetFocus(): void { + if (this.initalFocusedElement) { + this.initalFocusedElement.focus(); + this.initalFocusedElement = undefined; + } + } }