react-magma
react-magma copied to clipboard
TreeView: Add ability to update selected items from outside the tree
Currently the preselectedItems TreeView prop only renders on initial load. We should support adopters updating the selected items directly through the data without manually clicking on the checkboxes.
Use Cases:
- Ability to clear all selected items at once (On multi-select treeviews, consider adding separate "select all" or "unselect all" controls.)
- For multi select, ability to deselect a selected item by clicking on a tag (this is a common use case for filtering)
- QUESTION, For single select, do we want to support this or always force an item to be selected??
Cases to consider:
- If a child item is deselected, all the parents need to update
- If a parent item is deselected, all the children item need to update
- If a parent AND child item is deselected, both the parents and children need to update
- If an item is collapsed and selected, it should update appropriately
- If an item is expanded and selected, it should update appropriately
- onSelectedChange should continue to only get called once
- Should not affect
off
Slightly unrelated but another important addition for TreeView:
- Return itemId on onExpandedChange:
onExpandedChange?: (event: React.SyntheticEvent, itemId: string) => void;
Some work for this was started on https://github.com/cengage/react-magma/tree/feat/tree-view-pt7