react-checkbox-tree
react-checkbox-tree copied to clipboard
Prevent all node to be checked when filtering tree
See https://github.com/jakezatecky/react-checkbox-tree/issues/196
There is a strange behaviour for the leaf node.
On first render, there are correctly set as a leaf with a children: undefined
property.
But after filtering, they got a children: []
prop.
Thus the isLeaf
value is set wrong (which you can see on the filter example, when filtering the leaf suddenly get a directory icon).
And it also changes the returned values of the checked function, checking everything (even if the actual checked state is still untouched).
@dpellier @jakezatecky I am also having this bug.
I've confirmed this branch fixes the issue. 🙏
Opened a PR on your branch to update breaking tests: https://github.com/dpellier/react-checkbox-tree/pull/2
yess, so pumped there's a fix already in place for this one!
@jakezatecky this issue still persists. Merge the PR?
Hi friends, Please check out #217 .
Replace filtered.push({ ...node, children });
with filtered.push({...node, ...children.length && {children}});
. Temporary you can use this solution to fix the above issue.