From a6edf37b3f4d5825acf0bfe7fc26b0d35355878f Mon Sep 17 00:00:00 2001 From: gherkin Date: Wed, 28 Oct 2026 14:53:20 +0100 Subject: [PATCH 1/3] Arrow keys in the part list only hover, Enter pins and selects An arrow key moved the selection and pinned the part it landed on. Now it moves a focus row and hovers the part, like the mouse does. Enter pins and selects the focused part. Escape in the part search clears the hover. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UCbPYsA5LYNX8HZaGGZCpK --- tests/browser/interaction.spec.js | 24 ++++++++++++++++++------ web/app.js | 19 +++++++++++-------- web/viewer.css | 4 +++- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/tests/browser/interaction.spec.js b/tests/browser/interaction.spec.js index 491bd55..2db7425 100644 --- a/tests/browser/interaction.spec.js +++ b/tests/browser/interaction.spec.js @@ -1316,35 +1316,47 @@ test('arrow keys and Enter select a net from the search list', async ({ page }) expect((await state(page)).selectedNet).toBe(net); }); -test('an arrow key onto a pinned part keeps its pin', async ({ page }) => { +test('arrow keys in the part list only hover, Enter pins and selects', async ({ page }) => { await load(page); await page.locator('#tab-components').click(); const rows = page.locator('#comp-tbody .comp-row'); const a = Number(await rows.nth(0).getAttribute('data-idx')); const b = Number(await rows.nth(1).getAttribute('data-idx')); - await rows.nth(1).click(); - await settle(page); await rows.nth(0).click(); await settle(page); + await page.mouse.move(0, 0); await page.keyboard.press('ArrowDown'); await settle(page); - expect((await state(page)).selectedFootprintIdx).toBe(b); + await expect(page.locator('#comp-tbody .comp-row.focused')).toHaveAttribute('data-idx', String(b)); + let s = await state(page); + expect(s.selectedFootprintIdx).toBe(a); + expect(s.highlightedFootprints).toEqual([b]); + expect(await page.evaluate((b) => !!pinnedComponents[b], b)).toBe(false); + + await page.keyboard.press('Enter'); + await settle(page); + s = await state(page); + expect(s.selectedFootprintIdx).toBe(b); + expect(s.highlightedFootprints).toEqual([]); expect(await page.evaluate(([a, b]) => [!!pinnedComponents[a], !!pinnedComponents[b]], [a, b])) .toEqual([true, true]); }); -test('an arrow key past the last part keeps its pin', async ({ page }) => { +test('an arrow key past the last part changes nothing but the hover', async ({ page }) => { await load(page); await page.locator('#tab-components').click(); const last = page.locator('#comp-tbody .comp-row').last(); const z = Number(await last.getAttribute('data-idx')); await last.click(); await settle(page); + await page.mouse.move(0, 0); await page.keyboard.press('ArrowDown'); await settle(page); - expect((await state(page)).selectedFootprintIdx).toBe(z); + const s = await state(page); + expect(s.selectedFootprintIdx).toBe(z); + expect(s.highlightedFootprints).toEqual([z]); expect(await page.evaluate((z) => !!pinnedComponents[z], z)).toBe(true); }); diff --git a/web/app.js b/web/app.js index d02d56d..8391df5 100644 --- a/web/app.js +++ b/web/app.js @@ -1902,15 +1902,17 @@ function getCurrentTab() { // Navigate up/down in the comp or net search results. delta = +1 (down) or -1 (up). function navigateList(tabType, delta) { if (tabType === "comp") { + // An arrow key only moves the focus and hovers the part. Enter pins and + // selects it. var rows = Array.from(document.querySelectorAll("#comp-tbody .comp-row")); if (rows.length === 0) return; - var cur = rows.findIndex(function(r) { return r.classList.contains("selected"); }); + var cur = rows.findIndex(function(r) { return r.classList.contains("focused"); }); + if (cur < 0) cur = rows.findIndex(function(r) { return r.classList.contains("selected"); }); var next = Math.max(0, Math.min(rows.length - 1, cur < 0 ? (delta > 0 ? 0 : rows.length - 1) : cur + delta)); - var row = rows[next]; - var idx = parseInt(row.dataset.idx); - // An arrow key is not a click: it pins the part it lands on, never unpins. - if (!pinnedComponents[idx]) togglePinComponent(idx); - selectFootprint(idx, false); + rows.forEach(function(r) { r.classList.remove("focused"); }); + rows[next].classList.add("focused"); + rows[next].scrollIntoView({ block: "nearest" }); + hoverFootprint(parseInt(rows[next].dataset.idx)); } else { // Net panel var netDetail = document.getElementById("net-detail-panel"); @@ -1937,7 +1939,8 @@ function navigateList(tabType, delta) { function activateListSelection(tabType) { if (tabType === "comp") { - var row = document.querySelector("#comp-tbody .comp-row.selected") || + var row = document.querySelector("#comp-tbody .comp-row.focused") || + document.querySelector("#comp-tbody .comp-row.selected") || document.querySelector("#comp-tbody .comp-row"); if (row) { var idx = parseInt(row.dataset.idx); @@ -2055,7 +2058,7 @@ window.addEventListener("load", async function() { // Keyboard nav in component list document.getElementById("comp-search-input").addEventListener("keydown", function(e) { - if (e.key === "Escape") { e.stopPropagation(); this.value = ""; updateCompFilter(""); this.blur(); } + if (e.key === "Escape") { e.stopPropagation(); this.value = ""; updateCompFilter(""); hoverClear(); this.blur(); } else if (e.key === "ArrowDown") { e.preventDefault(); navigateList("comp", 1); } else if (e.key === "ArrowUp") { e.preventDefault(); navigateList("comp", -1); } else if (e.key === "Enter") { e.preventDefault(); activateListSelection("comp"); this.blur(); } diff --git a/web/viewer.css b/web/viewer.css index 5e8160f..33e66f7 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -1008,11 +1008,13 @@ canvas { /* ---- Keyboard navigation focus ---- */ .net-search-row.focused, -.net-comp-row.focused { +.net-comp-row.focused, +.comp-row.focused { background: var(--surface2); outline: 1px solid var(--accent); outline-offset: -1px; } +.comp-row.focused td { background: var(--surface2); } /* ---- Help overlay ---- */ From 9cba8ace14953f210e3800ffb3f151a6bbd034b4 Mon Sep 17 00:00:00 2001 From: gherkin Date: Wed, 28 Oct 2026 14:59:14 +0100 Subject: [PATCH 2/3] A new selection drops the arrow-key focus in the part list A breadcrumb selects a part without a rebuild of the list, so the focus row and its hover stayed on the part the arrow keys reached. Enter then picked that part, not the selected one. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UCbPYsA5LYNX8HZaGGZCpK --- tests/browser/interaction.spec.js | 24 ++++++++++++++++++++++++ web/app.js | 3 +++ 2 files changed, 27 insertions(+) diff --git a/tests/browser/interaction.spec.js b/tests/browser/interaction.spec.js index 2db7425..beeb04c 100644 --- a/tests/browser/interaction.spec.js +++ b/tests/browser/interaction.spec.js @@ -1360,6 +1360,30 @@ test('an arrow key past the last part changes nothing but the hover', async ({ p expect(await page.evaluate((z) => !!pinnedComponents[z], z)).toBe(true); }); +test('a selection from outside the part list drops the arrow-key focus', async ({ page }) => { + await load(page); + await page.locator('#tab-components').click(); + const rows = page.locator('#comp-tbody .comp-row'); + const b = Number(await rows.nth(1).getAttribute('data-idx')); + const c = Number(await rows.nth(2).getAttribute('data-idx')); + await rows.nth(0).click(); + await settle(page); + await page.mouse.move(0, 0); + + await page.keyboard.press('ArrowDown'); + await settle(page); + // A breadcrumb click selects without a rebuild of the list. + await page.evaluate((c) => selectFootprint(c, false), c); + await settle(page); + await expect(page.locator('#comp-tbody .comp-row.focused')).toHaveCount(0); + expect((await state(page)).highlightedFootprints).toEqual([]); + + await page.keyboard.press('Enter'); + await settle(page); + expect((await state(page)).selectedFootprintIdx).toBe(c); + expect(await page.evaluate((b) => !!pinnedComponents[b], b)).toBe(false); +}); + test('Escape deselects', async ({ page }) => { await load(page); await selectNetFromList(page, frontNets[0]); diff --git a/web/app.js b/web/app.js index 8391df5..a4aa8ff 100644 --- a/web/app.js +++ b/web/app.js @@ -1080,6 +1080,9 @@ function deselectFootprint(fpIdx) { } function updateCompListSelection(fpIdx) { + // A new selection ends an arrow-key walk: drop its focus row and hover. + var focused = document.querySelector("#comp-tbody .comp-row.focused"); + if (focused) { focused.classList.remove("focused"); hoverClear(); } document.querySelectorAll(".comp-row").forEach(function(row) { row.classList.toggle("selected", parseInt(row.dataset.idx) === fpIdx); }); From 6279c5d92f9ea6e83fcf1ef0d6e3af0c0cb779bd Mon Sep 17 00:00:00 2001 From: gherkin Date: Wed, 28 Oct 2026 15:33:33 +0100 Subject: [PATCH 3/3] A mouse hover after the arrow keys takes over the hover The last used input owns the hover. A mouse hover or its end now drops the arrow-key focus row in the part list, so no outline is left on a row the board no longer shows. The arrow keys set the hover directly. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UCbPYsA5LYNX8HZaGGZCpK --- tests/browser/interaction.spec.js | 20 ++++++++++++++++++++ web/app.js | 15 ++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/tests/browser/interaction.spec.js b/tests/browser/interaction.spec.js index beeb04c..50c10e3 100644 --- a/tests/browser/interaction.spec.js +++ b/tests/browser/interaction.spec.js @@ -1384,6 +1384,26 @@ test('a selection from outside the part list drops the arrow-key focus', async ( expect(await page.evaluate((b) => !!pinnedComponents[b], b)).toBe(false); }); +test('a mouse hover after the arrow keys takes over the hover', async ({ page }) => { + await load(page); + await page.locator('#tab-components').click(); + const rows = page.locator('#comp-tbody .comp-row'); + const c = Number(await rows.nth(2).getAttribute('data-idx')); + await rows.nth(0).click(); + await settle(page); + await page.mouse.move(0, 0); + + await page.keyboard.press('ArrowDown'); + await settle(page); + await rows.nth(2).hover(); + await waitIdle(page); + await expect(page.locator('#comp-tbody .comp-row.focused')).toHaveCount(0); + expect((await state(page)).highlightedFootprints).toEqual([c]); + + await settle(page); + expect((await state(page)).highlightedFootprints).toEqual([]); +}); + test('Escape deselects', async ({ page }) => { await load(page); await selectNetFromList(page, frontNets[0]); diff --git a/web/app.js b/web/app.js index a4aa8ff..ccd9a92 100644 --- a/web/app.js +++ b/web/app.js @@ -668,17 +668,27 @@ function setHover(nets, footprints) { scheduleRedrawAll(); } +// The last used input owns the hover. The arrow keys call setHover directly; +// the functions below drop the arrow-key focus row in the part list. +function dropCompFocus() { + var row = document.querySelector("#comp-tbody .comp-row.focused"); + if (row) row.classList.remove("focused"); +} + function hoverFootprint(fpIdx) { + dropCompFocus(); setHover([], [fpIdx]); } function hoverNet(netName) { + dropCompFocus(); setHover([netName], []); } // Clicks call this too: a click can rebuild the list under the pointer, and // then no mouseleave fires. function hoverClear() { + dropCompFocus(); if (hoverNets.length === 0 && highlightedFootprints.length === 0) return; setHover([], []); } @@ -1081,8 +1091,7 @@ function deselectFootprint(fpIdx) { function updateCompListSelection(fpIdx) { // A new selection ends an arrow-key walk: drop its focus row and hover. - var focused = document.querySelector("#comp-tbody .comp-row.focused"); - if (focused) { focused.classList.remove("focused"); hoverClear(); } + if (document.querySelector("#comp-tbody .comp-row.focused")) hoverClear(); document.querySelectorAll(".comp-row").forEach(function(row) { row.classList.toggle("selected", parseInt(row.dataset.idx) === fpIdx); }); @@ -1915,7 +1924,7 @@ function navigateList(tabType, delta) { rows.forEach(function(r) { r.classList.remove("focused"); }); rows[next].classList.add("focused"); rows[next].scrollIntoView({ block: "nearest" }); - hoverFootprint(parseInt(rows[next].dataset.idx)); + setHover([], [parseInt(rows[next].dataset.idx)]); } else { // Net panel var netDetail = document.getElementById("net-detail-panel");