diff --git a/packages/client/src/render/screenRouter.js b/packages/client/src/render/screenRouter.js index 262ed65f66..64319102f8 100644 --- a/packages/client/src/render/screenRouter.js +++ b/packages/client/src/render/screenRouter.js @@ -56,8 +56,30 @@ export const screenRouter = ({ screens, onScreenSelected, appRootPath }) => { } } + function click(e) { + const x = e.target.closest("a") + const y = x && x.getAttribute("href") + + if ( + e.ctrlKey || + e.metaKey || + e.altKey || + e.shiftKey || + e.button || + e.defaultPrevented + ) + return + + const target = x.target || "_self" + if (!y || target !== "_self" || x.host !== location.host) return + + e.preventDefault() + route(y) + } + addEventListener("popstate", route) addEventListener("pushstate", route) + addEventListener("click", click) return route } diff --git a/packages/standard-components/src/Link.svelte b/packages/standard-components/src/Link.svelte index d557df6abd..ef0b71d62e 100644 --- a/packages/standard-components/src/Link.svelte +++ b/packages/standard-components/src/Link.svelte @@ -13,7 +13,7 @@ $: target = openInNewTab ? "_blank" : "_self" -{text} +{text}