From c5c21d692926c46ef9e162d9263c98be75ffb279 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Mon, 29 Jun 2020 21:26:16 +0100 Subject: [PATCH] when navigating between fronend & backend, you return to the last url you worked on --- .../builder/src/pages/[application]/_reset.svelte | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/pages/[application]/_reset.svelte b/packages/builder/src/pages/[application]/_reset.svelte index d5c0ee5576..9528f25557 100644 --- a/packages/builder/src/pages/[application]/_reset.svelte +++ b/packages/builder/src/pages/[application]/_reset.svelte @@ -5,7 +5,7 @@ import { get } from "builderStore/api" import { fade } from "svelte/transition" - import { isActive, goto, layout } from "@sveltech/routify" + import { isActive, goto, layout, url } from "@sveltech/routify" import { SettingsIcon, PreviewIcon } from "components/common/Icons/" import IconButton from "components/common/IconButton.svelte" @@ -27,6 +27,17 @@ throw new Error(pkg) } } + + const topItemNavigate = path => () => { + const activeTopNav = $layout.children.find(c => $isActive(c.path)) + if (!activeTopNav) return + store.update(state => { + if (!state.previousTopNavPath) state.previousTopNavPath = {} + state.previousTopNavPath[activeTopNav.path] = window.location.pathname.replace("/_builder", "") + $goto(state.previousTopNavPath[path] || path) + return state + }) + } @@ -46,7 +57,7 @@ $goto(path)}> + on:click={topItemNavigate(path)}> {title} {/each}