diff --git a/src/framework/theme/components/cdk/overlay/overlay-position.spec.ts b/src/framework/theme/components/cdk/overlay/overlay-position.spec.ts index e941bac61e..48cbf39307 100644 --- a/src/framework/theme/components/cdk/overlay/overlay-position.spec.ts +++ b/src/framework/theme/components/cdk/overlay/overlay-position.spec.ts @@ -44,7 +44,7 @@ describe('NbAdjustableConnectedPositionStrategy', () => { // Have to create layout component as it's required for scroll service to work properly. // Also it registers overlay container so we don't have to create it manually. - TestBed.createComponent(NbLayoutComponent); + TestBed.createComponent(NbLayoutComponent).detectChanges(); overlayHostElement = document.createElement('div'); overlayHostElement.style.width = '10px'; diff --git a/src/framework/theme/components/layout/layout.component.ts b/src/framework/theme/components/layout/layout.component.ts index 157becbb4a..888d28293b 100644 --- a/src/framework/theme/components/layout/layout.component.ts +++ b/src/framework/theme/components/layout/layout.component.ts @@ -274,25 +274,6 @@ export class NbLayoutComponent implements AfterViewInit, OnDestroy { listener.complete(); }); - this.scrollService.onGetPosition() - .pipe( - takeUntil(this.destroy$), - ) - .subscribe(({ listener }) => { - listener.next(this.getScrollPosition()); - listener.complete(); - }); - - this.scrollTop - .shouldRestore() - .pipe( - filter(() => this.restoreScrollTopValue), - takeUntil(this.destroy$), - ) - .subscribe(() => { - this.scroll(0, 0); - }); - this.scrollService .onScrollableChange() .pipe( @@ -318,6 +299,20 @@ export class NbLayoutComponent implements AfterViewInit, OnDestroy { } ngAfterViewInit() { + this.scrollService.onGetPosition() + .pipe(takeUntil(this.destroy$)) + .subscribe(({ listener }) => { + listener.next(this.getScrollPosition()); + listener.complete(); + }); + + this.scrollTop.shouldRestore() + .pipe(filter( + () => this.restoreScrollTopValue), + takeUntil(this.destroy$), + ) + .subscribe(() => this.scroll(0, 0)); + this.layoutDirectionService.onDirectionChange() .pipe(takeUntil(this.destroy$)) .subscribe(direction => this.document.dir = direction);