Commit ae7579e98d198b9bb067cc2fa6ad0cf1a616422c
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,8 +42,6 @@ | ||
42 | @on-query-change="onQueryChange" | 42 | @on-query-change="onQueryChange" |
43 | @on-input-focus="isFocused = true" | 43 | @on-input-focus="isFocused = true" |
44 | @on-input-blur="isFocused = false" | 44 | @on-input-blur="isFocused = false" |
45 | - | ||
46 | - ref="selectHead" | ||
47 | /> | 45 | /> |
48 | </slot> | 46 | </slot> |
49 | </div> | 47 | </div> |
@@ -407,7 +405,7 @@ | @@ -407,7 +405,7 @@ | ||
407 | if (this.visible) { | 405 | if (this.visible) { |
408 | 406 | ||
409 | if (this.filterable) { | 407 | if (this.filterable) { |
410 | - const input = this.$refs.selectHead.$refs.input; | 408 | + const input = this.$el.querySelector('input[type="text"]'); |
411 | this.caretPosition = input.selectionStart; | 409 | this.caretPosition = input.selectionStart; |
412 | this.$nextTick(() => { | 410 | this.$nextTick(() => { |
413 | const caretPosition = this.caretPosition === -1 ? input.value.length : this.caretPosition; | 411 | const caretPosition = this.caretPosition === -1 ? input.value.length : this.caretPosition; |
@@ -415,7 +413,7 @@ | @@ -415,7 +413,7 @@ | ||
415 | }); | 413 | }); |
416 | } | 414 | } |
417 | 415 | ||
418 | - event.stopPropagation(); | 416 | + if (!this.autoComplete) event.stopPropagation(); |
419 | event.preventDefault(); | 417 | event.preventDefault(); |
420 | this.hideMenu(); | 418 | this.hideMenu(); |
421 | this.isFocused = true; | 419 | this.isFocused = true; |
@@ -513,8 +511,8 @@ | @@ -513,8 +511,8 @@ | ||
513 | } | 511 | } |
514 | 512 | ||
515 | if (this.filterable){ | 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 | onQueryChange(query) { | 518 | onQueryChange(query) { |
@@ -581,8 +579,7 @@ | @@ -581,8 +579,7 @@ | ||
581 | } | 579 | } |
582 | }, | 580 | }, |
583 | isFocused(focused){ | 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 | el[this.isFocused ? 'focus' : 'blur'](); | 583 | el[this.isFocused ? 'focus' : 'blur'](); |
587 | 584 | ||
588 | // restore query value in filterable single selects | 585 | // restore query value in filterable single selects |