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.

remove unnecessary optimisation

Roman Pominovcbec58bfcedc
diff --git a/apps/designer/app/designer/shared/tree/tree-node.tsx b/apps/designer/app/designer/shared/tree/tree-node.tsx
index 25082a8ffe..a48cad9f34 100644
--- a/apps/designer/app/designer/shared/tree/tree-node.tsx
+++ b/apps/designer/app/designer/shared/tree/tree-node.tsx
@@ -128,23 +128,27 @@ export const TreeNode = forwardRef<HTMLDivElement, TreeNodeProps>(
<Text size="1">{label}</Text>
</Button>
</Flex>
- {isExpandable && (isExpanded || animate) && (
+ {isExpandable && (
<CollapsibleContent
onAnimationEnd={handleAnimationEnd}
ref={collapsibleContentRef}
>
- {instance.children.flatMap((child) =>
- typeof child === "string"
- ? []
- : [
- <TreeNode
- key={child.id}
- instance={child}
- level={level + 1}
- {...commonProps}
- />,
- ]
- )}
+ {
+ // CollapsibleContent automatically doesn't render children when collapsed.
+ // No need to worry about optimizing this.
+ instance.children.flatMap((child) =>
+ typeof child === "string"
+ ? []
+ : [
+ <TreeNode
+ key={child.id}
+ instance={child}
+ level={level + 1}
+ {...commonProps}
+ />,
+ ]
+ )
+ }
</CollapsibleContent>
)}
</Collapsible.Root>