angular / angular/components

[mat-tree] Nodes are not updated correctly with trackyBy function set

Aperta
#11,616 9 commenti 23 reazioni 0 assegnatari Vedi su GitHub
area: cdk/tree P4
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

#### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la riproduzione StackBlitz collegata e confronta il comportamento di MatTree con ngFor quando viene utilizzata una funzione trackBy. Esamina la issue correlata #7877 e verifica che la sostituzione dell'array di nodi aggiorni le proprietà modificate nel template renderizzato preservando i nodi tracciati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.