angular / angular/components

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

オープン
#30,551 コメント 2 件 リアクション 0 件 担当者 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.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

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

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

調査の方向性

リンクされた StackBlitz でリグレッションを再現し、まず src/example/tree-nested-child-accessor-overview-example.ts とその HTML template を確認します。次に、“nodes is not iterable” エラーが発生する tree component のソースを調査します。動的に追加された子データが、エラーや live reload を必要とせずに tree に表示されれば完了です。

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

評価

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

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

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