mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 12:33:36 +09:00
avoid empty props objects
This commit is contained in:
1 parent
fbf8f7db87
commit
652a323db2
1 file changed
+10
-3
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user