Reset focus to trigger element when pane is closed (#217)
This commit is contained in:
parent
d85c96d408
commit
832f8d560d
|
@ -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<boolean>;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue