From 7ae62ee727142af5696648e21600b12f6dc6c69d Mon Sep 17 00:00:00 2001 From: KenLiu Date: Wed, 13 May 2026 16:09:37 +0800 Subject: [PATCH] fix: highlight same-net schematic traces on hover --- lib/components/SchematicViewer.tsx | 17 ++++++ lib/hooks/useTraceNetHoverHighlight.ts | 79 ++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 lib/hooks/useTraceNetHoverHighlight.ts diff --git a/lib/components/SchematicViewer.tsx b/lib/components/SchematicViewer.tsx index ab4fd20..dfc96af 100644 --- a/lib/components/SchematicViewer.tsx +++ b/lib/components/SchematicViewer.tsx @@ -5,6 +5,7 @@ import { import { su } from "@tscircuit/soup-util" import { useChangeSchematicComponentLocationsInSvg } from "lib/hooks/useChangeSchematicComponentLocationsInSvg" import { useChangeSchematicTracesForMovedComponents } from "lib/hooks/useChangeSchematicTracesForMovedComponents" +import { useTraceNetHoverHighlight } from "lib/hooks/useTraceNetHoverHighlight" import { useSchematicGroupsOverlay } from "lib/hooks/useSchematicGroupsOverlay" import { enableDebug } from "lib/utils/debug" import { useCallback, useEffect, useMemo, useRef, useState } from "react" @@ -345,6 +346,11 @@ export const SchematicViewer = ({ editEvents: editEventsWithUnappliedEditEvents, }) + useTraceNetHoverHighlight({ + svgDivRef, + circuitJsonKey, + }) + // Add group overlays when enabled useSchematicGroupsOverlay({ svgDivRef, @@ -396,6 +402,17 @@ export const SchematicViewer = ({ return ( + {onSchematicComponentClicked && (