Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cdk/scrolling/virtual-scroll-viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
ChangeDetectorRef,
Component,
ElementRef,
inject,
Inject,
Input,
NgZone,
Expand All @@ -23,6 +24,7 @@ import {
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import {Platform} from '@angular/cdk/platform';
import {
animationFrameScheduler,
asapScheduler,
Expand Down Expand Up @@ -77,6 +79,8 @@ const SCROLL_SCHEDULER =
],
})
export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements OnInit, OnDestroy {
private _platform = inject(Platform);

/** Emits when the viewport is detached from a CdkVirtualForOf. */
private readonly _detachedSubject = new Subject<void>();

Expand Down Expand Up @@ -205,6 +209,11 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
}

override ngOnInit() {
// Scrolling depends on the element dimensions which we can't get during SSR.
if (!this._platform.isBrowser) {
return;
}

if (this.scrollable === this) {
super.ngOnInit();
}
Expand Down