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

[tree view] Provide prop so that all items are expanded by default #14509

Closed
1 task done
sdpollack opened this issue Oct 29, 2019 · 5 comments
Closed
1 task done

[tree view] Provide prop so that all items are expanded by default #14509

sdpollack opened this issue Oct 29, 2019 · 5 comments
Labels
component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! discussion

Comments

@sdpollack
Copy link

sdpollack commented Oct 29, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

I would appreciate an easier way to have all children expanded by default. Seems like the current 'defaultExpanded' property is misnamed. How about 'expandedItems'? Then 'defaultExpanded' would be available and could be implemented as the default 'true' or 'false' default expanded state for all child TreeItems.

If there is already a way to accomplish this, it should be better described in the documentation. I missed it.

Examples 🌈

Motivation 🔦

I've spend a great deal of time trying to get the defaultExpanded working as I need to show all items. This is a challenge since using useState in a recursive function appears to be problematic. I'm going to guess others need the TreeView to start fully expanded as I do. The current implementation it starts fully collapsed.

Search keywords:

@oliviertassinari oliviertassinari added the component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! label Oct 29, 2019
@oliviertassinari
Copy link
Member

@sdpollack Thank you for taking the time to fill this issue. I don't think that we should introduce an option to expand all the tree items. In mui/material-ui#17705, we explore how to make the TreeView expended states controllable as well as having the TreeItem behing able to override this state. The capability to control the expended state on the tree item would match https://github.com/frontend-collective/react-sortable-tree#props's solution.

@sdpollack
Copy link
Author

Thank you for your fast response. I've reviewed the comments in 17705 and I don't believe they apply to me. I have no need for controlling the expanded state beyond the base functionality of the component after it is initially displayed. I'm looking for is an easier way to initiate the tree in an expanded state. The defaultExpanded prop is suboptimal because in order to create the array of expanded nodes, I've already had recurse through the tree. I've had to get creative to make sure the explosion of the TreeItems happens after the creation of the defaultExpanded array. My initial implementations delivered the defaultExpanded array after the TreeView was rendered so it had no effect.

@oliviertassinari
Copy link
Member

@sdpollack Yes, we definitely offload some of the work on your side.

@JokerMartini
Copy link

I can't believe is 2022 and the MUI still does not provide a way to have the treeview items expanded by default or successfully draw treeview lines appropriately.

@joshmcqueen
Copy link

Any updates on this? Would be nice to automatically expand all treeview items

@oliviertassinari oliviertassinari transferred this issue from mui/material-ui Sep 5, 2024
@oliviertassinari oliviertassinari changed the title TreeView: Provide prop so that all items are expanded by default [tree view] Provide prop so that all items are expanded by default Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! discussion
Projects
None yet
Development

No branches or pull requests

4 participants