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.

fix a crash when setting selected instance inside transaction

Roman Pominovd92e3d5bda1c
diff --git a/apps/designer/app/canvas/shared/instance.ts b/apps/designer/app/canvas/shared/instance.ts
index 0a8f01d074..eb73ce930d 100644
--- a/apps/designer/app/canvas/shared/instance.ts
+++ b/apps/designer/app/canvas/shared/instance.ts
@@ -127,12 +127,17 @@ export const useReparentInstance = () => {
dropTarget.instanceId,
dropTarget.position
);
-
- // Make the drag item selected
- if (selectedInstance?.id !== instanceId) {
- setSelectedInstance(findInstanceById(rootInstance, instanceId));
- }
});
+
+ // Make the drag item the selected instance
+ if (
+ selectedInstance?.id !== instanceId &&
+ rootInstanceContainer.value !== undefined
+ ) {
+ setSelectedInstance(
+ findInstanceById(rootInstanceContainer.value, instanceId)
+ );
+ }
});
};