diff --git a/src/sql/parts/notebook/notebook.component.html b/src/sql/parts/notebook/notebook.component.html index ffc9703231..be2c51272d 100644 --- a/src/sql/parts/notebook/notebook.component.html +++ b/src/sql/parts/notebook/notebook.component.html @@ -7,7 +7,7 @@
-
+
diff --git a/src/sql/parts/notebook/notebook.component.ts b/src/sql/parts/notebook/notebook.component.ts index 3d77252fd5..3b43ce1ecc 100644 --- a/src/sql/parts/notebook/notebook.component.ts +++ b/src/sql/parts/notebook/notebook.component.ts @@ -51,6 +51,7 @@ export const NOTEBOOK_SELECTOR: string = 'notebook-component'; }) export class NotebookComponent extends AngularDisposable implements OnInit, OnDestroy, INotebookEditor { @ViewChild('toolbar', { read: ElementRef }) private toolbar: ElementRef; + @ViewChild('container', { read: ElementRef }) private container: ElementRef; private _model: NotebookModel; private _isInErrorState: boolean = false; private _errorMessage: string; @@ -62,6 +63,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe private profile: IConnectionProfile; private _trustedAction: TrustedAction; private _providerRelatedActions: IAction[] = []; + private _scrollTop: number; constructor( @@ -112,6 +114,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this)); this.updateTheme(this.themeService.getColorTheme()); this.initActionBar(); + this.setScrollPosition(); this.doLoad(); } @@ -157,6 +160,11 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe } } + //Saves scrollTop value on scroll change + public scrollHandler(event: Event){ + this._scrollTop = event.srcElement.scrollTop; + } + public unselectActiveCell() { if (this.model && this.model.activeCell) { this.model.activeCell.active = false; @@ -201,6 +209,15 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe } } + private setScrollPosition(): void { + if (this._notebookParams && this._notebookParams.input) { + this._notebookParams.input.layoutChanged(() => { + let containerElement = this.container.nativeElement; + containerElement.scrollTop = this._scrollTop; + }); + } + } + private async doLoad(): Promise { try { await this.setNotebookManager();