Skip to content

Commit 61142d4

Browse files
committed
Merge branch 'develop' of github.com:basemate/matestack-ui-core into develop
2 parents be5124d + 6586691 commit 61142d4

File tree

6 files changed

+74
-18
lines changed

6 files changed

+74
-18
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Vue from 'vue/dist/vue.esm'
22
import VRuntimeTemplate from "v-runtime-template"
33
import Vuex from 'vuex'
4+
import isNavigatingToAnotherPage from "./location"
45

56
const componentDef = {
67
props: ['appConfig', 'params'],
@@ -9,12 +10,18 @@ const componentDef = {
910
},
1011
computed: Vuex.mapState({
1112
asyncTemplate: state => state.pageTemplate,
12-
currentPath: state => state.currentPath
13+
currentPathName: state => state.currentPathName,
14+
currentSearch: state => state.currentSearch,
15+
currentOrigin: state => state.currentOrigin,
1316
}),
1417
mounted: function(){
1518
const self = this;
1619
window.onpopstate = (event) => {
17-
if (self.currentPath != document.location.pathname){
20+
if (isNavigatingToAnotherPage({
21+
origin: self.currentOrigin,
22+
pathName: self.currentPathName,
23+
search: self.currentSearch
24+
}, document.location)){
1825
self.$store.dispatch("navigateTo", {url: document.location.pathname, backwards: true} );
1926
}
2027
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const isNavigatingToAnotherPage = function(currentLocation, targetLocation) {
2+
3+
// omits hash by design
4+
return currentLocation.pathName !== targetLocation.pathname ||
5+
currentLocation.origin !== targetLocation.origin ||
6+
currentLocation.search !== targetLocation.search
7+
}
8+
9+
export default isNavigatingToAnotherPage

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);

spec/usage/components/transition_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,20 @@ def page2
141141
expect(page).to have_content("This is Page 2")
142142
expect(page).to have_selector("body.not-reloaded")
143143

144-
# page.evaluate_script('window.history.back()')
145144
page.go_back
146145

147-
element = page.find("#my-div-on-page-1")
148-
refreshed_content_on_page_1 = element.text
149-
150146
expect(page).to have_content("My Example App Layout")
151147
expect(page).to have_content("This is Page 1")
152148
expect(page).not_to have_content("This is Page 2")
153149
expect(page).to have_selector("body.not-reloaded")
150+
expect(page).to have_no_content(first_content_on_page_1)
154151

155-
expect(first_content_on_page_1).not_to eq(refreshed_content_on_page_1)
152+
page.go_forward
153+
154+
expect(page).to have_content("My Example App Layout")
155+
expect(page).not_to have_content("This is Page 1")
156+
expect(page).to have_content("This is Page 2")
157+
expect(page).to have_selector("body.not-reloaded")
156158
end
157159

158160
# supposed to work, but doesn't. Suspect Vue is the culprint here

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

Lines changed: 40 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)