-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(virtual-scroll): emit on viewChange
inside the NgZone
#12873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/cdk/scrolling/virtual-for-of.ts
Outdated
@SkipSelf() private _viewport: CdkVirtualScrollViewport) { | ||
@SkipSelf() private _viewport: CdkVirtualScrollViewport, | ||
/** The Angular zone. */ | ||
ngZone: NgZone) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be optional with a breaking change for next major?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual scroll isn't released yet so its ok
src/cdk/scrolling/virtual-for-of.ts
Outdated
@@ -166,14 +167,16 @@ export class CdkVirtualForOf<T> implements CollectionViewer, DoCheck, OnDestroy | |||
/** The set of available differs. */ | |||
private _differs: IterableDiffers, | |||
/** The virtual scrolling viewport that these items are being rendered in. */ | |||
@SkipSelf() private _viewport: CdkVirtualScrollViewport) { | |||
@SkipSelf() private _viewport: CdkVirtualScrollViewport, | |||
/** The Angular zone. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't contribute much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, removed
this.dataStream.subscribe(data => { | ||
this._data = data; | ||
this._onRenderedDataChange(); | ||
}); | ||
this._viewport.renderedRangeStream.pipe(takeUntil(this._destroyed)).subscribe(range => { | ||
this._renderedRange = range; | ||
this.viewChange.next(this._renderedRange); | ||
ngZone.run(() => this.viewChange.next(this._renderedRange)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to write a test for this. Something like:
const spy = jasmine.createSpy('something');
renderedRangeStream.subscribe(() => spy(NgZone.isInAngularZone()));
expect(spy).toHaveBeenCalledWith(true);
test added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -166,14 +167,15 @@ export class CdkVirtualForOf<T> implements CollectionViewer, DoCheck, OnDestroy | |||
/** The set of available differs. */ | |||
private _differs: IterableDiffers, | |||
/** The virtual scrolling viewport that these items are being rendered in. */ | |||
@SkipSelf() private _viewport: CdkVirtualScrollViewport) { | |||
@SkipSelf() private _viewport: CdkVirtualScrollViewport, | |||
ngZone: NgZone) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left this before, but I think it got lost between commits: shouldn't we make this an optional parameter with a breaking change for the next major?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual scroll isn't released yet, so it's not necessary
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
fixes #12869