angular / angular/components

bug(MatTree): expandAll() only expand the first level

Đang mở
#30,445 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
area: cdk/tree P3
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ả

### Is this a regression?

- [x] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

17.x

### Description

Reopen Issue #29865. [CDK/Material: 19.1.2](https://github.com/angular/components/blob/19.1.2/src/cdk/tree/tree.ts) contains a fix [#30226](https://github.com/angular/components/pull/30226) but the issue still persists.

The method expandAll() of MatTree expands only the first level of a deeply nested tree. On deprecated MatTreeControl, the same method was able to expand the entire tree without problems.

WORKAROUND:

```typescript
this.dataSource.forEach(node => this.tree.expandDescendants(node));
```

### Reproduction

StackBlitz link:

* Flat nodes: https://stackblitz.com/edit/jfoxsvj4?file=src%2Fexample%2Ftree-flat-child-accessor-overview-example.ts
* Nested nodes: https://stackblitz.com/edit/r8azqcn7?file=src%2Fexample%2Ftree-nested-child-accessor-overview-example.ts

Steps to reproduce:

1. Open the demos.
2. The tree is partially expanded
3. Edit the demo and enable the workaround on the ngAfterViewInit callback.
4. The tree is now fully expanded.

### Expected Behavior

MatTree's expandAll() should expand all nodes.

### Actual Behavior

Only the first level nodes are expanded.

### Environment

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

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 src/cdk/tree/tree.ts tại expandAll(), sau đó so sánh hành vi của nó với expandDescendants() và các bản tái hiện StackBlitz phẳng và lồng nhau được liên kết. Xác minh thay đổi bằng cả hai bản demo và xác nhận rằng expandAll() mở rộng mọi nút trong một cây lồng nhau sâu, không chỉ ở cấp đầu tiên.

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
42/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.