From 40adb5ed2921bb53e9a3b48fc27788252f471fe9 Mon Sep 17 00:00:00 2001 From: Cam Pedersen Date: Fri, 5 Jun 2026 21:39:52 -0400 Subject: [PATCH] fix(electronics): Escape cancels an in-progress schematic wire MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While dogfooding the schematic editor (and wiring up the motor co-sim demo), the missing keyboard cancel for an in-progress wire was the single biggest friction point: once a wire chain started, the only way out was a right-click, which is easy to miss and impossible to script reliably. Add a window keydown handler in SchematicCanvas that calls cancelSchWire() on Escape while the wire tool is active — the universal EDA reflex, complementing the existing right-click cancel and double-click finish. Follows the Escape-to-dismiss pattern already used across ~10 components. Co-Authored-By: Claude Opus 4.8 --- .../2026-06-05-schematic-wire-escape-cancel.json | 9 +++++++++ .../src/components/electronics/SchematicCanvas.tsx | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 changelog/entries/2026-06-05-schematic-wire-escape-cancel.json diff --git a/changelog/entries/2026-06-05-schematic-wire-escape-cancel.json b/changelog/entries/2026-06-05-schematic-wire-escape-cancel.json new file mode 100644 index 00000000..c90fad95 --- /dev/null +++ b/changelog/entries/2026-06-05-schematic-wire-escape-cancel.json @@ -0,0 +1,9 @@ +{ + "id": "2026-06-05-schematic-wire-escape-cancel", + "version": "0.9.4", + "date": "2026-06-05", + "category": "fix", + "title": "Press Escape to cancel an in-progress schematic wire", + "summary": "Drawing a wire and want out? Escape now drops it — the universal EDA reflex, complementing right-click cancel and double-click finish.", + "features": ["electronics", "schematic", "ux"] +} diff --git a/packages/app/src/components/electronics/SchematicCanvas.tsx b/packages/app/src/components/electronics/SchematicCanvas.tsx index f4daa095..45b97e90 100644 --- a/packages/app/src/components/electronics/SchematicCanvas.tsx +++ b/packages/app/src/components/electronics/SchematicCanvas.tsx @@ -6,7 +6,7 @@ * Supports place, wire, label, delete, and move tools. */ -import { useRef, useCallback, useState, useMemo } from "react"; +import { useRef, useCallback, useState, useMemo, useEffect } from "react"; import { useDocumentStore, getPcbNodeIds } from "@vcad/core"; import type { SchematicComponent, SchematicWire } from "@vcad/ir"; import { useElectronicsStore } from "@/stores/electronics-store"; @@ -261,6 +261,18 @@ export function SchematicCanvas() { const select = useElectronicsStore((s) => s.select); const setHoveredNet = useElectronicsStore((s) => s.setHoveredNet); + + // Escape cancels an in-progress wire (the universal EDA reflex; complements + // the right-click cancel and double-click finish). + useEffect(() => { + const onKey = (e: KeyboardEvent) => { + if (e.key === "Escape" && schTool === "wire") { + useElectronicsStore.getState().cancelSchWire(); + } + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [schTool]); const zoomAt = useElectronicsStore((s) => s.zoomSchAt); const adjustPan = useElectronicsStore((s) => s.adjustSchPan); const startSchWire = useElectronicsStore((s) => s.startSchWire);