Skip to content

Commit

Permalink
chore: update common (#3273)
Browse files Browse the repository at this point in the history
* chore: update common

* fix(cascader): fix remove and change trigger effect
  • Loading branch information
uyarn committed Aug 15, 2024
1 parent 995e71f commit b27f993
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/cascader/core/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,27 @@ export function handleRemoveTagEffect(
} = cascaderContext;

if (disabled) return;
const newValue = cloneDeep(value) as [];
const res = newValue.splice(index, 1);
const node = treeStore.getNodes(res[0])[0];

setValue(newValue, 'uncheck', node.getModel());

const checked = node.setChecked(!node.isChecked());
// 处理不同数据类型
const resValue = valueType === 'single'
? checked
: checked.map((val) => treeStore
.getNode(val)
.getPath()
.map((item) => item.value));

setValue(resValue, 'uncheck', node.getModel());
if (isFunction(onRemove)) {
onRemove({ value: checked, node: node as any });
// index equal to undefined means to click clear button
if (index !== undefined) {
const newValue = cloneDeep(value) as [];
const res = newValue.splice(index, 1);
const node = treeStore.getNodes(res[0])[0];

const checked = node.setChecked(!node.isChecked());
// 处理不同数据类型
const resValue = valueType === 'single'
? checked
: checked.map((val) => treeStore
.getNode(val)
.getPath()
.map((item) => item.value));
setValue(resValue, 'uncheck', node.getModel());
if (isFunction(onRemove)) {
onRemove({ value: checked, node: node as any });
}
} else if (isFunction(onRemove)) {
onRemove({ value, node: undefined });
}
}

Expand Down

0 comments on commit b27f993

Please sign in to comment.