From 0903e96c6b4e84d0c21123415fe0b9a8f31ab2ca Mon Sep 17 00:00:00 2001 From: chenxian Date: Tue, 7 Jun 2022 17:08:36 +0800 Subject: [PATCH 1/4] fix(TreeSelect): calculate all checked value only when treeCheckedStrategy=all, close#3936 --- src/tree-select/tree-select.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tree-select/tree-select.jsx b/src/tree-select/tree-select.jsx index 5193607122..502b03b71c 100644 --- a/src/tree-select/tree-select.jsx +++ b/src/tree-select/tree-select.jsx @@ -427,7 +427,6 @@ class TreeSelect extends Component { const nonExistentValueKeys = this.getNonExistentValueKeys(); let keys = this.getKeysByValue(value); - keys = getAllCheckedKeys(keys, this.state._k2n, this.state._p2n); switch (treeCheckedStrategy) { case 'parent': @@ -437,6 +436,8 @@ class TreeSelect extends Component { keys = filterParentKey(keys, this.state._k2n, this.state._p2n); break; default: + // calculate all checked value only when treeCheckedStrategy=all, close #3936 + keys = getAllCheckedKeys(keys, this.state._k2n, this.state._p2n); break; } From 869f863cdb105388ca73e67a8c2bd04efb4e2935 Mon Sep 17 00:00:00 2001 From: chenxian Date: Tue, 7 Jun 2022 17:08:36 +0800 Subject: [PATCH 2/4] fix(TreeSelect): calculate all checked value only when treeCheckedStrategy=all, close#3936 --- src/tree-select/tree-select.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tree-select/tree-select.jsx b/src/tree-select/tree-select.jsx index 5193607122..502b03b71c 100644 --- a/src/tree-select/tree-select.jsx +++ b/src/tree-select/tree-select.jsx @@ -427,7 +427,6 @@ class TreeSelect extends Component { const nonExistentValueKeys = this.getNonExistentValueKeys(); let keys = this.getKeysByValue(value); - keys = getAllCheckedKeys(keys, this.state._k2n, this.state._p2n); switch (treeCheckedStrategy) { case 'parent': @@ -437,6 +436,8 @@ class TreeSelect extends Component { keys = filterParentKey(keys, this.state._k2n, this.state._p2n); break; default: + // calculate all checked value only when treeCheckedStrategy=all, close #3936 + keys = getAllCheckedKeys(keys, this.state._k2n, this.state._p2n); break; } From 9ed19af6995f2c39352c00c5de39d59b4f8207c4 Mon Sep 17 00:00:00 2001 From: chenxian Date: Thu, 9 Jun 2022 10:35:12 +0800 Subject: [PATCH 3/4] fix(TreeSelect): fix treeCheckedStrategy issue --- src/tree-select/tree-select.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tree-select/tree-select.jsx b/src/tree-select/tree-select.jsx index 502b03b71c..7a329240eb 100644 --- a/src/tree-select/tree-select.jsx +++ b/src/tree-select/tree-select.jsx @@ -428,6 +428,11 @@ class TreeSelect extends Component { let keys = this.getKeysByValue(value); + if (treeCheckedStrategy !== 'child') { + // there's no need to calculate all checked value when treeCheckedStrategy=child, close #3936 + keys = getAllCheckedKeys(keys, this.state._k2n, this.state._p2n); + } + switch (treeCheckedStrategy) { case 'parent': keys = filterChildKey(keys, this.state._k2n, this.state._p2n); @@ -436,8 +441,6 @@ class TreeSelect extends Component { keys = filterParentKey(keys, this.state._k2n, this.state._p2n); break; default: - // calculate all checked value only when treeCheckedStrategy=all, close #3936 - keys = getAllCheckedKeys(keys, this.state._k2n, this.state._p2n); break; } From f780d30be1f9cb3c1f72f6532ca26ae2704d4d6d Mon Sep 17 00:00:00 2001 From: chenxian Date: Thu, 9 Jun 2022 14:41:24 +0800 Subject: [PATCH 4/4] test(*): remove only on test case --- test/time-picker2/index-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/time-picker2/index-spec.js b/test/time-picker2/index-spec.js index 85294478b4..0ab8f9445e 100644 --- a/test/time-picker2/index-spec.js +++ b/test/time-picker2/index-spec.js @@ -288,7 +288,7 @@ describe('TimePicker2', () => { assert.deepEqual(getStrValue(wrapper), ['11:12:13', '12:00:00']) }) - it.only('should render with value controlled', () => { + it('should render with value controlled', () => { wrapper = mount(); assert.deepEqual(getStrValue(wrapper), ['11:12:13', '12:12:13'])