diff --git a/apps/builder/app/builder/features/workspace/canvas-iframe.tsx b/apps/builder/app/builder/features/workspace/canvas-iframe.tsx index 3b0b770b937e..1b140b6ef24f 100644 --- a/apps/builder/app/builder/features/workspace/canvas-iframe.tsx +++ b/apps/builder/app/builder/features/workspace/canvas-iframe.tsx @@ -45,7 +45,15 @@ const CanvasRectUpdater = ({ } const rect = iframeRef.current.getBoundingClientRect(); - $canvasRect.set(rect); + + $canvasRect.set( + new DOMRect( + Math.round(rect.x), + Math.round(rect.y), + Math.round(rect.width), + Math.round(rect.height) + ) + ); }; setUpdateCallback(() => task); diff --git a/apps/builder/app/builder/features/workspace/canvas-tools/canvas-tools.tsx b/apps/builder/app/builder/features/workspace/canvas-tools/canvas-tools.tsx index 33762b22af9a..f855015c6141 100644 --- a/apps/builder/app/builder/features/workspace/canvas-tools/canvas-tools.tsx +++ b/apps/builder/app/builder/features/workspace/canvas-tools/canvas-tools.tsx @@ -17,7 +17,7 @@ import { Label } from "./outline/label"; import { Outline } from "./outline/outline"; import { useSubscribeDragAndDropState } from "./use-subscribe-drag-drop-state"; import { applyScale } from "./outline"; -import { $scale } from "~/builder/shared/nano-states"; +import { $clampingRect, $scale } from "~/builder/shared/nano-states"; import { BlockChildHoveredInstanceOutline } from "./outline/block-instance-outline"; const containerStyle = css({ @@ -41,11 +41,16 @@ export const CanvasTools = () => { const dragAndDropState = useStore($dragAndDropState); const instances = useStore($instances); const scale = useStore($scale); + const clampingRect = useStore($clampingRect); if (!canvasToolsVisible) { return; } + if (clampingRect === undefined) { + return; + } + if (dragAndDropState.isDragging) { if (dragAndDropState.placementIndicator === undefined) { return; @@ -59,7 +64,7 @@ export const CanvasTools = () => { return dropTargetInstance ? (