Skip to content

Commit 657fc11

Browse files
committed
Router push needs a catch block, as navigating to same route throws an error, see vuejs/vue-router#2881 (comment). It seems it's not supposed to throw the error if parameters are changed, so maybe a bug in vue-router?
1 parent 72b4e4f commit 657fc11

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

Diff for: static/js/vue-cdr-access/src/components/browseSearch.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@
4141
methods: {
4242
getResults() {
4343
let update_params = { anywhere: encodeURIComponent(this.search_query) };
44-
this.$router.push({ name: 'displayRecords', query: this.urlParams(update_params) });
44+
this.$router.push({ name: 'displayRecords', query: this.urlParams(update_params) })
45+
.catch((e) => {
46+
if (e.name !== 'NavigationDuplicated') {
47+
throw e;
48+
}
49+
});
4550
},
4651
4752
clearSearch() {

Diff for: static/js/vue-cdr-access/src/components/browseSort.vue

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
this.$router.push({
4040
path: this.$route.path,
4141
query: this.urlParams({ sort: this.sort_order }, is_search_sort)
42+
}).catch((e) => {
43+
if (e.name !== 'NavigationDuplicated') {
44+
throw e;
45+
}
4246
});
4347
this.sort_order = '';
4448
}

Diff for: static/js/vue-cdr-access/src/components/displayWrapper.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@
108108
109109
updateUrl() {
110110
let params = this.setTypes();
111-
this.$router.push({ name: 'displayRecords', query: params });
111+
this.$router.push({ name: 'displayRecords', query: params }).catch((e) => {
112+
if (e.name !== 'NavigationDuplicated') {
113+
throw e;
114+
}
115+
});
112116
},
113117
114118
updateParams() {

Diff for: static/js/vue-cdr-access/src/components/facets.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@
124124
// Add/Update with new facets
125125
base_search.query = Object.assign(base_search.query, updated_facet_params.queryFacets);
126126
127-
this.$router.push(base_search);
127+
this.$router.push(base_search).catch((e) => {
128+
if (e.name !== 'NavigationDuplicated') {
129+
throw e;
130+
}
131+
});
128132
},
129133
130134
/**

Diff for: static/js/vue-cdr-access/src/components/viewType.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@
3737
e.preventDefault();
3838
this.browse_type = e.target.id;
3939
let update_params = { browse_type: encodeURIComponent(this.browse_type) };
40-
this.$router.push({ name: 'displayRecords', query: this.urlParams(update_params) });
40+
this.$router.push({ name: 'displayRecords', query: this.urlParams(update_params) }).catch((e) => {
41+
if (e.name !== 'NavigationDuplicated') {
42+
throw e;
43+
}
44+
});
4145
sessionStorage.setItem('browse-type', this.browse_type);
4246
}
4347
},

Diff for: static/js/vue-cdr-access/src/components/worksOnly.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@
4141
params.types = this.updateWorkType(this.adminUnit, this.works_only).types;
4242
params.works_only = this.works_only;
4343
44-
this.$router.push({ name: 'displayRecords', query: params });
44+
this.$router.push({ name: 'displayRecords', query: params }).catch((e) => {
45+
if (e.name !== 'NavigationDuplicated') {
46+
throw e;
47+
}
48+
});
4549
}
4650
},
4751

0 commit comments

Comments
 (0)