fix: implement trace hover highlighting#149
fix: implement trace hover highlighting#149akramcodez wants to merge 2 commits intotscircuit:mainfrom
Conversation
|
@akramcodez is attempting to deploy a commit to the tscircuit Team on Vercel. A member of the Team first needs to authorize it. |
|
PTAL @nailoo |
There's no more bounties @akramcodez |
|
@Excellencedev not matters for me, I just want to contribute. |
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
|
@rushabhcodes I couldn’t find the demo at that link, so I used the example12-spice-boost-converter example to show the fix. Can you help me find one with the exact URL? The examples labeled 15 and 16 are ones I created locally for testing. |
rushabhcodes
left a comment
There was a problem hiding this comment.
This does no fixes the issue, please understand the issue first
@akramcodez |




fixes: tscircuit/tscircuit#1130
/claim tscircuit/tscircuit#1130
Problem
When hovering over traces in the schematic viewer, only the specific segment under the cursor was highlighted.
Users need to see the entire electrical net (all connected traces) to properly visualize connections such as VCC, GND, or signal paths.
Solution
This PR implements net-based connectivity highlighting.
Previous attempts (PR #142 and PR #118) used unreliable fields such as
net_idor subcircuit keys.This implementation uses the correct source of truth for electrical connectivity:
source_trace.connected_source_net_ids.Demo Video
video.mov
Technical Implementation
Algorithm
Identify source
Map the hovered
schematic_trace_idto its correspondingsource_trace.Extract nets
Retrieve
connected_source_net_idsfrom the source trace.Find related traces
Query the circuit-json graph to find all other
source_tracesthat share these Net IDs.Highlight
Map the results back to
schematic_trace_idsand apply CSS highlighting.Key Changes
lib/utils/trace-connectivity.tsAdded core logic to traverse the circuit-json graph and identify connected components.
lib/hooks/useConnectedTracesHoverHighlighting.tsManages hover event listeners on SVG elements.
Adds a 50ms debounce to avoid flickering.
Injects CSS for dynamic highlighting.
Uses a MutationObserver to support dynamic SVG updates.
lib/components/SchematicViewer.tsxIntegrated the hook and ensured it is disabled during edit mode.
Visual Design
#ff6b353px0.15s)Result
Hovering over any trace now highlights the entire connected electrical net, improving clarity and readability for schematic analysis.