angular / angular/components

bug(COMPONENT): UI not rendered when dynamically modifying data in a mat tree

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

Descripción

### Is this a regression?

- [x] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

17.1.5

### Description

Clicking on the node in the tree to dynamically add data doesn't update the UI.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/2rhfgfpu?file=src%2Fexample%2Ftree-nested-child-accessor-overview-example.ts,src%2Fexample%2Ftree-nested-child-accessor-overview-example.html
Steps to reproduce:
1. Click on a node
2. The tree is not updated with the newly created node

### Expected Behavior

When i add a node, when the UI has to be updated.

### Actual Behavior

When i click on a node, i sometimes need to load dynamic data from the backend and append the created node to the node i just clicked.
We used to refresh the UI by assigning null to the data of the datasource and re-assigning the data to the datasource following this ticket : https://github.com/angular/components/issues/11381
Unfortunately, this does not work anymore because i have the following error : nodes is not iterable.
I checked the source code, and the error occurs in the tree component.

Funnily enough, when i modify the HTML to live reload the page, my nodes appear.

### Environment

- Angular: 19.1.5
- CDK/Material: 19.1.2
- Browser(s): Chrome Version 133.0.6943.98 (Official Build) (64-bit)
- Operating System (e.g. Windows, macOS, Ubuntu): Linux

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Reproduce la regresión en el StackBlitz enlazado, comenzando por src/example/tree-nested-child-accessor-overview-example.ts y su plantilla HTML. Después inspecciona el código fuente del componente tree donde se produce el error “nodes is not iterable”. Se considera terminado cuando los datos secundarios añadidos dinámicamente se renderizan en el tree sin el error y sin requerir una recarga en vivo.

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
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.