Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

avoid empty props objects

Roman Pominov652a323db226
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;