angular / angular/components

bug(MatTree): padding is not recomputed when moving a node inside/outside an expandable node

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

説明

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

As `TreeControl` is deprecated, I started migrating to the latest API using `childrenAccessor`. So far so good, except for one case not working any more.

I'm using `matTreeNodePadding` and `matTreeNodePaddingIndent` on ``. When I move a node inside/outside of an expandable node, padding is not recomputed as-is.

Expanding/collapsing the parent node in which the node was moved, will recompute its padding though.

### Reproduction

Minimal example on [Stackblitz](https://stackblitz.com/~/github.com/poirierlouis/ng-issue-29959).

Steps to reproduce:
1. Open link
2. Open preview in a new tab
3. Open both folders (`/` and `home`)
4. Follow instructions to move a node outside its parent node

`dataSource` is updated with a new array, using the same items. Can it be a source of error? Should the entire tree be cloned somehow, to trigger changes detection down to padding computation?

### Expected Behavior

When a node is moved inside/outside of an expandable node (level is changed), padding should be recomputed based on the new level of the node.

### Actual Behavior

Padding of the node is not updated when moving the node inside/outside of an expandable node.

### Environment

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

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

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

調査の方向性

リンクされた StackBlitz の再現手順から始め、childrenAccessor を使用してノードを展開可能な親の間で移動したときの matTreeNodePadding の動作を調査します。ノードのレベルがどのように変化し、padding がどのように再計算されるかを追跡し、その後、親を展開または折りたたむことなくノードを移動するとその padding が更新されることを確認します。

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

評価

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

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

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