adobe / adobe/react-spectrum

[TreeView] parent/child selectionBehavior

Open
#6,589 5 comments 4 reactions 0 assignees View on GitHub
enhancement TreeView
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### 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:

1. select a parent and all of its children by selecting the parent checkbox.
2. Unselecting a child while siblings are still selected switches the parent to indeterminate
3. Unselecting the last child unselects the parent
4. Should `onSelectionChange` include 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.

image

### 💻 Examples

_No response_

### 🧢 Your Company/Team

_No response_

### 🕷 Tracking Issue

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.