From bf643cc85fe8a086818591290cb3111e2a3ec811 Mon Sep 17 00:00:00 2001 From: Gene Lee Date: Tue, 4 Jun 2019 16:03:55 -0700 Subject: [PATCH] Fixed bug: Execute cell should scroll to its results (#5861) --- .../parts/notebook/cellViews/output.component.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 {