Skip to content

Commit 51b2798

Browse files
committed
added search and origin check on popstate navigation check
1 parent 65dbddd commit 51b2798

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

app/concepts/matestack/ui/core/app/app.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ const componentDef = {
99
},
1010
computed: Vuex.mapState({
1111
asyncTemplate: state => state.pageTemplate,
12-
currentPath: state => state.currentPath
12+
currentPathName: state => state.currentPathName,
13+
currentSearch: state => state.currentSearch,
14+
currentOrigin: state => state.currentOrigin,
1315
}),
1416
mounted: function(){
1517
const self = this;
1618
window.onpopstate = (event) => {
17-
if (self.currentPath != document.location.pathname){
19+
let needToNavigate = self.currentPathName !== document.location.pathname ||
20+
self.currentOrigin !== document.location.origin ||
21+
self.currentSearch !== document.location.search
22+
23+
if (needToNavigate){
1824
self.$store.dispatch("navigateTo", {url: document.location.pathname, backwards: true} );
1925
}
2026
}

app/concepts/matestack/ui/core/app/store.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ Vue.use(Vuex)
88
const store = new Vuex.Store({
99
state: {
1010
pageTemplate: null,
11-
currentPath: document.location.pathname
11+
currentPathName: document.location.pathname,
12+
currentSearch: document.location.search,
13+
currentOrigin: document.location.origin
1214
},
1315
mutations: {
1416
setPageTemplate (state, serverResponse){
1517
state.pageTemplate = serverResponse
1618
},
17-
setCurrentPath (state, path){
18-
state.currentPath = path
19+
setCurrentLocation (state, current){
20+
state.currentPathName = current.path
21+
state.currentSearch = current.search
22+
state.currentOrigin = current.origin
1923
}
2024
},
2125
actions: {
@@ -46,7 +50,7 @@ const store = new Vuex.Store({
4650
setTimeout(function () {
4751
resolve(response["data"])
4852
commit('setPageTemplate', response["data"])
49-
commit('setCurrentPath', url)
53+
commit('setCurrentLocation', { path: url, search: document.location.search, origin: document.location.origin })
5054
matestackEventHub.$emit("page_loaded", url);
5155
if (typeof matestackUiCoreTransitionSuccess !== 'undefined') {
5256
matestackUiCoreTransitionSuccess(url);

vendor/assets/javascripts/dist/matestack-ui-core.js

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/assets/javascripts/dist/matestack-ui-core.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)