fix(editor): clamp resize min size and bounds

This commit is contained in:
clawdbot 2026-01-29 09:59:05 +08:00
parent 78b7fbd9a7
commit cdcc9d049b

View File

@ -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.