From daa171754560d63c08845ec24e1c35e995328171 Mon Sep 17 00:00:00 2001 From: imrishabh18 Date: Fri, 24 Oct 2025 04:25:06 +0530 Subject: [PATCH 1/2] fix the side mapping --- ...Group_doInitialSchematicLayoutMatchPack.ts | 10 ++++++- ...efault-facing-direction-schematic.snap.svg | 26 +++++++++++++++++++ ...inheader-default-facing-direction.test.tsx | 18 +++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/repros/__snapshots__/repro67-pinheader-default-facing-direction-schematic.snap.svg create mode 100644 tests/repros/repro67-pinheader-default-facing-direction.test.tsx diff --git a/lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts b/lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts index c02bf6990..ccb89664c 100644 --- a/lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts +++ b/lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts @@ -1,6 +1,5 @@ import { getCircuitJsonTree, - transformSchematicElements, type CircuitJsonTreeNode, type CircuitJsonUtilObjects, } from "@tscircuit/circuit-json-util" @@ -775,6 +774,15 @@ export function Group_doInitialSchematicLayoutMatchPack< originalDirection, placement.ccwRotationDegrees, ) + // Update side_of_component to match the new facing direction + const facingToSideMap = { + left: "left", + right: "right", + up: "top", + down: "bottom", + } as const + port.side_of_component = + facingToSideMap[port.facing_direction] || port.side_of_component } // Also rotate text positions diff --git a/tests/repros/__snapshots__/repro67-pinheader-default-facing-direction-schematic.snap.svg b/tests/repros/__snapshots__/repro67-pinheader-default-facing-direction-schematic.snap.svg new file mode 100644 index 000000000..93f4b693a --- /dev/null +++ b/tests/repros/__snapshots__/repro67-pinheader-default-facing-direction-schematic.snap.svg @@ -0,0 +1,26 @@ +-1,-2-1,-1-1,0-1,1-1,2-1,3-1,40,-20,-10,00,10,20,30,41,-21,-11,01,11,21,31,42,-22,-12,02,12,22,32,4P11234P21234 \ No newline at end of file diff --git a/tests/repros/repro67-pinheader-default-facing-direction.test.tsx b/tests/repros/repro67-pinheader-default-facing-direction.test.tsx new file mode 100644 index 000000000..e9d74c068 --- /dev/null +++ b/tests/repros/repro67-pinheader-default-facing-direction.test.tsx @@ -0,0 +1,18 @@ +import { it, expect } from "bun:test" +import { getTestFixture } from "tests/fixtures/get-test-fixture" + +it("repro67: pinheader default facingDirection for autolayout", async () => { + const { circuit } = getTestFixture() + + circuit.add( + + + + + , + ) + + await circuit.renderUntilSettled() + + expect(circuit).toMatchSchematicSnapshot(import.meta.path) +}) From a6623a00366b951cb625e02ed56f9756c401817e Mon Sep 17 00:00:00 2001 From: imrishabh18 Date: Fri, 24 Oct 2025 04:31:32 +0530 Subject: [PATCH 2/2] remove mapping --- .../Group/Group_doInitialSchematicLayoutMatchPack.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts b/lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts index ccb89664c..6e61bcd39 100644 --- a/lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts +++ b/lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchPack.ts @@ -774,15 +774,9 @@ export function Group_doInitialSchematicLayoutMatchPack< originalDirection, placement.ccwRotationDegrees, ) - // Update side_of_component to match the new facing direction - const facingToSideMap = { - left: "left", - right: "right", - up: "top", - down: "bottom", - } as const port.side_of_component = - facingToSideMap[port.facing_direction] || port.side_of_component + (port.facing_direction as "left" | "right" | "top" | "bottom") || + port.side_of_component } // Also rotate text positions