From 652a323db22669b6fe4cd07123729a36b41b74ad Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Mon, 21 Nov 2022 12:08:03 +0400 Subject: [PATCH] avoid empty props objects --- apps/designer/app/shared/copy-paste.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/designer/app/shared/copy-paste.ts b/apps/designer/app/shared/copy-paste.ts index 750769caa2..008d4be7f1 100644 --- a/apps/designer/app/shared/copy-paste.ts +++ b/apps/designer/app/shared/copy-paste.ts @@ -5,7 +5,9 @@ import { useSubscribe, type Publish } from "~/shared/pubsub"; import { useSelectedInstanceData } from "~/designer/shared/nano-states"; import { useRootInstance } from "./nano-states"; -let currentData: { instance: Instance; props: InstanceProps } | undefined; +let currentData: + | { instance: Instance; props: InstanceProps | undefined } + | undefined; export const useSubscribeCopyPaste = (publish: Publish) => { const [selectedInstanceData] = useSelectedInstanceData(); @@ -22,7 +24,13 @@ export const useSubscribeCopyPaste = (publish: Publish) => { if (instance === undefined) { return; } - currentData = { instance, props: selectedInstanceData.props }; + currentData = { + instance, + props: + selectedInstanceData.props.props.length > 0 + ? selectedInstanceData.props + : undefined, + }; }); useSubscribe("paste", () => { @@ -32,7 +40,6 @@ export const useSubscribeCopyPaste = (publish: Publish) => { const instance = utils.tree.cloneInstance(currentData.instance); - // @todo: look into why in the old code they were undefined sometimes const props = currentData.props ? cloneProps(currentData.props, { instanceId: instance.id }) : undefined;