Skip to content

fix(schematic): traverse descendant groups in matchpack schematic layout - #5932

Open
RainyMarks wants to merge 1 commit into
tscircuit:mainfrom
RainyMarks:fix/5573-nested-pcb-group-schematic-autolayout
Open

RainyMarks wants to merge 1 commit into
tscircuit:mainfrom
RainyMarks:fix/5573-nested-pcb-group-schematic-autolayout

Conversation

@RainyMarks

Copy link
Copy Markdown

Fixes #5573

Problem

When schematic groups (A, B) are nested inside separate physical/PCB wrapper groups (Left, Right) on a shared schematic sheet with schAutoLayoutEnabled, schematic auto-layout leaves their components overlapping at (0, 0).

Cause

In lib/components/primitive-components/Group/applySchematicMatchPackLayoutToTree.ts, nested group handling queried only direct schematic_component rows matching schematic_group_id: schematicGroup.schematic_group_id. Because each schematic_component belongs to its immediate parent schematic_group (A or B), the wrapper groups (Left, Right) had zero direct components:

  1. getNestedGroupMatchpackProxy fell back to a default 2 x 2 box centered at (0, 0) instead of measuring descendant components.
  2. Descendant component ports and connectivity keys were omitted from the matchpack input problem.
  3. Applying the solved placement shifted zero components and did not update descendant schematic_group centers, leaving R1 and R2 stacked at (0, 0).

Fix

  • Add collectNestedGroupSchematicElements in lib/components/primitive-components/Group/applySchematicMatchPackLayoutToTree.ts to walk each nested group's CircuitJsonTreeNode subtree within the active schematicSheetId (stopping at collapsed show_as_schematic_box child groups) and return its root schematic_group, descendant schematic_groups, and descendant schematic_components.
  • Use collectNestedGroupSchematicElements when computing nested group matchpack proxies/pins, building connectivity groups, and applying solved position deltas—shifting descendant schematic_components (along with their ports, texts, and schematic primitives) as well as descendant schematic_group centers while preserving PCB group structure and placement.
  • Add regression tests with schematic snapshots in tests/groups/group-schematic-matchpack-nested-pcb-groups1.test.tsx (reproducing Schematic auto-layout overlaps groups nested under separate PCB groups #5573 and verifying PCB placement is preserved) and tests/groups/group-schematic-matchpack-nested-pcb-groups2.test.tsx (multi-sheet scoping with multi-component nested groups).

Testing

  • bun test tests/groups/ tests/features/matchpack-solver-events.test.tsx tests/repros/repro88-schAutoLayoutEnabled.test.tsx tests/repros/repro139-multi-sheet-chips-auto-layout-together.test.tsx tests/repros/repro70-schematicbox-rotation-autolayout.test.tsx tests/repros/repro161-power-section-autolayout/ tests/repros/repro163-esp32-testpoint-autolayout/ tests/repros/repro164-rp2040-swd-status-led-layout.test.tsx tests/repros/repro183-battery-charger-status-led-component-overlap.test.tsx --timeout 30000 (32 pass, 1 skip, 0 fail)
  • bun test tests/scripts/ tests/components/primitive-components/schematic-section-autolayout-no-section.test.tsx tests/components/primitive-components/schematic-symbol-two-sheets-mosfet-opamp.test.tsx --timeout 30000 (4 pass, 0 fail)
  • bun run check:class-exports
  • bunx biome format (0 issues on modified files)
  • bunx tsc --noEmit (0 errors)
  • bun run build && bun run smoke-test:dist

@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tscircuit-core-benchmarks Ready Ready Preview Nov 27, 2026 1:09am UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 09312ff8 Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schematic auto-layout overlaps groups nested under separate PCB groups

1 participant