-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(cdk/scrolling): virtual scroll not picking up trackBy function when items come in after init #21335
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
@Input() items = Array(10).fill(0).map((_, i) => i); | ||
@Input() trackBy: TrackByFunction<number>; | ||
@Input() templateCacheSize = 20; | ||
orientation = 'vertical'; |
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.
Removing the Input
here isn't necessary for the fix, but I noticed that they don't actually do anything.
…en items come in after init The virtual scroll only creates its `IterableDiffer` once, which means that if the `trackBy` function comes in at a later point (e.g. the input changed or the initialization order is different), it won't be picked up. These changes make it so the differ always has a `trackBy` which then delegates to the user-provided one or falls back to the default. Fixes angular#21281.
a815ad9
to
709691d
Compare
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
…en items come in after init (#21335) The virtual scroll only creates its `IterableDiffer` once, which means that if the `trackBy` function comes in at a later point (e.g. the input changed or the initialization order is different), it won't be picked up. These changes make it so the differ always has a `trackBy` which then delegates to the user-provided one or falls back to the default. Fixes #21281. (cherry picked from commit 43081d9)
…en items come in after init (angular#21335) The virtual scroll only creates its `IterableDiffer` once, which means that if the `trackBy` function comes in at a later point (e.g. the input changed or the initialization order is different), it won't be picked up. These changes make it so the differ always has a `trackBy` which then delegates to the user-provided one or falls back to the default. Fixes angular#21281.
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. |
The virtual scroll only creates its
IterableDiffer
once, which means that if thetrackBy
function comes in at a later point (e.g. the input changed or the initialization order is different), it won't be picked up.These changes make it so the differ always has a
trackBy
which then delegates to the user-provided one or falls back to the default.Fixes #21281.