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 () {
this.inputLength = this.$refs.input.value.length * 12 + 20;
this.$emit('on-keydown');
},
handleInputDelete () {
if (this.multiple && this.selectedMultiple.length && this.query === '') {

View file

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