react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

Selecting parent node checkbox as intermediate

Open anupsingh244 opened this issue 2 years ago • 1 comments

I want to make parent node checkbox as intermediate selection on the selection of child nodes? I dont see any way to do it. can you please help me with that.

anupsingh244 avatar Aug 23 '23 13:08 anupsingh244

I would imagine in your node renderer, you could run a check that looks through all the children in the node to see if they are selected. If some but not all are selected, you could add a class to the component that marks it as intermediate.

const allSelected = node.children.every((child) => child.isSelected)
const someSelected = node.children.some((child) => child.isSelected)

if (someSelected && !allSelected) {
  // Add your intermediate style
}

If this works for you, will you please close the issue. Thank you and good luck!

jameskerr avatar Aug 28 '23 17:08 jameskerr