angular / angular/components

bug(mat-tree): How to control a tree expansion state if treeControl is deprecated?

Open
#29,856 3 comments 14 reactions 0 assignees View on GitHub
area: material/tree docs P2
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### 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

mat-tree has [treeControl] (and many other related classes and parts) deprecated. How are we supposed to control the expansion state of the tree from our component if there is to no treeControl? Was this an oversight in documentation? even your own examples in the documentation use the deprecated features!

### Reproduction

N/A

### Expected Behavior

I expect deprecated features / componenets / classes to have a new replacement or documentation on HOW to use the new way of doing things that accounts for the deprecated feature.

### Actual Behavior

In this case (CdkTree):

```
/**
* The tree controller
*
* @deprecated Use one of `levelAccessor` or `childrenAccessor` instead. To be removed in a
* future version.
* @breaking-change 21.0.0
*/
treeControl?: TreeControl;
```
levelAccessor and childrenAccessor have nothing to do with expansion state. Please tell us what we are supposed to use in place of treeControl!

### Environment

- Angular: 18.2.2
- CDK/Material: 18.2.2
- Browser(s): N/A
- Operating System (e.g. Windows, macOS, Ubuntu): N/A

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the CdkTree API shown in the issue and the existing mat-tree documentation examples that use treeControl. Determine how expansion state should be controlled with the non-deprecated API, then update the guidance and examples so the replacement is explicit and the documented approach is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
documentation, frontend
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.