bug(MatTree): expandAll() only expand the first level
- Lingua principale
- TypeScript
- Stelle
- 25k
- Fork
- 6.8k
- Merge medio
- 1g 8h
- PR unite (30g)
- 91
Descrizione
### 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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da src/cdk/tree/tree.ts in expandAll(), quindi confronta il suo comportamento con expandDescendants() e con le riproduzioni StackBlitz collegate, piatta e annidata. Verifica la modifica con entrambe le demo e conferma che expandAll() espanda ogni nodo di un albero profondamente annidato, non solo il primo livello.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100