components icon indicating copy to clipboard operation
components copied to clipboard

fix(cdk/scrolling): virtual list not updating when source array is mutated

Open crisbeto opened this issue 6 years ago • 4 comments

When an array is passed to cdkVirtualFor, it falls back to creating an ArrayDataSource which won't emit if the array has changed. Since the intention of the cdkVirtualFor is to be (more or less) a drop-in alternative for ngFor, it is expected that it'll update if the data has changed. These changes add a new type of data source that will allow us to detect changes on the data and to update the view.

Note: I went with adding a new type of data source, rather than using the iterable differ directly, because it would've meant having to maintain two different code paths inside the directive. Furthermore, I can see this being useful in cdk/tree and cdk/table as well.

Fixes #14635. Fixes #14501.

crisbeto avatar Dec 26 '18 10:12 crisbeto

@jelbourn @mmalerba how should we proceed with this one?

crisbeto avatar Jan 30 '19 18:01 crisbeto

Why don't we just add the methods to DataSource with a default implementation that does nothing? That seems like the cleanest solution to me

@jelbourn WDYT?

mmalerba avatar Apr 17 '19 21:04 mmalerba

Is the issue fixed? when will this be available for us?

MayuriRathod avatar Nov 12 '19 06:11 MayuriRathod

can we approve the fix now? even thou it is not "perfect" it seems to me it does not impact other areas. later it could be improved but at the moment we need the functionality which is even in basic ion-list (in ionic). thank you.

Raigedas avatar Apr 16 '20 19:04 Raigedas