[dev-v5] feat: 🌲 TreeView: Support Recursive and Indeterminate Selection in Multiple Selection Mode
🙋 Feature Request
When the Multiple Selection mode is activated in the TreeView component, selecting a parent node should recursively select its child nodes and reflect the children's state in the parent's checkbox.
🤔 Expected Behavior
Selecting (checking) a parent node automatically selects all its child nodes recursively.
A parent node becomes checked if all its child nodes are selected.
A parent node becomes indeterminate if only some of its child nodes are selected.
😯 Current Behavior
Currently, selecting a parent node does not automatically select its child nodes. Additionally, parent nodes do not visually reflect the selection state of their children.
💁 Possible Solution
Implement recursive selection logic:
On parent node selection, propagate the selection to all child nodes.
On selection change of a child node, update parent nodes to reflect checked or indeterminate states based on child selections.
🔦 Context
The current behavior can be confusing for users as it does not align with common UI practices for hierarchical selection. Providing recursive and reflective selections improves intuitiveness and usability.
💻 Examples
Example scenario:
✅ Parent Node (checked) ....✅ Child Node 1 ....✅ Child Node 2
➖ Parent Node (indeterminate) .... ✅ Child Node 1 .... ☐ Child Node 2
The new behavior, can be enabled via an option.
It's not always useful. In some cases, we want independent elements.
You need a parameter to have both possibilities. That's why SelectionMode is an enum and not a boolean. So, with a new enum like MultipleRecursive, why not?
I think as well it would be good to support that behavior (next to what we already have). Agreed that it should be opt-in.