diff --git a/packages/builder/src/helpers/urlStateSync.js b/packages/builder/src/helpers/urlStateSync.js index c4c48fb3fb..04c639b3ec 100644 --- a/packages/builder/src/helpers/urlStateSync.js +++ b/packages/builder/src/helpers/urlStateSync.js @@ -65,6 +65,10 @@ export const syncURLToState = options => { params = res.params } } + // Clean URL + if (url?.endsWith("/index")) { + url = url.replace("/index", "") + } log("Navigating to", url, "with params", params) cachedGoto(url, params) } diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_layout.svelte index 51c3c64321..932a3d360a 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_layout.svelte @@ -13,12 +13,8 @@ $: params = routify.params $: routeComponentId = $params.componentId - const cleanUrl = url => { - // Strip trailing slashes - if (url?.endsWith("/index")) { - url = url.replace("/index", "") - } - // Hide new component panel whenever component ID changes + // Hide new component panel whenever component ID changes + const closeNewComponentPanel = url => { if (url?.endsWith("/new")) { url = url.replace("/new", "") } @@ -40,7 +36,7 @@ fallbackUrl: "../", store, routify, - beforeNavigate: cleanUrl, + beforeNavigate: closeNewComponentPanel, }) onDestroy(stopSyncing)