angular / angular/components

[mat-tree] Nodes are not updated correctly with trackyBy function set

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

説明

#### Bug, feature request, or proposal:
MatTree does not reflect the changes to the nodes if trackBy function is used. For example, I have several items with trackBy function pointing to their "id" property. If I provide a new array with completely same ids, but with changes to some of the other properties, change detection does not occur.

#### What is the expected behavior?
When used with trackBy function MatTree should trigger change detection on all nodes, just like ngFor with trackBy does.

#### What is the current behavior?
No changes are detected therefore data is not updated in template.

#### What are the steps to reproduce?
https://stackblitz.com/edit/angular-material2-issue-z8ubtt

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Latest versions of Angular, Material (check StackBlitz). Any browser.

#### Is there anything else we should know?
Same [issue](https://github.com/angular/material2/issues/7877) was observed last year with MatTable.

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

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

調査の方向性

リンクされている StackBlitz の再現コードから始め、trackBy 関数を使用した場合の MatTree と ngFor の動作を比較します。関連する issue #7877 を確認し、ノード配列を置き換えると、追跡対象のノードを保持したまま、レンダリングされたテンプレート内の変更されたプロパティが更新されることを検証します。

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

評価

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

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

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