Commit 47f03c5419e77b20cd6012584ef5b23ed696302f

Authored by 梁灏
1 parent 7a215509

fix #4273

src/components/select/select-head.vue
@@ -155,6 +155,7 @@ @@ -155,6 +155,7 @@
155 }, 155 },
156 resetInputState () { 156 resetInputState () {
157 this.inputLength = this.$refs.input.value.length * 12 + 20; 157 this.inputLength = this.$refs.input.value.length * 12 + 20;
  158 + this.$emit('on-keydown');
158 }, 159 },
159 handleInputDelete () { 160 handleInputDelete () {
160 if (this.multiple && this.selectedMultiple.length && this.query === '') { 161 if (this.multiple && this.selectedMultiple.length && this.query === '') {
src/components/select/select.vue
@@ -44,6 +44,8 @@ @@ -44,6 +44,8 @@
44 @on-input-focus="isFocused = true" 44 @on-input-focus="isFocused = true"
45 @on-input-blur="isFocused = false" 45 @on-input-blur="isFocused = false"
46 @on-clear="clearSingleSelect" 46 @on-clear="clearSingleSelect"
  47 +
  48 + @on-keydown="handleFilterInputKeyDown"
47 /> 49 />
48 </slot> 50 </slot>
49 </div> 51 </div>
@@ -264,6 +266,7 @@ @@ -264,6 +266,7 @@
264 unchangedQuery: true, 266 unchangedQuery: true,
265 hasExpectedValue: false, 267 hasExpectedValue: false,
266 preventRemoteCall: false, 268 preventRemoteCall: false,
  269 + filterQueryKeyDown: false, // #4273
267 }; 270 };
268 }, 271 },
269 computed: { 272 computed: {
@@ -392,7 +395,7 @@ @@ -392,7 +395,7 @@
392 if (cOptions.children.length > 0) selectOptions.push({...option}); 395 if (cOptions.children.length > 0) selectOptions.push({...option});
393 } else { 396 } else {
394 // ignore option if not passing filter 397 // ignore option if not passing filter
395 - if (!hasDefaultSelected) { 398 + if (!hasDefaultSelected || this.filterQueryKeyDown) {
396 const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option; 399 const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option;
397 if (!optionPassesFilter) continue; 400 if (!optionPassesFilter) continue;
398 } 401 }
@@ -402,6 +405,8 @@ @@ -402,6 +405,8 @@
402 } 405 }
403 } 406 }
404 407
  408 + this.filterQueryKeyDown = false;
  409 +
405 return selectOptions; 410 return selectOptions;
406 }, 411 },
407 flatOptions(){ 412 flatOptions(){
@@ -658,7 +663,14 @@ @@ -658,7 +663,14 @@
658 if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) { 663 if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) {
659 this.hasExpectedValue = true; 664 this.hasExpectedValue = true;
660 } 665 }
661 - } 666 + },
  667 + /**
  668 + * 下面的方法,当 filterable 时,输入内容时,标记,用于区分和直接选择而引起的 bug
  669 + * #4273
  670 + * */
  671 + handleFilterInputKeyDown () {
  672 + this.filterQueryKeyDown = true;
  673 + },
662 }, 674 },
663 watch: { 675 watch: {
664 value(value){ 676 value(value){