From 34509e0c128d71f4b3f6e3f96d07b71be6ebf80d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 6 Jan 2021 10:14:05 +0000 Subject: [PATCH] Prevent client app links from functioning in the builder preview --- packages/client/src/sdk.js | 2 +- packages/client/src/utils/linkable.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 packages/client/src/utils/linkable.js diff --git a/packages/client/src/sdk.js b/packages/client/src/sdk.js index a0b8aa6719..fefd659986 100644 --- a/packages/client/src/sdk.js +++ b/packages/client/src/sdk.js @@ -1,8 +1,8 @@ import * as API from "./api" import { authStore, routeStore, screenStore, bindingStore } from "./store" import { styleable } from "./utils/styleable" +import { linkable } from "./utils/linkable" import { getAppId } from "./utils/getAppId" -import { link as linkable } from "svelte-spa-router" import DataProvider from "./components/DataProvider.svelte" export default { diff --git a/packages/client/src/utils/linkable.js b/packages/client/src/utils/linkable.js new file mode 100644 index 0000000000..13549e4c5c --- /dev/null +++ b/packages/client/src/utils/linkable.js @@ -0,0 +1,10 @@ +import { get } from "svelte/store" +import { link } from "svelte-spa-router" +import { builderStore } from "../store" + +export const linkable = (node, href) => { + if (get(builderStore).inBuilder) { + return + } + link(node, href) +}