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

Prevent all node to be checked when filtering tree

Open dpellier opened this issue 4 years ago • 4 comments

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 avatar Apr 27 '20 09:04 dpellier

@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

MaxwellKendall avatar May 04 '20 19:05 MaxwellKendall

yess, so pumped there's a fix already in place for this one!

olessiap avatar May 05 '20 15:05 olessiap

@jakezatecky this issue still persists. Merge the PR?

vjr12 avatar Jul 23 '20 05:07 vjr12

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.

jalalazimi avatar Aug 13 '20 08:08 jalalazimi