[Autocomplete UI] Better handling of blur events.

This commit is contained in:
Fabio Manganiello 2023-12-16 14:09:04 +01:00
parent 1dfbe0c12d
commit 028f48ed49
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -10,7 +10,7 @@
:value="value"
@focus="onFocus"
@input="onInput"
@blur="onInput"
@blur="onBlur"
@keydown="onInputKeyDown"
@keyup="onInputKeyUp"
>
@ -23,8 +23,7 @@
:key="item"
:data-item="item"
v-for="(item, i) in visibleItems"
@click="onItemSelect(item)"
>
@click="onItemSelect(item)">
<span class="matching" v-if="value?.length">{{ item.substr(0, value.length) }}</span>
<span class="normal">{{ item.substr(value?.length || 0) }}</span>
</div>
@ -150,6 +149,14 @@ export default {
this.visible = true
},
onBlur(e) {
this.onInput(e)
this.$nextTick(() => {
if (this.valueIsInItems())
this.visible = false
})
},
onItemSelect(item) {
this.$emit("input", item)
this.$nextTick(() => {