Commit 47f03c5419e77b20cd6012584ef5b23ed696302f

Authored by 梁灏
1 parent 7a215509

fix #4273

src/components/select/select-head.vue
... ... @@ -155,6 +155,7 @@
155 155 },
156 156 resetInputState () {
157 157 this.inputLength = this.$refs.input.value.length * 12 + 20;
  158 + this.$emit('on-keydown');
158 159 },
159 160 handleInputDelete () {
160 161 if (this.multiple && this.selectedMultiple.length && this.query === '') {
... ...
src/components/select/select.vue
... ... @@ -44,6 +44,8 @@
44 44 @on-input-focus="isFocused = true"
45 45 @on-input-blur="isFocused = false"
46 46 @on-clear="clearSingleSelect"
  47 +
  48 + @on-keydown="handleFilterInputKeyDown"
47 49 />
48 50 </slot>
49 51 </div>
... ... @@ -264,6 +266,7 @@
264 266 unchangedQuery: true,
265 267 hasExpectedValue: false,
266 268 preventRemoteCall: false,
  269 + filterQueryKeyDown: false, // #4273
267 270 };
268 271 },
269 272 computed: {
... ... @@ -392,7 +395,7 @@
392 395 if (cOptions.children.length > 0) selectOptions.push({...option});
393 396 } else {
394 397 // ignore option if not passing filter
395   - if (!hasDefaultSelected) {
  398 + if (!hasDefaultSelected || this.filterQueryKeyDown) {
396 399 const optionPassesFilter = this.filterable ? this.validateOption(cOptions) : option;
397 400 if (!optionPassesFilter) continue;
398 401 }
... ... @@ -402,6 +405,8 @@
402 405 }
403 406 }
404 407  
  408 + this.filterQueryKeyDown = false;
  409 +
405 410 return selectOptions;
406 411 },
407 412 flatOptions(){
... ... @@ -658,7 +663,14 @@
658 663 if (this.getInitialValue().length > 0 && this.selectOptions.length === 0) {
659 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 675 watch: {
664 676 value(value){
... ...