From ad623849e2cca8c0ab2bdbe397faeae79dbbd0cb Mon Sep 17 00:00:00 2001
From: "Henrik.Askjer" <henrik.askjer@uib.no>
Date: Fri, 27 Aug 2021 14:27:49 +0200
Subject: [PATCH] Add full text search option while waiting for debounce

---
 src/components/Autocomplete.vue | 34 ++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue
index e718f4c..906e2ad 100644
--- a/src/components/Autocomplete.vue
+++ b/src/components/Autocomplete.vue
@@ -85,31 +85,31 @@
         }
       },
       select(item) {
-        this.items = []
         if (item) {
-          if (typeof item == 'string') { // if blurred without selecting an option
-             // TODO: sett timeout for å vente på siste forslag?
-            item = {q: item, label: item}
-
-          }
-          if (item.q == this.$refs.autocomplete.searchInput) {
-              this.$emit('submit', item)
-              
-              let self = this
-              setTimeout(() => {
-                self.$refs.autocomplete.$refs.input.select()
-                this.items = []
-                this.suggesting = false
-                }, 1)
+          if (typeof item != 'string') {
+            this.$emit('submit', item)
+            
+            let self = this
+            setTimeout(() => {
+              self.$refs.autocomplete.$refs.input.select()
+              this.items = []
+              this.suggesting = false
+              }, 1)
           }
-          
         }
       }
     },
     methods: {
       run_query(q) {
         this.suggesting = true
-        this.items = []
+        if (this.items[0]) {
+          if (this.items[0].lang) {
+          this.items.unshift({q: q, label: q})
+        }
+          else {
+            this.items[0] = {q: q, label: q}
+          }
+        }
         this.debounced(q, this)
       }
     },
-- 
GitLab