angular / angular/components

bug(MatTree): expandAll() only expand the first level

Abierto
#30,445 2 comentarios 2 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.x

### Description

Reopen Issue #29865. [CDK/Material: 19.1.2](https://github.com/angular/components/blob/19.1.2/src/cdk/tree/tree.ts) contains a fix [#30226](https://github.com/angular/components/pull/30226) but the issue still persists.

The method expandAll() of MatTree expands only the first level of a deeply nested tree. On deprecated MatTreeControl, the same method was able to expand the entire tree without problems.

WORKAROUND:

```typescript
this.dataSource.forEach(node => this.tree.expandDescendants(node));
```

### Reproduction

StackBlitz link:

* Flat nodes: https://stackblitz.com/edit/jfoxsvj4?file=src%2Fexample%2Ftree-flat-child-accessor-overview-example.ts
* Nested nodes: https://stackblitz.com/edit/r8azqcn7?file=src%2Fexample%2Ftree-nested-child-accessor-overview-example.ts

Steps to reproduce:

1. Open the demos.
2. The tree is partially expanded
3. Edit the demo and enable the workaround on the ngAfterViewInit callback.
4. The tree is now fully expanded.

### Expected Behavior

MatTree's expandAll() should expand all nodes.

### Actual Behavior

Only the first level nodes are expanded.

### Environment

- Angular: 19.1.2
- CDK/Material: 19.1.2
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Empieza por src/cdk/tree/tree.ts en expandAll() y compara después su comportamiento con expandDescendants() y las reproducciones enlazadas de StackBlitz, plana y anidada. Verifica el cambio con ambas demos y confirma que expandAll() expande todos los nodos de un árbol profundamente anidado, no solo el primer nivel.

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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.