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.

close the sidebar when dragging on the canvas #10

Oleg Isonen5c72ed5a8251
diff --git a/app/designer/features/sidebar-left/sidebar-left.tsx b/app/designer/features/sidebar-left/sidebar-left.tsx
index 0f45dea50d..c50c946a5e 100644
--- a/app/designer/features/sidebar-left/sidebar-left.tsx
+++ b/app/designer/features/sidebar-left/sidebar-left.tsx
@@ -38,19 +38,19 @@ export const SidebarLeft = ({
const [isDragging, setIsDragging] = useState(false);
const { TabContent } = activeTab === "none" ? none : panels[activeTab];
- useSubscribe<"clickCanvas">("clickCanvas", () => {
- setActiveTab("none");
- });
+ const close = useCallback(() => setActiveTab("none"), []);
+ useSubscribe<"clickCanvas">("clickCanvas", close);
+ useSubscribe("dragStartInstance", close);
const handleDragChange = useCallback(
(isDragging: boolean) => {
// After dragging is done, container is going to become visible
// and we need to close it for good.
- if (isDragging === false) setActiveTab("none");
+ if (isDragging === false) close();
setIsDragging(isDragging);
onDragChange(isDragging);
},
- [onDragChange]
+ [onDragChange, close]
);
return (