From 8b4bd84ab5a9dd9d3d5a2ab6d21d375a4204e96a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 29 Nov 2021 08:30:52 +0000 Subject: [PATCH] Preserve bindings when duplicating components --- packages/builder/src/builderStore/store/frontend.js | 4 ++-- .../design/NavigationPanel/ComponentDropdownMenu.svelte | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 1f1fb035a4..c94c759792 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -524,7 +524,7 @@ export const getFrontendStore = () => { } } }, - paste: async (targetComponent, mode) => { + paste: async (targetComponent, mode, preserveBindings = false) => { let promises = [] store.update(state => { // Stop if we have nothing to paste @@ -536,7 +536,7 @@ export const getFrontendStore = () => { const cut = state.componentToPaste.isCut // immediately need to remove bindings, currently these aren't valid when pasted - if (!cut) { + if (!cut && !preserveBindings) { state.componentToPaste = removeBindings(state.componentToPaste) } diff --git a/packages/builder/src/components/design/NavigationPanel/ComponentDropdownMenu.svelte b/packages/builder/src/components/design/NavigationPanel/ComponentDropdownMenu.svelte index 06293e4168..56c5eef2ad 100644 --- a/packages/builder/src/components/design/NavigationPanel/ComponentDropdownMenu.svelte +++ b/packages/builder/src/components/design/NavigationPanel/ComponentDropdownMenu.svelte @@ -53,7 +53,7 @@ const duplicateComponent = () => { storeComponentForCopy(false) - pasteComponent("below") + pasteComponent("below", true) } const deleteComponent = async () => { @@ -69,9 +69,9 @@ store.actions.components.copy(component, cut) } - const pasteComponent = mode => { + const pasteComponent = (mode, preserveBindings = false) => { // lives in store - also used by drag drop - store.actions.components.paste(component, mode) + store.actions.components.paste(component, mode, preserveBindings) }