You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Microsoft Windows 10 Pro 10.0.17763 N/A Build 17763
Chrome Version 73.0.3683.103 (Official Build) (64-bit)
FireFox Developer Edition 67.0b9 (64-bit)
Is there anything else we should know?
Surely this is the very intent of view recycling, but it seems very strange that the default behaviour of *cdkVirtualFor is very different from *ngFor: my bound parameters changed, the data rendered via the @Input() changed, so why didn't the internal state reset?
It's more than template caching, which most of us would take to mean the HTML: it caches whole components and internal state.
Obviously, setting templateCacheSize: 0 fixes this problem.
Maybe simply highlighting this in the documentation might help, since you have to read between the lines to understand what's happening? Perhaps I'm the only one with this expectation. 🤷♂️
The text was updated successfully, but these errors were encountered:
Hi Michael, it is not a defect of Angular. Virtual scroll uses cache to reuse components, but your component is not reusable. Look at my explanation for another issue - you have the same case
@ArtemKlots While I agree that this is not a defect by virtue of it being a design choice, I still think it might be a good idea to highlight this behaviour in the documentation more clearly, which was the point of this ticket.
What is the expected behavior?
New components rendered by
CdkVirtualForOf
are pristine by default.What is the current behavior?
New components created by
CdkVirtualForOf
within the<cdk-virtual-scroll-viewport>
inherit internal state of recycled views by default.What are the steps to reproduce?
https://stackblitz.com/edit/angular-virtual-scrolling-with-component-state
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Is there anything else we should know?
Surely this is the very intent of view recycling, but it seems very strange that the default behaviour of
*cdkVirtualFor
is very different from*ngFor
: my bound parameters changed, the data rendered via the@Input()
changed, so why didn't the internal state reset?It's more than template caching, which most of us would take to mean the HTML: it caches whole components and internal state.
Obviously, setting
templateCacheSize: 0
fixes this problem.Maybe simply highlighting this in the documentation might help, since you have to read between the lines to understand what's happening? Perhaps I'm the only one with this expectation. 🤷♂️
The text was updated successfully, but these errors were encountered: