-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Comments
@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. |
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. |
@sdpollack Yes, we definitely offload some of the work on your side. |
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. |
Any updates on this? Would be nice to automatically expand all treeview items |
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:
The text was updated successfully, but these errors were encountered: