Commit 427b869297e36780c062ebd9a5e6e672bffc4ac8

Authored by Aresn
Committed by GitHub
2 parents a7713a76 d20b4e1a

Merge pull request #3747 from SergioCrisostomo/select-patches

Select fixes
src/components/select/option.vue
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 <li 2 <li
3 :class="classes" 3 :class="classes"
4 @click.stop="select" 4 @click.stop="select"
  5 + @touchend.stop="select"
5 @mousedown.prevent 6 @mousedown.prevent
6 @touchstart.prevent 7 @touchstart.prevent
7 ><slot>{{ showLabel }}</slot></li> 8 ><slot>{{ showLabel }}</slot></li>
src/components/select/select.vue
@@ -411,7 +411,7 @@ @@ -411,7 +411,7 @@
411 clearSingleSelect(){ // PUBLIC API 411 clearSingleSelect(){ // PUBLIC API
412 this.$emit('on-clear'); 412 this.$emit('on-clear');
413 this.hideMenu(); 413 this.hideMenu();
414 - if (this.clearable) this.values = []; 414 + if (this.clearable) this.reset();
415 }, 415 },
416 getOptionData(value){ 416 getOptionData(value){
417 const option = this.flatOptions.find(({componentOptions}) => componentOptions.propsData.value === value); 417 const option = this.flatOptions.find(({componentOptions}) => componentOptions.propsData.value === value);
@@ -427,7 +427,7 @@ @@ -427,7 +427,7 @@
427 let initialValue = Array.isArray(value) ? value : [value]; 427 let initialValue = Array.isArray(value) ? value : [value];
428 if (!multiple && (typeof initialValue[0] === 'undefined' || (String(initialValue[0]).trim() === '' && !Number.isFinite(initialValue[0])))) initialValue = []; 428 if (!multiple && (typeof initialValue[0] === 'undefined' || (String(initialValue[0]).trim() === '' && !Number.isFinite(initialValue[0])))) initialValue = [];
429 return initialValue.filter((item) => { 429 return initialValue.filter((item) => {
430 - return Boolean(item) || item === 0 430 + return Boolean(item) || item === 0;
431 }); 431 });
432 }, 432 },
433 processOption(option, values, isFocused){ 433 processOption(option, values, isFocused){
@@ -488,6 +488,14 @@ @@ -488,6 +488,14 @@
488 return; 488 return;
489 } 489 }
490 490
  491 + if (this.transfer) {
  492 + const {$el} = this.$refs.dropdown;
  493 + if ($el === event.target || $el.contains(event.target)) {
  494 + return;
  495 + }
  496 + }
  497 +
  498 +
491 if (this.filterable) { 499 if (this.filterable) {
492 const input = this.$el.querySelector('input[type="text"]'); 500 const input = this.$el.querySelector('input[type="text"]');
493 this.caretPosition = input.selectionStart; 501 this.caretPosition = input.selectionStart;
@@ -507,6 +515,8 @@ @@ -507,6 +515,8 @@
507 } 515 }
508 }, 516 },
509 reset(){ 517 reset(){
  518 + this.query = '';
  519 + this.focusIndex = -1;
510 this.unchangedQuery = true; 520 this.unchangedQuery = true;
511 this.values = []; 521 this.values = [];
512 }, 522 },