From edea3117577abf2031c009cddbb9d202872cfe80 Mon Sep 17 00:00:00 2001 From: Hale Rankin Date: Wed, 20 Jan 2021 13:55:16 -0800 Subject: [PATCH] Revised section scrolling logic to fix broken user experience. (#13926) (#14005) --- .../notebook/browser/notebook.component.ts | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/sql/workbench/contrib/notebook/browser/notebook.component.ts b/src/sql/workbench/contrib/notebook/browser/notebook.component.ts index 5b9b09d32a..a6e8c9145c 100644 --- a/src/sql/workbench/contrib/notebook/browser/notebook.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/notebook.component.ts @@ -760,22 +760,9 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe } navigateToSection(id: string): void { - id = id.toLowerCase(); - let chromeHeight: number = 0; - let elBody: HTMLElement = document.body; - let tabBar = elBody.querySelector('.title.tabs') as HTMLElement; - let actionBar = elBody.querySelector('.editor-toolbar.actionbar-container') as HTMLElement; - let section = this.getSectionElements().find(s => s.relativeUri && s.relativeUri.toLowerCase() === id); + let section = this.getSectionElements().find(s => s.relativeUri && s.relativeUri.toLowerCase() === id.toLowerCase()); if (section) { - // Scroll this section to the top of the header instead of just bringing header into view. - if (tabBar && actionBar) { - chromeHeight = tabBar.scrollHeight + actionBar.scrollHeight; - } - let scrollTop: number = section.headerEl.getBoundingClientRect().top - (chromeHeight + 10); - (this.container.nativeElement).scrollTo({ - top: scrollTop, - behavior: 'smooth' - }); + section.headerEl.scrollIntoView({ behavior: 'smooth', block: 'start' }); section.headerEl.focus(); } }