Skip to content

Commit

Permalink
fix(Tree): not calculate all checked value when checkedStrategy is ch…
Browse files Browse the repository at this point in the history
  • Loading branch information
lakerswgq authored Jun 21, 2022
1 parent a52b952 commit 5e2c577
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/tree/view/tree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const getCheckedKeys = (props, willReceiveProps, _k2n, _p2n) => {
checkedKeys = [];
}

const { checkStrictly } = props; // TODO TEST
const { checkStrictly, checkedStrategy } = props; // TODO TEST
if (checkStrictly) {
if (isPlainObject(checkedKeys)) {
const { checked, indeterminate } = checkedKeys;
Expand All @@ -142,7 +142,11 @@ const getCheckedKeys = (props, willReceiveProps, _k2n, _p2n) => {

checkedKeys = checkedKeys.filter(key => !!_k2n[key]);
} else {
checkedKeys = getAllCheckedKeys(checkedKeys, _k2n, _p2n);
if (checkedStrategy !== 'child') {
// checkedStrategy 为 child 时不需要计算所有可选值
checkedKeys = getAllCheckedKeys(checkedKeys, _k2n, _p2n);
}

checkedKeys = checkedKeys.filter(key => !!_k2n[key]);

indeterminateKeys = getIndeterminateKeys(checkedKeys, props.checkStrictly, _k2n, _p2n);
Expand Down Expand Up @@ -889,6 +893,7 @@ class Tree extends Component {
}

let newCheckedKeys;

switch (checkedStrategy) {
case 'parent':
newCheckedKeys = filterChildKey(checkedKeys, _k2n, _p2n);
Expand Down

0 comments on commit 5e2c577

Please sign in to comment.