This commit is contained in:
梁灏 2018-09-28 11:17:45 +08:00
parent 7a2155098f
commit 47f03c5419
2 changed files with 15 additions and 2 deletions

View file

@ -155,6 +155,7 @@
}, },
resetInputState () { resetInputState () {
this.inputLength = this.$refs.input.value.length * 12 + 20; this.inputLength = this.$refs.input.value.length * 12 + 20;
this.$emit('on-keydown');
}, },
handleInputDelete () { handleInputDelete () {
if (this.multiple && this.selectedMultiple.length && this.query === '') { if (this.multiple && this.selectedMultiple.length && this.query === '') {

View file

@ -44,6 +44,8 @@
@on-input-focus="isFocused = true" @on-input-focus="isFocused = true"
@on-input-blur="isFocused = false" @on-input-blur="isFocused = false"
@on-clear="clearSingleSelect" @on-clear="clearSingleSelect"
@on-keydown="handleFilterInputKeyDown"
/> />
</slot> </slot>
</div> </div>
@ -264,6 +266,7 @@
unchangedQuery: true, unchangedQuery: true,
hasExpectedValue: false, hasExpectedValue: false,
preventRemoteCall: false, preventRemoteCall: false,
filterQueryKeyDown: false, // #4273
}; };
}, },
computed: { computed: {
@ -392,7 +395,7 @@
if (cOptions.children.length > 0) selectOptions.push({...option}); if (cOptions.children.length > 0) selectOptions.push({...option});
} else { } else {
// ignore option if not passing filter // ignore option if not passing filter
if (!hasDefaultSelected) { if (!hasDefaultSelected || this.filterQueryKeyDown) {
const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option;
if (!optionPassesFilter) continue; if (!optionPassesFilter) continue;
} }
@ -402,6 +405,8 @@
} }
} }
this.filterQueryKeyDown = false;
return selectOptions; return selectOptions;
}, },
flatOptions(){ flatOptions(){
@ -658,7 +663,14 @@
if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) { if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) {
this.hasExpectedValue = true; this.hasExpectedValue = true;
} }
} },
/**
* 下面的方法 filterable 输入内容时标记用于区分和直接选择而引起的 bug
* #4273
* */
handleFilterInputKeyDown () {
this.filterQueryKeyDown = true;
},
}, },
watch: { watch: {
value(value){ value(value){