Cascader: multiple && filterable,在有 tag 的时候,输入拼音按 delete 的时候,会把 tag 删掉

pull/21555/head
z__z 2021-12-16 16:10:14 +08:00
parent 1ef72a3283
commit bdabdaa4b2
1 changed files with 12 additions and 2 deletions

View File

@ -62,7 +62,9 @@
:placeholder="presentTags.length ? '' : placeholder" :placeholder="presentTags.length ? '' : placeholder"
@input="e => handleInput(inputValue, e)" @input="e => handleInput(inputValue, e)"
@click.stop="toggleDropDownVisible(true)" @click.stop="toggleDropDownVisible(true)"
@keydown.delete="handleDelete"> @keydown.delete="handleDelete"
@compositionstart="handleCompositionstart"
@compositionend="handleCompositionend">
</div> </div>
<transition name="el-zoom-in-top" @after-leave="handleDropdownLeave"> <transition name="el-zoom-in-top" @after-leave="handleDropdownLeave">
@ -240,7 +242,8 @@ export default {
filtering: false, filtering: false,
suggestions: [], suggestions: [],
inputInitialHeight: 0, inputInitialHeight: 0,
pressDeleteCount: 0 pressDeleteCount: 0,
spell: false
}; };
}, },
@ -436,6 +439,12 @@ export default {
handleBlur(e) { handleBlur(e) {
this.$emit('blur', e); this.$emit('blur', e);
}, },
handleCompositionstart() {
this.spell = true;
},
handleCompositionend(e) {
this.spell = false;
},
handleInput(val, event) { handleInput(val, event) {
!this.dropDownVisible && this.toggleDropDownVisible(true); !this.dropDownVisible && this.toggleDropDownVisible(true);
@ -579,6 +588,7 @@ export default {
} }
}, },
handleDelete() { handleDelete() {
if (this.spell) return;
const { inputValue, pressDeleteCount, presentTags } = this; const { inputValue, pressDeleteCount, presentTags } = this;
const lastIndex = presentTags.length - 1; const lastIndex = presentTags.length - 1;
const lastTag = presentTags[lastIndex]; const lastTag = presentTags[lastIndex];