考虑 withChildren 的情况

This commit is contained in:
2betop 2021-02-05 16:23:57 +08:00
parent 0b69f5ed1b
commit 2975f1f0b2

View File

@ -294,12 +294,14 @@ export class TreeSelector extends React.Component<
if (
parent.children.every((child: any) => ~value.indexOf(child))
) {
parent.children.forEach((child: any) => {
const index = value.indexOf(child);
if (~index) {
value.splice(index, 1);
}
});
if (!props.withChildren) {
parent.children.forEach((child: any) => {
const index = value.indexOf(child);
if (~index) {
value.splice(index, 1);
}
});
}
value.push(parent);
toCheck = parent;
continue;