Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
BeniFreitag opened this issue Feb 4, 2025 · 2 comments
Open
1 task done

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

BeniFreitag opened this issue Feb 4, 2025 · 2 comments
Labels
needs triage This issue needs to be triaged by the team

Comments

@BeniFreitag
Copy link

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

17.x

Description

Reopen Issue #29865. CDK/Material: 19.1.2 contains a fix #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:

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

Reproduction

StackBlitz link:

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
@BeniFreitag BeniFreitag added the needs triage This issue needs to be triaged by the team label Feb 4, 2025
@JonasMa
Copy link

JonasMa commented Feb 6, 2025

I'm having the same problem. Interestingly it works when calling it after a timeout of > 200ms in the ngAfterViewInit.

I'm using Angular 19.1.4 and Material 19.1.2.

@WwwHhhYran
Copy link

I'm having the same problem, and the previous bugfix(#30226 ) has not solved this issue. Is there anyone out there to fix this please?

Also, I can't understand why TreeControl will be deprecated, deprecating TreeControl makes it impossible to control the state of the tree before initializing the view, and I think integrating all the methods from TreeControl into Tree will make custom components less flexible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

3 participants