From 8c96d382bbab49cce1cd755b6ac2d783b8382b9d Mon Sep 17 00:00:00 2001
From: Henrik Askjer <henrik.askjer@uib.no>
Date: Tue, 21 Dec 2021 15:55:50 +0100
Subject: [PATCH] return to results after clicking multiple links

---
 src/components/DictionaryView.vue | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue
index 2b69f699..3c97bc2a 100644
--- a/src/components/DictionaryView.vue
+++ b/src/components/DictionaryView.vue
@@ -12,10 +12,10 @@
     </div>
 
         <div class="return_to_results" v-if="total_results && article">
-          <router-link v-if="article.source" :to="article.source" @click.native="return_to_results()">
+          <router-link v-if="previous" :to="previous" @click.native="return_to_results()">
             <v-icon left class="nav_arrow">chevron_left</v-icon>{{$t("back_to_results")}}
           </router-link>
-          <a v-if="!article.source" href="/">
+          <a v-if="!this.previous" href="/">
             <v-icon left class="nav_arrow">chevron_left</v-icon>Søk etter andre ord
           </a>
         </div>
@@ -99,7 +99,6 @@ function navigate_to_article(self, source) {
   axios.get(ARTICLE_ENDPOINT + lang + '/article/' + self.$route.params.id + ".json")
   .then(function(response){
     self.article = Object.assign(response.data, {'dictionary': lang, results: self.search_results})
-    self.search_results = {}
     self.error = null
   })
   .catch(function(error){
@@ -219,6 +218,7 @@ function navigate_to_query(self, word) {
                 self.inflection_suggestions = []
               }
               self.waiting_for_articles = false
+              
               history.replaceState({
                 article: self.article,
                 lang: self.lang,
@@ -230,6 +230,7 @@ function navigate_to_query(self, word) {
                 page: self.page,
                 perPage: self.perPage
               }, '')
+              self.previous = self.$route.fullPath
             })
           
         }).catch(error =>{
@@ -440,7 +441,8 @@ export default {
       }
     },
     details_click: function(item) {
-      item.article.source = this.previous.split('#')[0] + "#" + item.title_id
+      item.article.source = this.$route.fullPath
+      this.previous = this.previous.split('#')[0] + "#" + item.title_id
       this.article = item.article
       history.replaceState({article: this.article,
                             search_results: {},
@@ -458,11 +460,6 @@ export default {
       this.article = null
     }
   },
-  watch: {
-    $route(to, from) {
-      this.previous = from.fullPath
-    }
-  },
   mounted: function(){
     let self = this
     self.lang = self.$route.params.lang || this.$store.state.defaultDict
-- 
GitLab