Open nathanforce opened 5 months ago
Can you try accessing the TreeStateContext from within UNSTABLE_TreeItemContent/the checkbox instead? I imagine you should be able to override the onChange
for the Checkbox at that point to reach your desired behavior then. However, if you want interactions on the Tree row itself to also follow the same behavior, that might be a bit trickier, might have to drop down to the hooks level to fully customize that behavior
It looks like I'm able to access the state via context from within my Checkbox component. Thanks!
Do you know if there is appetite to include this parent selection behavior out of the box? It feels pretty standard for a tree component and might be easier implemented internally.
Yeah, I think supporting that kind of parent selection behavior makes sense, there is work slated for having the parent be in a "indeterminate" state if a subset of its children are selected already so something like that seems like a natural progression. Would probably become an option on the Tree itself. Would you like to modify this issue to reflect this parent selection instead? Would be good to have this publicly tracked as well
Provide a general summary of the feature here
I was surprised to see that reading
UNSTABLE_TreeStateContext
from within myTreeItem
component does not let me access the tree state. I'm guessing this has something to do with the collection building, but not sure how to best proceed. My ultimate intent is to allow parent checkboxes to toggle all of their children, if that helps.๐ค Expected Behavior?
const state = useContext(UNSTABLE_TreeStateContext);
should return the state, allowing me to leverage theselectionManager
.๐ฏ Current Behavior
const state = useContext(UNSTABLE_TreeStateContext);
returnsnull
๐ Possible Solution
No response
๐ฆ Context
Parent checkbox selection
๐ป Examples
No response
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response