angular / angular/components

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

オープン
#30,445 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る
area: cdk/tree P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

### 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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/cdk/tree/tree.ts の expandAll() から始め、expandDescendants() およびリンクされたフラットとネストされた StackBlitz の再現例と動作を比較します。両方のデモで変更を検証し、expandAll() が深くネストされたツリー内の最初のレベルだけでなく、すべてのノードを展開することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。