vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.15k stars 1.38k forks source link

Inconsistent Behaviour of Undetermined State With Search Term #1983

Closed hadiwina closed 6 years ago

hadiwina commented 6 years ago

Hi!

Thanks for the hard work for this library!

I'm noticing an inconsistency in how a parent node is undetermined when both plugins ['checkbox', 'search'] are enabled.

When search term is provided, the tree hides the result correctly. However, clicking a parent whose some children is hidden makes that parent node selected. However, if I go from the other direction by selecting all the children of the parent whose some children is hidden, the parent is now undetermined.

Example of selecting upward.. upward

Example of selecting parent with hidden children.. downward

I think the confusion is that with hidden children, the state of a parent could be different depending on where you start selecting node first.

Do you have any thoughts on this?

lokeshsoni04 commented 6 years ago

Even I am having same issue

vakata commented 6 years ago

three_state works on the actual tree model, not on what you see. The nodes are still there (even if filtered out). If you have a parent with three child nodes and perform a search which hides one of those nodes, then selecting the two visible children still means that the parent is in undetermined state, as the third (CURRENTLY not visible child) is not selected.

Working from the other direction - selecting a parent selects all its children, even the hidden ones. If you want to change this behavior - take a look at this option: https://www.jstree.com/api/#/?q=cascade&f=$.jstree.defaults.checkbox.cascade_to_hidden

I hope this clears things a bit. Let me know if I can help further.

hadiwina commented 6 years ago

@vakata .. Hm. I see. Let me play around with that option a little bit more. I think I did try that and wasn't taking any effect. It was possible I used it incorrectly. Will report back. :)

Thanks a lot!

hadiwina commented 6 years ago

@vakata this option seems to work well. Thanks a lot for the help!