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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be private readonly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the convention of the other injected properties; theoretically, no one should overwrite them, considering it implicit. Should we still use readonly?


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