angular / angular/components

bug(cdk-tree): CDK Tree can't be opened when trackBy function is used after update of datasource

Abierto
#30,403 9 comentarios 1 reacción 0 asignados Ver en GitHub
area: cdk/tree P2
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

Angular 17 (here is the same example: https://stackblitz.com/edit/zmfrj6ks?file=src%2Fexample%2Fcdk-tree-nested-example.ts,src%2Fexample%2Fcdk-tree-nested-example.html with Angular 17)

### Description

Hi, there is a bug in the Angular CDK Tree. When you update the data of the tree and a trackBy function is given to the tree, you can't interact with the tree anymore.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/fesfbplt?file=src%2Fexample%2Fcdk-tree-nested-children-accessor-example.html
Steps to reproduce:
1. interact with the tree (not mandatory, but you see that it works)
2. click on "changeTree" button
3. try to open the tree again => this doesn't work

### Expected Behavior

Tree should be updateable and interactive after an update. I would also expect that the open state is kept when only part of the tree is changed (in the example one subtree is removed, the other persists) and a trackby function is given.

### Actual Behavior

Tree is closed and not interactive anymore.

### Environment

- Angular: 18/19
- CDK/Material: 18/19
- Browser(s): all
- Operating System (e.g. Windows, macOS, Ubuntu): windows

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 el comportamiento de Angular CDK Tree en torno a su función trackBy y las actualizaciones de datasource. Reproduce la secuencia changeTree y, después, sigue los puntos de entrada de CDK Tree implicados en la actualización de los datos y la conservación del estado de interacción. La tarea está terminada cuando el árbol sigue siendo interactivo después de una actualización y conserva el estado abierto de los subárboles que no han cambiado.

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.