From 47f03c5419e77b20cd6012584ef5b23ed696302f Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Fri, 28 Sep 2018 11:17:45 +0800 Subject: [PATCH] fix #4273 --- src/components/select/select-head.vue | 1 + src/components/select/select.vue | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/select/select-head.vue b/src/components/select/select-head.vue index 640db54..92d9d74 100644 --- a/src/components/select/select-head.vue +++ b/src/components/select/select-head.vue @@ -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 === '') { diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 0e5a89b..15e2892 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -44,6 +44,8 @@ @on-input-focus="isFocused = true" @on-input-blur="isFocused = false" @on-clear="clearSingleSelect" + + @on-keydown="handleFilterInputKeyDown" /> @@ -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){ -- libgit2 0.21.4