Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/browser/interaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,38 @@ 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 }) => {
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.keyboard.press('ArrowDown');
await settle(page);
expect((await state(page)).selectedFootprintIdx).toBe(b);
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 }) => {
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.keyboard.press('ArrowDown');
await settle(page);
expect((await state(page)).selectedFootprintIdx).toBe(z);
expect(await page.evaluate((z) => !!pinnedComponents[z], z)).toBe(true);
});

test('Escape deselects', async ({ page }) => {
await load(page);
await selectNetFromList(page, frontNets[0]);
Expand Down
5 changes: 2 additions & 3 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1908,10 +1908,9 @@ function navigateList(tabType, delta) {
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);
togglePinComponent(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);
updateCompListSelection(idx);
row.scrollIntoView({ block: "nearest" });
} else {
// Net panel
var netDetail = document.getElementById("net-detail-panel");
Expand Down
Loading