Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Cascader: fix delete tag bug (ElemeFE#20939)
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 authored and CarterLi committed Nov 19, 2021
1 parent 1803164 commit f2b005b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/cascader/src/cascader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@

<div v-if="multiple" class="el-cascader__tags">
<el-tag
v-for="(tag, index) in presentTags"
v-for="tag in presentTags"
:key="tag.key"
type="info"
:size="tagSize"
:hit="tag.hitState"
:closable="tag.closable"
disable-transitions
@close="deleteTag(index)">
@close="deleteTag(tag)">
<span>{{ tag.text }}</span>
</el-tag>
<input
Expand Down Expand Up @@ -574,7 +574,7 @@ export default {
if (this.pressDeleteCount) {
if (lastTag.hitState) {
this.deleteTag(lastIndex);
this.deleteTag(lastTag);
} else {
lastTag.hitState = true;
}
Expand All @@ -593,10 +593,11 @@ export default {
this.toggleDropDownVisible(false);
}
},
deleteTag(index) {
deleteTag(tag) {
const { checkedValue } = this;
const val = checkedValue[index];
this.checkedValue = checkedValue.filter((n, i) => i !== index);
const current = tag.node.getValueByOption();
const val = checkedValue.find(n => isEqual(n, current));
this.checkedValue = checkedValue.filter(n => !isEqual(n, current));
this.$emit('remove-tag', val);
},
updateStyle() {
Expand Down

0 comments on commit f2b005b

Please sign in to comment.