From 9059eb383379458c804c8d5084a9b3694ca1ffb8 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Tue, 28 Aug 2018 10:33:18 -0300 Subject: [PATCH] Uses replace instead of push routes on event search bus to prevent browser history messing up. Ref. #85. --- src/js/event-bus-search.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js/event-bus-search.js b/src/js/event-bus-search.js index 8d40ebe5e..5bd0d2705 100644 --- a/src/js/event-bus-search.js +++ b/src/js/event-bus-search.js @@ -46,7 +46,8 @@ export default { }); }, watch: { - '$route' (to, from) { + '$route' (to, from) { + console.log("router watch"); // Should set Collection ID from URL only when in admin. if (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') this.collectionId = !this.$route.params.collectionId ? this.$route.params.collectionId : parseInt(this.$route.params.collectionId); @@ -290,8 +291,9 @@ export default { this.updateURLQueries(); }, updateURLQueries() { - this.$router.push({query: {}}); - this.$router.push({query: this.$store.getters['search/getPostQuery']}); + console.log("update"); + this.$router.replace({query: {}}); + this.$router.replace({query: this.$store.getters['search/getPostQuery']}); }, updateStoreFromURL() { this.$store.dispatch('search/set_postquery', this.$route.query); @@ -316,7 +318,7 @@ export default { this.$emit( 'hasFiltered', res.hasFiltered); if(res.advancedSearchResults){ - this.$router.push({query: this.$store.getters['search/getPostQuery'],}); + this.$router.replace({query: this.$store.getters['search/getPostQuery'],}); this.$emit('advancedSearchResults', res.advancedSearchResults); } })