From b067c78313bb472e74987e59b06a2933d1bce1c6 Mon Sep 17 00:00:00 2001 From: techmannih Date: Fri, 13 Mar 2026 00:58:22 +0530 Subject: [PATCH 1/5] fix: prevent duplicate pin indicators by deduplicating primitives by element --- src/components/ElementOverlayBox.tsx | 34 ++++++++++++++----- .../plated_hole_hover_fix.fixture.tsx | 27 +++++++++++++++ 2 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 src/examples/plated_hole_hover_fix.fixture.tsx diff --git a/src/components/ElementOverlayBox.tsx b/src/components/ElementOverlayBox.tsx index 35f49fa3..db29b04c 100644 --- a/src/components/ElementOverlayBox.tsx +++ b/src/components/ElementOverlayBox.tsx @@ -52,7 +52,7 @@ export const getTextForHighlightedPrimitive = ( .filter((ph) => !ph.includes("unnamed_")) // reverse alphabetical order .sort((a, b) => b.localeCompare(a)) - + console.log("port_hints", port_hints) const parentName = _parent_source_component && "name" in _parent_source_component && @@ -146,6 +146,7 @@ export const HighlightedPrimitiveBoxWithText = ({ if (primitiveElement.type === "pcb_trace") { const traceTextContext = { primitiveElement, elements } const overlayInfo = getTraceOverlayInfo(traceTextContext) + console.log(overlayInfo?.text) if (!overlayInfo) return null const yOffset = mousePos.y - 35 @@ -153,8 +154,6 @@ export const HighlightedPrimitiveBoxWithText = ({ return (
p._element.type === "pcb_smtpad") && - highlightedPrimitives.some((p) => p._element.type === "pcb_trace") + const hasSmtPadOrPlatedHoleAndTrace = + highlightedPrimitives.some( + (p) => + p._element.type === "pcb_smtpad" || + p._element.type === "pcb_plated_hole", + ) && highlightedPrimitives.some((p) => p._element.type === "pcb_trace") let primitives = highlightedPrimitives - // If both smtpad and trace are present, only return smtpads - if (hasSmtPadAndTrace) { - primitives = primitives.filter((p) => p._element.type === "pcb_smtpad") + // If both a pad (smtpad or plated hole) and a trace are present, only return pads + if (hasSmtPadOrPlatedHoleAndTrace) { + primitives = primitives.filter( + (p) => + p._element.type === "pcb_smtpad" || + p._element.type === "pcb_plated_hole", + ) } + + // Deduplicate primitives by element to avoid multiple boxes for the same element + // (e.g. plated hole has a copper pad primitive and a drill hole primitive) + const seenElements = new Set() + primitives = primitives.filter((p) => { + if (seenElements.has(p._element)) return false + seenElements.add(p._element) + return true + }) + // When having multiple traces filter traces to get only the shortest one primitives = filterTracesIfMultiple({ primitives, diff --git a/src/examples/plated_hole_hover_fix.fixture.tsx b/src/examples/plated_hole_hover_fix.fixture.tsx new file mode 100644 index 00000000..f444fa55 --- /dev/null +++ b/src/examples/plated_hole_hover_fix.fixture.tsx @@ -0,0 +1,27 @@ +import { Circuit } from "@tscircuit/core" +import { PCBViewer } from "../PCBViewer" + +export const PlatedHoleHoverFix = () => { + const circuit = new Circuit() + + circuit.add( + + + , + ) + + const soup = circuit.getCircuitJson() + + return ( +
+ +
+ ) +} + +export default PlatedHoleHoverFix From 1eb5b92895b5d090d58c7146d78ff25e5811d256 Mon Sep 17 00:00:00 2001 From: techmannih Date: Fri, 13 Mar 2026 01:00:09 +0530 Subject: [PATCH 2/5] format --- src/components/ElementOverlayBox.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/ElementOverlayBox.tsx b/src/components/ElementOverlayBox.tsx index db29b04c..281ebd89 100644 --- a/src/components/ElementOverlayBox.tsx +++ b/src/components/ElementOverlayBox.tsx @@ -52,7 +52,6 @@ export const getTextForHighlightedPrimitive = ( .filter((ph) => !ph.includes("unnamed_")) // reverse alphabetical order .sort((a, b) => b.localeCompare(a)) - console.log("port_hints", port_hints) const parentName = _parent_source_component && "name" in _parent_source_component && @@ -146,7 +145,6 @@ export const HighlightedPrimitiveBoxWithText = ({ if (primitiveElement.type === "pcb_trace") { const traceTextContext = { primitiveElement, elements } const overlayInfo = getTraceOverlayInfo(traceTextContext) - console.log(overlayInfo?.text) if (!overlayInfo) return null const yOffset = mousePos.y - 35 From a4b62fb6bacfaea40787f44815f1736733cb8d29 Mon Sep 17 00:00:00 2001 From: techmannih Date: Fri, 13 Mar 2026 01:06:23 +0530 Subject: [PATCH 3/5] up --- src/examples/{ => 2026}/plated_hole_hover_fix.fixture.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/examples/{ => 2026}/plated_hole_hover_fix.fixture.tsx (92%) diff --git a/src/examples/plated_hole_hover_fix.fixture.tsx b/src/examples/2026/plated_hole_hover_fix.fixture.tsx similarity index 92% rename from src/examples/plated_hole_hover_fix.fixture.tsx rename to src/examples/2026/plated_hole_hover_fix.fixture.tsx index f444fa55..789c52e5 100644 --- a/src/examples/plated_hole_hover_fix.fixture.tsx +++ b/src/examples/2026/plated_hole_hover_fix.fixture.tsx @@ -1,5 +1,5 @@ import { Circuit } from "@tscircuit/core" -import { PCBViewer } from "../PCBViewer" +import { PCBViewer } from "../../PCBViewer" export const PlatedHoleHoverFix = () => { const circuit = new Circuit() From 5cf1dc1182e8847d8a1da6529200d8c5284faaf2 Mon Sep 17 00:00:00 2001 From: techmannih Date: Fri, 13 Mar 2026 01:07:54 +0530 Subject: [PATCH 4/5] update --- src/components/ElementOverlayBox.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/ElementOverlayBox.tsx b/src/components/ElementOverlayBox.tsx index 281ebd89..bb342d88 100644 --- a/src/components/ElementOverlayBox.tsx +++ b/src/components/ElementOverlayBox.tsx @@ -54,9 +54,9 @@ export const getTextForHighlightedPrimitive = ( .sort((a, b) => b.localeCompare(a)) const parentName = _parent_source_component && - "name" in _parent_source_component && - _parent_source_component.name && - !_parent_source_component.name.includes("unnamed_") + "name" in _parent_source_component && + _parent_source_component.name && + !_parent_source_component.name.includes("unnamed_") ? _parent_source_component.name : null @@ -115,8 +115,8 @@ export const HighlightedPrimitiveBoxWithText = ({ const color: string = layerColorHightlightMap[ - (primitive as any)?._element - ?.layer as keyof typeof layerColorHightlightMap + (primitive as any)?._element + ?.layer as keyof typeof layerColorHightlightMap ] ?? "red" // Check for rotation on the parent PCB component @@ -152,6 +152,8 @@ export const HighlightedPrimitiveBoxWithText = ({ return (
Date: Fri, 13 Mar 2026 01:08:24 +0530 Subject: [PATCH 5/5] firmar --- src/components/ElementOverlayBox.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/ElementOverlayBox.tsx b/src/components/ElementOverlayBox.tsx index bb342d88..3f3bc68e 100644 --- a/src/components/ElementOverlayBox.tsx +++ b/src/components/ElementOverlayBox.tsx @@ -54,9 +54,9 @@ export const getTextForHighlightedPrimitive = ( .sort((a, b) => b.localeCompare(a)) const parentName = _parent_source_component && - "name" in _parent_source_component && - _parent_source_component.name && - !_parent_source_component.name.includes("unnamed_") + "name" in _parent_source_component && + _parent_source_component.name && + !_parent_source_component.name.includes("unnamed_") ? _parent_source_component.name : null @@ -115,8 +115,8 @@ export const HighlightedPrimitiveBoxWithText = ({ const color: string = layerColorHightlightMap[ - (primitive as any)?._element - ?.layer as keyof typeof layerColorHightlightMap + (primitive as any)?._element + ?.layer as keyof typeof layerColorHightlightMap ] ?? "red" // Check for rotation on the parent PCB component