Closed Ctrlmonster closed 3 months ago
@mellis481 can you read through this and give your feeling on it?
@Ctrlmonster how would your proposed prop work when someone closes a branch? Would this prop only be for on first render? If yes, then I think we can open this issue for “help requested” after we rename the prop to be expandAllOnFirstRender. If the answer is no (ie you want everything always open) then I think that would introduce serious accessibility issues (like why would we allow nodes to be closed if it just reopens), then I think this is out of scope for this library given that our goal is primarily to be accessible. We wouldn’t want to lie to screen readers and let them think that they can fold a branch.
@Ctrlmonster Using the defaultExpandedIds
property works for me using your code where you simply map the id
prop of your data. Can you confirm the items in your data
array have an id
prop?
@Ctrlmonster Using the
defaultExpandedIds
property works for me using your code where you simply map theid
prop of your data. Can you confirm the items in yourdata
array have anid
prop?
They definitely do. Are there any requirements on the ids or can they just be completely random? If there aren't, this seems to be a problem with my code. But it's really weird as the data gets created inside the component and the ids get mapped a few loc below, not sure how they can't be fresh if both get re-created on component re-render.
@dgreene1 That's a good point, it would really only make sense on the first render (and that's what I need as well), but if expandedIds={data.map(({id}) => id)}
should work then I'm not sure if an extra prop is needed.
Okay then we’ll close the issue for now.
The problem Right now if you have a dynamically changing tree (i.e. inside an editor) where the tree-view often gets re-created from scatch, it becomes unreasonably cumbersome to tell the view to just open all tabs by default (i.e. to view the full content of the new tree). The reason for this is mainly that there is an error thrown if you pass an id that the tree doesn't know about, i.e.
Node with id=MY_ID doesn't exist in the tree
,Describe the solution you'd like Either provide a new
expandAll
prop or allow the user to pass another value toexpandedIds
that signals the intent of opening up all tabs (i.e. null, true or some symbol)Describe alternatives you've considered
Attempt 1: dynamically get all ids:
Attempt 2: pass all possible future ids (only limited usecase, would theoretically work in my case)