Skip to content
Snippets Groups Projects
Commit 757c0111 authored by Henrik Askjer's avatar Henrik Askjer
Browse files

Merge branch 'fix_premature_autocomplete' into 'master'

Use combobox

See merge request spraksamlingane/beta.ordbok.uib.no!41
parents 87b220f0 f998c08c
No related branches found
No related tags found
No related merge requests found
<template>
<div class="autocomplete-container" :class="$vuetify.breakpoint.name">
<v-autocomplete
<v-combobox
v-model="select"
:loading="loading"
:items="items"
......@@ -19,7 +19,6 @@
full-width
flat
outlined
auto-select-first
placeholder="Søk her"
ref="autocomplete"
color="primary"
......@@ -28,7 +27,7 @@
<template v-slot:item="data">
<span class="search-hit">{{data.item.label}} </span> ({{data.item.lang_set ? Array.from(data.item.lang_set).sort().join(', ') : 'fritekstsøk'}})
</template>
</v-autocomplete>
</v-combobox>
</div>
</template>
......@@ -69,7 +68,6 @@
});
hits.reverse()
hits = hits.slice(0, 9)
hits.unshift({q: encodeURIComponent(q), label: q + ' '})
}
hits.sort( (h1, h2) => {
let val1 = h1.label.length * 10 + (h1.label[0].toLowerCase() === h1.label[0] ? 0 : 1)
......@@ -92,7 +90,11 @@
}
},
select(item) {
if (typeof item === 'string') {
item = {"q": encodeURIComponent(item)}
}
this.$emit('submit', item)
this.$refs.autocomplete.blur()
let self = this
setTimeout(() => self.$refs.autocomplete.$refs.input.select(), 1)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment