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

Avoid dropdown when selecting by clicking

parent c46e77b9
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
.then( .then(
function(response) { function(response) {
let currentSearch = self.$refs.autocomplete.searchInput let currentSearch = self.$refs.autocomplete.searchInput
if (currentSearch == q) { if (currentSearch == q & self.suggesting) {
let hits = [] let hits = []
response.data.forEach((item, i) => { response.data.forEach((item, i) => {
...@@ -87,15 +87,20 @@ ...@@ -87,15 +87,20 @@
select(item) { select(item) {
this.items = [] this.items = []
if (item) { if (item) {
if (typeof item === 'string') { // if blurred without selecting an option if (typeof item == 'string') { // if blurred without selecting an option
// TODO: sett timeout for å vente på siste forslag? // TODO: sett timeout for å vente på siste forslag?
item = {q: item, label: item} item = {q: item, label: item}
} }
if (item.q == this.$refs.autocomplete.searchInput) { if (item.q == this.$refs.autocomplete.searchInput) {
this.$emit('submit', item) this.$emit('submit', item)
let self = this let self = this
setTimeout(() => self.$refs.autocomplete.$refs.input.select(), 1) setTimeout(() => {
self.$refs.autocomplete.$refs.input.select()
this.items = []
this.suggesting = false
}, 1)
} }
} }
...@@ -103,6 +108,7 @@ ...@@ -103,6 +108,7 @@
}, },
methods: { methods: {
run_query(q) { run_query(q) {
this.suggesting = true
this.items = [] this.items = []
this.debounced(q, this) this.debounced(q, this)
} }
......
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