Fix input getters and logic for AutoComplete
This commit is contained in:
parent
9ca6671c71
commit
ae7579e98d
1 changed files with 5 additions and 8 deletions
|
@ -42,8 +42,6 @@
|
||||||
@on-query-change="onQueryChange"
|
@on-query-change="onQueryChange"
|
||||||
@on-input-focus="isFocused = true"
|
@on-input-focus="isFocused = true"
|
||||||
@on-input-blur="isFocused = false"
|
@on-input-blur="isFocused = false"
|
||||||
|
|
||||||
ref="selectHead"
|
|
||||||
/>
|
/>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
@ -407,7 +405,7 @@
|
||||||
if (this.visible) {
|
if (this.visible) {
|
||||||
|
|
||||||
if (this.filterable) {
|
if (this.filterable) {
|
||||||
const input = this.$refs.selectHead.$refs.input;
|
const input = this.$el.querySelector('input[type="text"]');
|
||||||
this.caretPosition = input.selectionStart;
|
this.caretPosition = input.selectionStart;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const caretPosition = this.caretPosition === -1 ? input.value.length : this.caretPosition;
|
const caretPosition = this.caretPosition === -1 ? input.value.length : this.caretPosition;
|
||||||
|
@ -415,7 +413,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
event.stopPropagation();
|
if (!this.autoComplete) event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.hideMenu();
|
this.hideMenu();
|
||||||
this.isFocused = true;
|
this.isFocused = true;
|
||||||
|
@ -513,8 +511,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.filterable){
|
if (this.filterable){
|
||||||
const inputField = this.$refs.selectHead.$refs.input;
|
const inputField = this.$el.querySelector('input[type="text"]');
|
||||||
this.$nextTick(() => inputField.focus());
|
if (!this.autoComplete) this.$nextTick(() => inputField.focus());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onQueryChange(query) {
|
onQueryChange(query) {
|
||||||
|
@ -581,8 +579,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isFocused(focused){
|
isFocused(focused){
|
||||||
const {selectHead, reference} = this.$refs;
|
const el = this.filterable ? this.$el.querySelector('input[type="text"]') : this.$el;
|
||||||
const el = this.filterable ? selectHead.$el.querySelector('input') : reference;
|
|
||||||
el[this.isFocused ? 'focus' : 'blur']();
|
el[this.isFocused ? 'focus' : 'blur']();
|
||||||
|
|
||||||
// restore query value in filterable single selects
|
// restore query value in filterable single selects
|
||||||
|
|
Loading…
Add table
Reference in a new issue