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.

update open tree state as during drag&drop

Oleg Isonenedfea09debcd
diff --git a/app/designer/shared/tree/Tree.tsx b/app/designer/shared/tree/Tree.tsx
index b441e2a312..2c4590da5c 100644
--- a/app/designer/shared/tree/Tree.tsx
+++ b/app/designer/shared/tree/Tree.tsx
@@ -1,4 +1,4 @@
-import { useState, useMemo } from "react";
+import { useState, useMemo, useEffect } from "react";
import { type Instance } from "@webstudio-is/sdk";
import {
Flex,
@@ -55,6 +55,10 @@ export const Tree = ({
}: TreeProps) => {
const [isOpen, setIsOpen] = useState(selectedInstancePath.includes(instance));
+ useEffect(() => {
+ setIsOpen(selectedInstancePath.includes(instance));
+ }, [selectedInstancePath, instance]);
+
// Text nodes have only one child which is a string.
const showChildren =
instance.children.length > 1 || typeof instance.children[0] === "object";