patternfly-bootstrap-treeview icon indicating copy to clipboard operation
patternfly-bootstrap-treeview copied to clipboard

Method checkNode doesn't restore partially-checked parents.

Open marcodelpercio opened this issue 7 years ago • 2 comments

Hi,

I just found an issue when trying to programmatically check nodes via the checkNode method. Apparently the method passes the checked status onto the node's children however it doesn't set the partially-checked status on its parents when not all the siblings are checked. Take a look at the screenshot below. This is the result I'm getting with:

jQuery("#outfitsProductsTree").treeview('checkNode', [nodes2Check, { silent: false } ]);

(hierarchicalCheck: true) usingchecknode as you can see the parent(s) of the 3 nodes I checked should have the partially-checked status yet they don't. I digged a bit into the code and I found a workaround by using the toggleNodeChecked method instead. For some reason this method correctly sets the partially-checked status on the parents. So if I invoke:

jQuery("#outfitsProductsTree").treeview('toggleNodeChecked', [nodes2Check, { silent: false } ]);

with the very same nodes (nodes2Check) (and obviously hierarchicalCheck: true) I get the correct result: usingtogglenodechecked Sorry I'm not sure how to fix it properly otherwise I'd have forked straight away. Furthermore I'm still "forced" to use an old version due to Issue no.41

I hope the workaround helps for the time being

marcodelpercio avatar Jun 27 '17 10:06 marcodelpercio

Hi, could you please verify with the latest version and if it's still happening please provide a fiddle. Thanks

skateman avatar Jul 31 '17 07:07 skateman

This is still happening. The necessary code is only inside the toggleChecked function: https://github.com/patternfly/patternfly-bootstrap-treeview/blob/master/src/js/bootstrap-treeview.js#L725

vzlatkin avatar Jan 08 '18 03:01 vzlatkin