Uses replace instead of push routes on event search bus to prevent browser history messing up. Ref. #85.

This commit is contained in:
Mateus Machado Luna 2018-08-28 10:33:18 -03:00
parent 19e3b790c6
commit 9059eb3833
1 changed files with 6 additions and 4 deletions

View File

@ -46,7 +46,8 @@ export default {
}); });
}, },
watch: { watch: {
'$route' (to, from) { '$route' (to, from) {
console.log("router watch");
// Should set Collection ID from URL only when in admin. // Should set Collection ID from URL only when in admin.
if (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') if (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage')
this.collectionId = !this.$route.params.collectionId ? this.$route.params.collectionId : parseInt(this.$route.params.collectionId); this.collectionId = !this.$route.params.collectionId ? this.$route.params.collectionId : parseInt(this.$route.params.collectionId);
@ -290,8 +291,9 @@ export default {
this.updateURLQueries(); this.updateURLQueries();
}, },
updateURLQueries() { updateURLQueries() {
this.$router.push({query: {}}); console.log("update");
this.$router.push({query: this.$store.getters['search/getPostQuery']}); this.$router.replace({query: {}});
this.$router.replace({query: this.$store.getters['search/getPostQuery']});
}, },
updateStoreFromURL() { updateStoreFromURL() {
this.$store.dispatch('search/set_postquery', this.$route.query); this.$store.dispatch('search/set_postquery', this.$route.query);
@ -316,7 +318,7 @@ export default {
this.$emit( 'hasFiltered', res.hasFiltered); this.$emit( 'hasFiltered', res.hasFiltered);
if(res.advancedSearchResults){ 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); this.$emit('advancedSearchResults', res.advancedSearchResults);
} }
}) })