angular / angular/components

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

Abierto
#11,616 9 comentarios 23 reacciones 0 asignados Ver en GitHub
area: cdk/tree P4
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con la reproducción vinculada de StackBlitz y compara el comportamiento de MatTree con ngFor cuando se utiliza una función trackBy. Revisa el issue relacionado #7877 y verifica que reemplazar el array de nodos actualice las propiedades modificadas en la plantilla renderizada mientras conserva los nodos rastreados.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.