angular / angular/components

Nested tree does not correctly update

Đang mở
#13,028 6 bình luận 5 reaction 0 người được giao Xem trên GitHub
area: cdk/tree G P2
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

#### Bug, feature request, or proposal:
Bug

#### What is the expected behavior?
Adding a node to the tree and firing a change event should update the tree

#### What is the current behavior?
The tree does not update

#### What are the steps to reproduce?
[StackBlitz link](https://stackblitz.com/edit/angular-kowmq5-pmrkej?file=app/tree-nested-overview-example.ts) line 123

Open the example, and within 10 seconds expand the Applications node.

The following code should add a node, and the node should be displayed:
```ts
database.dataChange.subscribe(data => {
this.nestedDataSource.data = data;
console.log(data); // <-- see screenshot below
});
console.log('Please expand the Applications node within 10 seconds');
setTimeout(() => {
const data = this.nestedDataSource.data;
for (let node of data) {
if (node.filename == "Applications") {
const newnode = new FileNode();
newnode.filename = "ghost";
newnode.type = "gs";
node.children.push(newnode);
console.log("Added component");
}
}
// force change
console.log("Forcing change");
database.dataChange.next(data); // <-- firing event here
}, 10000);
```
After ten seconds the console correctly logs the added component:

![image](https://user-images.githubusercontent.com/1256049/45224934-897b7c80-b2bb-11e8-8c22-c43f356211dc.png)

But the view does not update:

![image](https://user-images.githubusercontent.com/1256049/45224944-91d3b780-b2bb-11e8-9643-167c930d8114.png)

#### What is the use-case or motivation for changing an existing behavior?
I would expect the tree to mirror the underlying data model.

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
It happens on chrome, with the latest version of the library.

#### Is there anything else we should know?
Sorry I could not make the example autoexpand (please see #13027 on why)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với app/tree-nested-overview-example.ts ở dòng 123 và tái hiện vấn đề bằng cách mở rộng Applications trước khi bản cập nhật bị trì hoãn diễn ra. Theo dõi cách nestedDataSource.data và database.dataChange được xử lý sau khi nút con được thêm vào. Hoàn tất khi chế độ xem hiển thị nút ma mới lúc sự kiện thay đổi được phát ra.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.