components icon indicating copy to clipboard operation
components copied to clipboard

bug(mat-nested-tree-node): Indent increases by level

Open tonyhook opened this issue 1 year ago • 4 comments

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

When we use matTreeNodePadding on , the indent should always be 40px because the div element is embedded in its parent div element. It should be different with .

Reproduction

StackBlitz link: https://stackblitz.com/edit/components-issue-starter-jotfnbjm Steps to reproduce:

  1. click apple
  2. click pie

Expected Behavior

The indent should keep 40px for all nested tree nodes.

Actual Behavior

The indent is 40px for level 1, 80px for level 2 ...

Environment

  • Angular: 19.2.4
  • CDK/Material: 19.2.7
  • Browser(s): Chrome, Safari
  • Operating System (e.g. Windows, macOS, Ubuntu): MacOS

tonyhook avatar Apr 03 '25 10:04 tonyhook

I suppose the matTreeNodePadding/cdkTreeNodePadding was not designed to work with nested nodes, since they are already displayed in a hierarchical way you can simply add padding like this and it should work fine.

mat-nested-tree-node {
  padding-left:40px;
}

but i agree it's confusing, and one would expect the directive to just work regardless.

SergheiGurgurov avatar Apr 19 '25 11:04 SergheiGurgurov

actually i found in the material docs it's explicitly mentioned that the matTreeNodePadding is only for flat trees

Image

SergheiGurgurov avatar Apr 19 '25 12:04 SergheiGurgurov

Sounds like this is working as expected. Closing.

crisbeto avatar May 02 '25 12:05 crisbeto

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.