angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.37k stars 6.75k forks source link

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

Open poirierlouis opened 1 week ago

poirierlouis commented 1 week ago

Is this a regression?

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 <mat-tree-node>. 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.

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

wagnermaciel commented 5 days ago

Hi @poirierlouis, would you be able to provide a stackblitz example of this issue? It is difficult to debug this only from the code & video you shared.

poirierlouis commented 5 days ago

Hi @wagnermaciel thanks for the quick answer. Yes I'll try and write an example to reproduce this issue.

poirierlouis commented 5 days ago

@wagnermaciel , I could definitely reproduce this issue, see Stackblitz example. I also updated the ticket.