[TreeView] parent/child selectionBehavior
Provide a general summary of the feature here
I'm having a hard time implementing parent/child selection behavior in a TreeView. Specifically I'd like to be able to:
- select a parent and all of its children by selecting the parent checkbox.
- Unselecting a child while siblings are still selected switches the parent to indeterminate
- Unselecting the last child unselects the parent
- Should
onSelectionChangeinclude parent keys? In my case parents are basically just meant for grouping and in my external state I'm only interested in knowing which child items are selected.
๐ค Expected Behavior?
Support intuitive parent/child selection.
๐ฏ Current Behavior
Parents and children feel unrelated
๐ Possible Solution
No response
๐ฆ Context
I'm building this sort of CheckboxTree, which I suspect is a pretty common usage of Tree.
๐ป Examples
No response
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response
We'll be most likely looking to add this behavior to our implementation of RSP TreeView (and by extension RAC Tree) since it is supported by Spectrum Design, but I'm unsure when that work will be slated to be picked up. As for the implementation, I imagine SelectionManager would need to be updated to have a mode where toggling the selection of a node that has children would also select the children. As for onSelectionChange including the parent keys I imagine we would still want to include them for use cases do care about parent key selection as well but maybe that could be changed via a option as well.
@nathanforce were you able to find an implementation to this? I am trying to do something similar as well.
Yes, but for now we've had to patch the package and manipulate the collection directly.