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 bug where we don't expand the new location of the selected instance on drop

Roman Pominov88befc1f452d
diff --git a/apps/designer/app/designer/shared/tree/tree.tsx b/apps/designer/app/designer/shared/tree/tree.tsx
index fecb3c27c0..582a2983e3 100644
--- a/apps/designer/app/designer/shared/tree/tree.tsx
+++ b/apps/designer/app/designer/shared/tree/tree.tsx
@@ -536,11 +536,16 @@ const useExpandState = ({
// We want to automatically expand all parents of the selected instance whenever it changes
const prevSelectedInstanceId = useRef(selectedInstanceId);
+ const prevRoot = useRef(root);
useEffect(() => {
- if (selectedInstanceId === prevSelectedInstanceId.current) {
+ if (
+ selectedInstanceId === prevSelectedInstanceId.current &&
+ prevRoot.current === root
+ ) {
return;
}
prevSelectedInstanceId.current = selectedInstanceId;
+ prevRoot.current = root;
if (selectedInstanceId === undefined) {
return;
}