fluentui-blazor icon indicating copy to clipboard operation
fluentui-blazor copied to clipboard

[dev-v5] feat: 🌲 TreeView: Support Recursive and Indeterminate Selection in Multiple Selection Mode

Open AClerbois opened this issue 7 months ago • 3 comments

🙋 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

AClerbois avatar May 24 '25 06:05 AClerbois

The new behavior, can be enabled via an option.

AClerbois avatar May 24 '25 06:05 AClerbois

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?

dvoituron avatar May 24 '25 06:05 dvoituron

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.

vnbaaij avatar May 24 '25 07:05 vnbaaij