[mat-tree] Nodes are not updated correctly with trackyBy function set
- Dominant language
- TypeScript
- Stars
- 25k
- Forks
- 6.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 91
Description
#### Bug, feature request, or proposal:
MatTree does not reflect the changes to the nodes if trackBy function is used. For example, I have several items with trackBy function pointing to their "id" property. If I provide a new array with completely same ids, but with changes to some of the other properties, change detection does not occur.
#### What is the expected behavior?
When used with trackBy function MatTree should trigger change detection on all nodes, just like ngFor with trackBy does.
#### What is the current behavior?
No changes are detected therefore data is not updated in template.
#### What are the steps to reproduce?
https://stackblitz.com/edit/angular-material2-issue-z8ubtt
#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Latest versions of Angular, Material (check StackBlitz). Any browser.
#### Is there anything else we should know?
Same [issue](https://github.com/angular/material2/issues/7877) was observed last year with MatTable.
Contributor guide
Research direction
Start with the linked StackBlitz reproduction and compare MatTree's behavior with ngFor when a trackBy function is used. Review the related issue #7877 and verify that replacing the node array updates changed properties in the rendered template while preserving tracked nodes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100