Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-storefront",
"version": "8.3.1",
"version": "8.3.2",
"description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.",
"module": "./index.js",
"license": "Apache-2.0",
Expand Down
16 changes: 10 additions & 6 deletions src/router/useSimpleNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default function useSimpleNavigation() {
nextNavigation.current = true
}, [])

const onNextNavigationEnd = useCallback(() => {
nextNavigation.current = false
}, [])

useEffect(() => {
async function doEffect() {
delegate('a', 'click', e => {
Expand All @@ -28,28 +32,28 @@ export default function useSimpleNavigation() {
// catch if not next link
if (href && !nextNavigation.current) {
e.preventDefault()
const url = toNextURL(href)
const url = toNextURL(href, as)
Router.push(url, as)
}
nextNavigation.current = false
})

routes.current = await fetchRouteManifest()
}

doEffect()
Router.events.on('routeChangeStart', onNextNavigation)
Router.events.on('routeChangeComplete', onNextNavigationEnd)

return () => Router.events.off('routeChangeStart', onNextNavigation)
}, [])
}

function toNextURL(href) {
const url = new URL(href, window.location.protocol + window.location.hostname)
function toNextURL(href, as) {
const url = new URL(as, window.location.protocol + '//' + window.location.hostname)

return {
pathname: url.pathname,
query: qs.parse(url.search),
pathname: href,
query: qs.parse(url.search, { ignoreQueryPrefix: true }),
}
}

Expand Down