Skip to content

feat: highlight all same-net traces on hover via JS DOM class toggling#207

Open
onchito-walks wants to merge 3 commits into
tscircuit:mainfrom
onchito-walks:fix/trace-hover-color
Open

feat: highlight all same-net traces on hover via JS DOM class toggling#207
onchito-walks wants to merge 3 commits into
tscircuit:mainfrom
onchito-walks:fix/trace-hover-color

Conversation

@onchito-walks
Copy link
Copy Markdown

Summary

  • Adds useTraceHoverHighlight hook that highlights all traces sharing the same data-subcircuit-connectivity-map-key when any trace in that net is hovered
  • Uses reliable JavaScript DOM class manipulation (mouseenter/mouseleave) instead of the CSS-only :has() approach which has inconsistent SVG-browser support
  • Handles both <g class="trace"> base groups and <g class="trace-overlays"> crossing overlay groups
  • Toggles .trace-highlighted CSS class with filter: invert(1) visual effect
  • Builds on the existing SVG markup structure from circuit-to-svg (no changes needed there)

Verification

  • bun run build → passes
  • Applied bun run format

Notes

/claim #1130

Adds useTraceHoverHighlight hook that finds all traces sharing the same data-subcircuit-connectivity-map-key on mouseenter/mouseleave and toggles a .trace-highlighted class on matching groups.\n\nThe CSS-only  approach from circuit-to-svg has inconsistent SVG-browser support. This JS approach uses direct DOM class manipulation which is reliable across all contexts.\n\nCo-authored-by: rdthree <rdthree@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

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

Project Deployment Actions Updated (UTC)
schematic-viewer Ready Ready Preview, Comment May 21, 2026 1:04am

Request Review

Tests the hook's core interaction logic: class toggling on mouseenter/mouseleave,
same-net vs different-net highlighting, overlay propagation, and cleanup on unmount.

6 tests, 0 failures. First tests in this repository.
@onchito-walks
Copy link
Copy Markdown
Author

Updated with tests. Added 6 DOM-based tests covering:

  • same-net highlighting on hover
  • highlight removal on mouseout to different net
  • highlight persistence on mouseout to same net
  • highlight switching between nets
  • overlay group triggering
  • cleanup correctness (no leaked listeners)

Run with bun test --preload ./tests/setup.ts

Also fixes MouseEvent type compatibility with addEventListener signatures.
Both the hook and test use (e as MouseEvent).relatedTarget instead of
declaring handlers as MouseEvent (which is incompatible with EventListener).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant