Skip to content

Commit e9d1fa1

Browse files
committed
fixup! fix(cdk/scrolling): Prevent virtual scroll 'flickering' with zoneless
1 parent 87b862f commit e9d1fa1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/cdk/scrolling/virtual-scroll-viewport.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,18 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
543543
// potential delays between the browser paint and the next tick.
544544
this.ngZone.runOutsideAngular(async () => {
545545
await Promise.resolve();
546-
if (!rendered && this._runAfterChangeDetection.length > 0) {
547-
this.ngZone.run(() => {
548-
this._applicationRef.tick();
549-
});
546+
if (
547+
rendered ||
548+
this._runAfterChangeDetection.length === 0 ||
549+
// shouldn't be possible since we run this asynchronously and tick is synchronous, but ZoneJS/fakeAsync
550+
// can flush microtasks synchronously
551+
(this._applicationRef as unknown as {_runningTick: boolean})._runningTick
552+
) {
553+
return;
550554
}
555+
this.ngZone.run(() => {
556+
this._applicationRef.tick();
557+
});
551558
});
552559
}
553560

0 commit comments

Comments
 (0)