Skip to content

Commit 80e1865

Browse files
authored
fix(TreeSelect): fixed multiple selection error when customValue is empty array (#3662)
1 parent f9c07dc commit 80e1865

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/tree-select/tree-select.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { SuperComponent, wxComponent } from '../common/src/index';
2+
import { isDef } from '../common/validator';
23
import config from '../common/config';
34
import props from './props';
45

@@ -150,19 +151,15 @@ export default class TreeSelect extends SuperComponent {
150151
handleChange(e) {
151152
const { innerValue } = this.data;
152153
const { level, type } = e.target.dataset;
154+
const { value } = type === 'multiple' ? e.detail.context : e.detail;
153155

154156
if (type === 'multiple') {
155-
const {
156-
context: { value },
157-
} = e.detail;
158-
const index = innerValue[level].indexOf(value);
159-
if (index !== -1) {
160-
innerValue[level].splice(index, 1);
161-
} else {
162-
innerValue[level].push(value);
157+
if (!isDef(innerValue[level])) {
158+
innerValue[level] = [];
163159
}
160+
const index = innerValue[level].indexOf(value);
161+
index === -1 ? innerValue[level].push(value) : innerValue[level].splice(index, 1);
164162
} else {
165-
const { value } = e.detail;
166163
innerValue[level] = value;
167164
}
168165

0 commit comments

Comments
 (0)