angular / angular/components

Mat-tree :Tree with nested nodes adding child doesnt update the view.

Open
#11,381 59 comments 52 reactions 0 assignees View on GitHub
area: material/tree P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Bug:

When using mat-nested-tree-node with a nested datasource if you add a child to an existing parent it does not update the view.

#### What is the expected behavior?
Well if you change or add a child to an existing parent in the nestedDataSource it should update the tree.

#### What is the current behavior?
It does not update the view when adding a child to an existing parent to the nestedDataStructure .

#### What is the use-case or motivation for changing an existing behavior?

Well in my case i need to update the view since i add/delete nodes .

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
versions 6 (Chrome ver 66)

#### Is there anything else we should know?
I found an workaround:
refreshTree(){
let _data = this.nestedDataSource.data;
this.nestedDataSource.data = null;
this.nestedDataSource.data = _data;
}

Contributor guide

Open the contributing guide

Research direction

Start with mat-nested-tree-node and the nestedDataSource update path described in the issue, reproducing the problem by adding a child to an existing parent. Compare the view with the documented refreshTree workaround; done means the nested tree reflects added or deleted nodes without that workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.