Skip to content

cdkTreeNodePadding level is ignored #16338

Closed
@allanbond

Description

@allanbond

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/angular-de5mhj

Steps to reproduce:

  1. Create a cdk-tree
  2. set the value of cdkTreeNodePadding to "0" for the cdk-tree-node

<cdk-tree-node *cdkTreeNodeDef="let node" cdkTreeNodePadding="0">

Expected Behavior

What behavior were you expecting to see?

cdkTreeNodePadding should honor the level that is passed as its value. When the passed level is '0', the padding for the cdkTreeNode should be set to 0 * indent pixels.

This line contains a comparison that causes the issue when the level is set to '0'

const level = this._level || nodeLevel;

Instead, it should check if this._level is explicitly undefined or null.

const level = (this._level === null || this._level === undefined) || nodeLevel;

Actual Behavior

What behavior did you actually see?

The passed level ('0') is ignored and the padding is set to level * indent pixels. All values other than '0' work fine.

Environment

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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions