diff --git a/src/sql/workbench/parts/notebook/cellViews/output.component.ts b/src/sql/workbench/parts/notebook/cellViews/output.component.ts index 06f712f6fb..c5b19280eb 100644 --- a/src/sql/workbench/parts/notebook/cellViews/output.component.ts +++ b/src/sql/workbench/parts/notebook/cellViews/output.component.ts @@ -43,7 +43,7 @@ export class OutputComponent extends AngularDisposable implements OnInit { } ngOnInit() { - this.renderOutput(); + this.renderOutput(true); this._initialized = true; this._register(Event.debounce(this.cellModel.notebookModel.layoutChanged, (l, e) => e, 50, /*leading=*/false) (() => this.renderOutput())); @@ -70,11 +70,21 @@ export class OutputComponent extends AngularDisposable implements OnInit { } } - private renderOutput() { + private renderOutput(focusAndScroll: boolean = false): void { let options = outputProcessor.getBundleOptions({ value: this.cellOutput, trusted: this.trustedMode }); options.themeService = this._themeService; // TODO handle safe/unsafe mapping this.createRenderedMimetype(options, this.outputElement.nativeElement); + if (focusAndScroll) { + this.setFocusAndScroll(this.outputElement.nativeElement); + } + } + + private setFocusAndScroll(node: HTMLElement): void { + if (node) { + node.focus(); + node.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); + } } public layout(): void {