@symbo.ls/router 2.12.20 → 2.12.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +9 -6
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { setCookie } from '@domql/cookie'
4
4
  import { redirectBasedOnAuth } from '@symbo.ls/auth-redirect'
5
+ import { checkRouteModal } from '@symbo.ls/platform-utils'
5
6
 
6
7
  export const getActiveRoute = (level = 0, route = window.location.pathname) => {
7
8
  const routeArray = route.split('/')
@@ -61,9 +62,7 @@ export const router = (
61
62
 
62
63
  const content = element.routes[routeInContent] || element.routes['/*']
63
64
 
64
- const { context } = element
65
- const { components } = context
66
- const isModal = components.findModal && (components.findModal(element, element.state) || {}).FoundModal
65
+ const wasModal = checkRouteModal(pathname, element)
67
66
  const isInitial = options.initialRender
68
67
  const hashChanged = hash && hash !== window.location.hash.slice(1)
69
68
  const pathChanged = pathname !== lastPathname
@@ -71,21 +70,25 @@ export const router = (
71
70
 
72
71
  if (!content) return
73
72
  if (options.pushState) {
74
- window.history.pushState(state, null, route + (hash ? `#${hash}` : ''))
73
+ window.history.pushState({ prevUrl: window.location.href, ...state}, null, route + (hash ? `#${hash}` : ''))
75
74
  }
76
75
 
76
+ const isModal = checkRouteModal(pathname, element)
77
+
77
78
  if (pathChanged || !hashChanged) {
78
79
  const hasSet = isInitial || (!isInitial && !isModal)
80
+ // const rootRouteHasChanged = rootRoute !== element.state.rootRoute
81
+ // || (!rootRouteHasChanged && { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
79
82
 
80
83
  if (options.updateState) {
81
- element.state.update({ route, hash }, { preventContentUpdate: true })
84
+ element.state.update({ route, hash, routeInContent }, { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
82
85
  }
83
86
 
84
87
  if (hasSet) {
85
88
  element.set({
86
89
  tag: options.useFragment && 'fragment',
87
90
  extend: content
88
- })
91
+ }, (!isInitial && wasModal && { preventContentUpdate: true }))
89
92
  }
90
93
  }
91
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/router",
3
- "version": "2.12.20",
3
+ "version": "2.12.24",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -11,6 +11,6 @@
11
11
  "@domql/utils": "latest",
12
12
  "@symbo.ls/auth-redirect": "latest"
13
13
  },
14
- "gitHead": "4d1ca55e71877709a79ae02fa3973158d959017c",
14
+ "gitHead": "a6dd07436c2d667711b773c1817c483b03dcf650",
15
15
  "source": "index.js"
16
16
  }