angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.39k stars 6.76k forks source link

Mat Tree ExpandAll doesn't work #12170

Closed lemoinet closed 1 year ago

lemoinet commented 6 years ago

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Collapse All/Expand All on Nested Tree Control

What is the current behavior?

The expandAll() in nested-tree-control.ts function doesn't work. this.dataNodes is undefined

What are the steps to reproduce?

https://angular-7dvgw3.stackblitz.io

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular/material 6.3.3

pedrus16 commented 6 years ago

I have the same problem. I simply added a call to expandAll() to the example from the doc: https://ynxoygyknxk.angular.stackblitz.io/

See the console for the error.

pedrus16 commented 6 years ago

I checked the source code and judging from the test file you have to set the dataNodes value yourself.

Notice the treeControl.dataNodes = nodes; before calling expandAll() https://github.com/angular/material2/blob/adda21f5c2d47ce12620567cda9494e68d092339/src/cdk/tree/control/nested-tree-control.spec.ts#L74-L93

sarora2073 commented 5 years ago

Ran into the same issue. From testing it does appear there is a dependency on expandAll /collapseAll /expand etc. relying treeControl.dataNodes field. When I look at the examples here: [https://material.angular.io/components/tree/examples] I notice that the first example populates dataNodes but the others don't.

That said, this case can probably be closed as a duplicate of the issue noted here : https://github.com/angular/material2/issues/12469. Not sure if ultimately the problem is just documentation OR if there is a "bug".

angular-automatic-lock-bot[bot] commented 1 year ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.