From 62502b7e3562437977dcf0bb9a6321fa42dd1183 Mon Sep 17 00:00:00 2001 From: Formsmith746 <214276465+Formsmith746@users.noreply.github.com> Date: Sun, 30 Aug 2026 08:26:13 +0300 Subject: [PATCH] fix: duplicate shapes without position offset --- apps/web/src/components/SketchForgeEditor.tsx | 9 +-------- tests/unit/workplaneShapes.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/web/src/components/SketchForgeEditor.tsx b/apps/web/src/components/SketchForgeEditor.tsx index 0291882..5363442 100644 --- a/apps/web/src/components/SketchForgeEditor.tsx +++ b/apps/web/src/components/SketchForgeEditor.tsx @@ -7083,14 +7083,7 @@ export function SketchForgeEditor({ setNotice("Select a shape first"); return; } - const duplicates = selectedShapes.map((shape) => { - const duplicate = cloneWorkplaneShapeTreeWithFreshIds(shape, "copy"); - return { - ...duplicate, - x: Math.min(110, shape.x + 8), - z: Math.min(110, shape.z + 8), - }; - }); + const duplicates = selectedShapes.map((shape) => cloneWorkplaneShapeTreeWithFreshIds(shape, "copy")); commitShapes([...shapes, ...duplicates], duplicates.map((shape) => shape.id), `Duplicated ${duplicates.length} shape${duplicates.length === 1 ? "" : "s"}`); }, [commitShapes, hasSelection, selectedShapes, shapes]); diff --git a/tests/unit/workplaneShapes.test.ts b/tests/unit/workplaneShapes.test.ts index ed81518..206bd83 100644 --- a/tests/unit/workplaneShapes.test.ts +++ b/tests/unit/workplaneShapes.test.ts @@ -157,6 +157,9 @@ describe("workplane shape helpers", () => { const original = shape({ id: "outer-group", kind: "mesh", + x: 14, + z: -9, + elevation: 3, groupedShapes: [ shape({ id: "round-roof-child", kind: "roundRoof" }), shape({ @@ -177,6 +180,7 @@ describe("workplane shape helpers", () => { expect(new Set(duplicateIds).size).toBe(duplicateIds.length); expect(duplicateIds.every((id) => !originalIds.includes(id))).toBe(true); + expect(duplicate).toMatchObject({ x: 14, z: -9, elevation: 3 }); expect(original.groupedShapes?.[0].id).toBe("round-roof-child"); expect(duplicate.groupedShapes?.[0].kind).toBe("roundRoof"); });