Skip to content

Conversation

@RaghavArora14
Copy link

@RaghavArora14 RaghavArora14 commented Oct 24, 2025

/Fixes #1576
/claim #1576

Reproduction

Before Fix:
image
image
Small spacing - width: 0.4 height: 1
Large spacing - width: 1.6 height: 4
Test FAILED

Fix

Changed width/height calculation in getAllDimensionsForSchematicBox.ts to use fixed MIN_PADDING (0.4) instead of schPinSpacing * 2.
After Fix:
image

Result

After fix, box width stays constant at 0.4 regardless of schPinSpacing value.

Small spacing - width: 0.4 height: 1
Large spacing - width: 0.4 height: 2.8
Tests PASS

@vercel
Copy link

vercel bot commented Oct 24, 2025

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

Project Deployment Preview Comments Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview Comment Oct 27, 2025 6:06am

@RaghavArora14
Copy link
Author

hey @seveibar can i get a review on this, i reproduced this issue and then tried the fix. Please let me know if this is correct

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no point in requesting a review with failing tests

also rename your test appropriately for the directory you put it in

@seveibar
Copy link
Contributor

also you need snapshot tests

@seveibar
Copy link
Contributor

@RaghavArora14 request your assigned maintainer for review. Work with them directly, join discord if needed https://tscircuit.com/join

https://docs.google.com/spreadsheets/d/1BU96V97WA6Xv9WyjIyN1qmdWvoJgLEir8mdqz--4B_o/edit?usp=sharing

@RaghavArora14
Copy link
Author

okay thanks, will ask the maintainer soon after fixing this up

- Changed width/height calculation to use fixed MIN_PADDING (0.4) instead of schPinSpacing * 2
- This ensures box dimensions only change based on pin positions, not pin spacing
- Added tests to verify width/height remain constant when schPinSpacing changes
- Updated snapshots for affected tests

Fixes tscircuit#1576
@RaghavArora14
Copy link
Author

hey @ShiboSoftwareDev can i get a review on this please, all the tests are now passing, have reproduced the issue and added test snapshots too

@RaghavArora14
Copy link
Author

also had created a seperate branch to reproduce the issue before fixing it and that was causing some issues with the format check so had to force push sorry if that causes any issues, lmk how i can fix those

@ShiboSoftwareDev
Copy link
Contributor

combine your repros into a single circuit in a single file

Removed comments explaining fixed padding for schWidth and schHeight.
@RaghavArora14
Copy link
Author

okay resolved the comments issue, will add them into a single repro file and ask for a review is that cool?

- Check if left/right pins actually have labels (not just if pinLabels prop exists)
- Apply 0.5mm minimum width when labels are present on left/right sides
- Fixes repro3 narrow box issue while keeping schPinSpacing independent
- Extract meaningful portHints (not generic 'pin1', 'pin2') as labels
- Merge with explicit pinLabels before calling getAllDimensionsForSchematicBox
- Fixes repro3 by including USB-C port labels (B8, A5, etc.) in width calculation
- Maintains backward compatibility by filtering out auto-generated pin labels
- Access footprint.children to get portHints instead of Port objects
- Port names are auto-generated (pin1, pin2), but portHints have actual labels
- Now correctly extracts meaningful labels like 'B8', 'A5' from USB-C footprints
- repro3 and repro68 tests now pass
- Access footprint.children to get portHints instead of Port objects
- Port names are auto-generated (pin1, pin2), but portHints have actual labels
- Now correctly extracts meaningful labels like 'B8', 'A5' from USB-C footprints
- repro3 and repro68 tests now pass
- Footprint in props is still a React element, not instantiated
- Access this.children to find the instantiated Footprint component
- Now correctly extracts portHints labels (B8, A5, etc.)
- repro3 width increased from 0.4mm to 1.3mm (much better proportions)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this happened because the test has a chip with a manual footprint that has portHints={["1"]}, portHints={["2"]}, portHints={["3"]}. These are NOT generic "pin1", "pin2" format - they're just numbers "1", "2", "3".

Our filter if (!hint.match(/^pin\d+$/)) only skips hints that match the pattern "pin" followed by digits. So "1", "2", "3" would pass through and be used as labels!

This means the chip's schematic box width changed because it now thinks it has labels "1", "2", "3" to display, triggering the 0.5mm minimum width logic.

...portLabelsFromFootprint,
...props.pinLabels, // Explicit pinLabels override footprint labels
}

Copy link
Contributor

@seveibar seveibar Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove the above and your new function and do _getPinLabelsFromPorts()

const ports = this.selectAll("port")
const pinLabels: Record<string,string> = {}
for (const port of ports) {
  pinLabels[`pin${port.pin_number}`] = port.getNameOrWhatever() // see Port.ts
}
return pinLabels

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done Please check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix schPinSpacing changing the width of the schematic box

3 participants