From 0d3a9a29ee84a38d602c597da2935c6cb19dec8b Mon Sep 17 00:00:00 2001
From: schneider210 <frank.schneider@sub.uni-goettingen.de>
Date: Wed, 11 Aug 2021 16:07:47 +0200
Subject: [PATCH] fix: logic to display any items on empty search

---
 src/.vuepress/components/SearchPage.vue | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/.vuepress/components/SearchPage.vue b/src/.vuepress/components/SearchPage.vue
index 680fd6d..b3d6ff8 100644
--- a/src/.vuepress/components/SearchPage.vue
+++ b/src/.vuepress/components/SearchPage.vue
@@ -11,7 +11,6 @@
       class="loading-wrapper py-10"
       >
       <v-progress-circular
-        v-if="loading"
         color="primary"
         size="50"
         indeterminate
@@ -78,12 +77,16 @@ export default {
     onSearchInput(query) {
       this.query = query;
       this.page = 1;
+
       this.search(this.query, 0, this.size)
     },
     async search(value, from, size) {
-      this.loading = false;
-
       try {
+        this.items = [];
+        this.total = 0;
+
+        this.loading = true;
+
         const searchResponse = await apiService.search(value, from, size);
         const items = searchResponse.hits?.hits;
 
@@ -92,9 +95,10 @@ export default {
           this.items = items.map(x => ({ ...x, searchTerm: value }));
         }
       } catch(error) {
-        // console.log(error.message);
+          this.items = [];
+          this.total = 0;
       } finally {
-        this.loading = true;
+        this.loading = false;
       }
     },
     scrollUp() {
-- 
GitLab