From cdcc9d049bab36127cbcbd1272e93af6f5b86c5b Mon Sep 17 00:00:00 2001 From: clawdbot Date: Thu, 29 Jan 2026 09:59:05 +0800 Subject: [PATCH] fix(editor): clamp resize min size and bounds --- packages/editor/src/editor/store.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/editor/store.ts b/packages/editor/src/editor/store.ts index 800f5a3..2d3efdb 100644 --- a/packages/editor/src/editor/store.ts +++ b/packages/editor/src/editor/store.ts @@ -1159,13 +1159,14 @@ export function editorReducer(state: EditorRuntimeState, action: EditorAction): const r0 = drag.snapshot.get(n.id); if (!r0) return n; - const nextRect: Rect = { + const nextRectRaw: Rect = { x: Math.round(bbox1.x + (r0.x - bbox0.x) * sx), y: Math.round(bbox1.y + (r0.y - bbox0.y) * sy), - w: Math.max(0, Math.round(r0.w * sx)), - h: Math.max(0, Math.round(r0.h * sy)), + w: Math.max(1, Math.round(r0.w * sx)), + h: Math.max(1, Math.round(r0.h * sy)), }; + const nextRect = clampRectToBounds(nextRectRaw, bounds, 50); return { ...n, rect: nextRect }; }); @@ -1185,8 +1186,8 @@ export function editorReducer(state: EditorRuntimeState, action: EditorAction): const rect: Rect = { x: target.x + (isLeft ? dx : 0), y: target.y + (isTop ? dy : 0), - w: Math.max(0, newW), - h: Math.max(0, newH), + w: Math.max(1, newW), + h: Math.max(1, newH), }; // goView-like: only snap when enabled and resizing a single selected node.