Skip to content
Open
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
8 changes: 3 additions & 5 deletions src/cdk/scrolling/virtual-scroll-viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On

private _injector = inject(Injector);

private _isDestroyed = false;
private _destroyRef = inject(DestroyRef);

constructor(...args: unknown[]);

Expand Down Expand Up @@ -211,7 +211,7 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
// effect that runs before change detection of any application views (since we're depending on markForCheck marking parents dirty)
{injector: inject(ApplicationRef).injector},
);
inject(DestroyRef).onDestroy(() => void ref.destroy());
this._destroyRef.onDestroy(() => void ref.destroy());
}

override ngOnInit() {
Expand Down Expand Up @@ -262,8 +262,6 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
this._detachedSubject.complete();
this._viewportChanges.unsubscribe();

this._isDestroyed = true;

super.ngOnDestroy();
}

Expand Down Expand Up @@ -512,7 +510,7 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On

/** Run change detection. */
private _doChangeDetection() {
if (this._isDestroyed) {
if (this._destroyRef.destroyed) {
return;
}

Expand Down
Loading