(bug)[Mat-Tree] - Problematic behavior when combining dynamic data with trackby
- Lenguaje dominante
- TypeScript
- Estrellas
- 25k
- Forks
- 6.8k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 91
Descripción
#### What is the expected behavior?
There should be a way to be able to dynamically update leaf nodes within a tree without forcing a collapse upon the tree.
#### What is the current behavior?
Utilizing a `trackBy` function to track an individual node by something like an ID causes the entire tree to become unresponsive after a change is made to the data. When the `trackBy` is omitted, the tree continues to respond after data changes, but any open nodes will collapse and you will have to re-navigate to the previously opened node.
#### What are the steps to reproduce?
Please reference the following stackblitz. Clicking the 'new' button will cause a new leaf to be created under node ID 1. Once this happens, you will see that all nodes will collapse, and clicking on the chevron will not prompt them to open. If you navigate to the template for the controller, and remove the `trackBy` function from the `mat-tree` element, you will find that upon clicking 'new' the tree will continue to collapse, but you will be able to re-expand individual nodes and see the new leaf.
https://stackblitz.com/edit/angular-afy2h1
Guía de contribución
Línea de trabajo
Comienza con la reproducción vinculada en StackBlitz e inspecciona la plantilla mat-tree y el controlador en torno a la actualización dinámica de hojas y la función trackBy. Reproduce el problema con y sin trackBy y, después, rastrea el comportamiento de actualización del árbol. Se considera terminado cuando añadir una hoja mantiene el árbol receptivo y conserva la capacidad de expandir nodos.
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
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100