react-checkbox-tree icon indicating copy to clipboard operation
react-checkbox-tree copied to clipboard

Ability to set indeterminate state for checkbox

Open malhotraashna opened this issue 6 years ago • 4 comments

It would be very useful to have the capability which lets you explicitly define if we want a node's checkbox to be in indeterminate state.

Something like: { value:'', label:'', children:[], checked: 'indeterminate/true/false' }

Or is there any way to accomplish this, if I am missing?

malhotraashna avatar Feb 20 '19 11:02 malhotraashna

Currently this is not possible, but it may very well be supported in the future.

jakezatecky avatar Feb 22 '19 13:02 jakezatecky

That'd be great!

For anyone following this, to implement it with the currently available options, I:

  1. Assigned a class(say, partially-selected-tree-node) to the node whose checkbox I wanted to be in indeterminate state.
  2. Set the indeterminate state for the checkbox to be true in componentDidMount and componentDidUpdate, whose parent has the assigned class.

const a = document.querySelectorAll('li.partially-selected-tree-node input[type="checkbox"]'); for (let i = 0; i < a.length; i += 1) { a[i].indeterminate = true; }

I don't know if it is acceptable to use javascript's query selector to achieve this but couldn't find any other way. Would really appreciate if there is a better way and I am missing it!

Any suggestions on this @jakezatecky ?

malhotraashna avatar Mar 01 '19 07:03 malhotraashna

This may (emphasis may) be supported in a v2.0 release. The query selector approach can work though I have no reasonable alternatives until this is better supported by the component.

jakezatecky avatar May 24 '19 06:05 jakezatecky

Hi @jakezatecky, is there any update on this?

Thanks in advance.

nolatone avatar Nov 01 '22 15:11 nolatone