Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions src/components/ElementOverlayBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const getTextForHighlightedPrimitive = (
.filter((ph) => !ph.includes("unnamed_"))
// reverse alphabetical order
.sort((a, b) => b.localeCompare(a))

const parentName =
_parent_source_component &&
"name" in _parent_source_component &&
Expand Down Expand Up @@ -259,15 +258,32 @@ export const ElementOverlayBox = ({
s.is_moving_component,
s.is_showing_multiple_traces_length,
])
const hasSmtPadAndTrace =
highlightedPrimitives.some((p) => 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<AnyCircuitElement>()
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,
Expand Down
27 changes: 27 additions & 0 deletions src/examples/2026/plated_hole_hover_fix.fixture.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Circuit } from "@tscircuit/core"
import { PCBViewer } from "../../PCBViewer"

export const PlatedHoleHoverFix = () => {
const circuit = new Circuit()

circuit.add(
<board pcbX={0} pcbY={0} width="40mm" height="30mm">
<chip
name="U1"
footprint="pinrow6_rows1_p2.54mm_id1mm_od1.5mm_male"
pcbX={0}
pcbY={0}
/>
</board>,
)

const soup = circuit.getCircuitJson()

return (
<div style={{ backgroundColor: "black", width: "100%", height: "100vh" }}>
<PCBViewer circuitJson={soup as any} />
</div>
)
}

export default PlatedHoleHoverFix
Loading