Commit ae7579e98d198b9bb067cc2fa6ad0cf1a616422c

Authored by Sergio Crisostomo
1 parent 9ca6671c

Fix input getters and logic for AutoComplete

Showing 1 changed file with 5 additions and 8 deletions   Show diff stats
src/components/select/select.vue
... ... @@ -42,8 +42,6 @@
42 42 @on-query-change="onQueryChange"
43 43 @on-input-focus="isFocused = true"
44 44 @on-input-blur="isFocused = false"
45   -
46   - ref="selectHead"
47 45 />
48 46 </slot>
49 47 </div>
... ... @@ -407,7 +405,7 @@
407 405 if (this.visible) {
408 406  
409 407 if (this.filterable) {
410   - const input = this.$refs.selectHead.$refs.input;
  408 + const input = this.$el.querySelector('input[type="text"]');
411 409 this.caretPosition = input.selectionStart;
412 410 this.$nextTick(() => {
413 411 const caretPosition = this.caretPosition === -1 ? input.value.length : this.caretPosition;
... ... @@ -415,7 +413,7 @@
415 413 });
416 414 }
417 415  
418   - event.stopPropagation();
  416 + if (!this.autoComplete) event.stopPropagation();
419 417 event.preventDefault();
420 418 this.hideMenu();
421 419 this.isFocused = true;
... ... @@ -513,8 +511,8 @@
513 511 }
514 512  
515 513 if (this.filterable){
516   - const inputField = this.$refs.selectHead.$refs.input;
517   - this.$nextTick(() => inputField.focus());
  514 + const inputField = this.$el.querySelector('input[type="text"]');
  515 + if (!this.autoComplete) this.$nextTick(() => inputField.focus());
518 516 }
519 517 },
520 518 onQueryChange(query) {
... ... @@ -581,8 +579,7 @@
581 579 }
582 580 },
583 581 isFocused(focused){
584   - const {selectHead, reference} = this.$refs;
585   - const el = this.filterable ? selectHead.$el.querySelector('input') : reference;
  582 + const el = this.filterable ? this.$el.querySelector('input[type="text"]') : this.$el;
586 583 el[this.isFocused ? 'focus' : 'blur']();
587 584  
588 585 // restore query value in filterable single selects
... ...