feat: highlight traces and same-net traces on hover#164
feat: highlight traces and same-net traces on hover#164aifunmobi wants to merge 3 commits intotscircuit:mainfrom
Conversation
When hovering over a schematic trace, the trace and all other traces connected to the same net change color to indicate interactivity. Net groups are precomputed from circuit-json relationships for efficient pointer event handling. Closes tscircuit/tscircuit#1130
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The previous approach using BFS over circuit-json source_trace relationships missed connections. The SVG already encodes correct net grouping via data-subcircuit-connectivity-map-key attributes set by circuit-to-svg. This is simpler and handles all edge cases including traces without net keys.
Demo — Trace Hover Highlighting (example9)How to test
Same-net grouping verificationIn example9, traces are grouped by net using the
Verified via browser console: // Hovering trace_0 → both net2 traces turn blue
trace_0: stroke="#60a5fa" // ✅ highlighted
trace_1: stroke="#60a5fa" // ✅ same-net highlighted
trace_2: stroke="rgb(0, 150, 0)" // unchanged (different net)
trace_3: stroke="rgb(0, 150, 0)" // unchanged (no net)This is the exact issue that caused PRs #142, #149, and #157 to be rejected — incomplete net grouping where only the directly hovered trace highlighted but not all same-net traces. |
Demo VideoExample 9 (RC charging voltage divider): Hovering over a trace highlights it and all same-net traces in blue ( |
rushabhcodes
left a comment
There was a problem hiding this comment.
Use the repro give https://tscircuit.com/MrPicklePinosaur/tscircuit_demo#schematic to demonstrate your fix
Loads MrPicklePinosaur/tscircuit_demo circuit from tscircuit registry to demonstrate trace hover highlighting on a complex real-world schematic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Demo on MrPicklePinosaur/tscircuit_demoAdded a new fixture ( How to test
This is the exact repro from https://tscircuit.com/MrPicklePinosaur/tscircuit_demo#schematic rendered with our PR's hover highlight hook. |

Summary
#60a5fa)useTraceHoverHighlighthook follows the same pattern as existinguseChangeSchematicTracesForMovedComponentsCloses tscircuit/tscircuit#1130
/claim #1130
How it works
circuitJson: schematic traces → source traces → connected portspointermove, detects which trace group the pointer is over viaElement.closest("[data-schematic-trace-id]")Test plan
#60a5fa)