diff --git a/tests/e2e.cjs b/tests/e2e.cjs index 08022f7..dd08b31 100644 --- a/tests/e2e.cjs +++ b/tests/e2e.cjs @@ -147,15 +147,18 @@ const BASE = process.env.BASE || "http://localhost:8000"; assert.deepEqual(await size(), [w1, h1], "the size is saved"); // while it shows handles, dragging the widget itself moves it, without another long press await longpress(".widget-slot"); - const order = () => p.$$eval(".slots > li", (ls) => ls.map((l) => l.classList.contains("widget-slot") ? "W" : "a")); - assert.notEqual((await order())[0], "W"); + const atStart = () => p.$eval(".widget-slot", (w) => { + const r = w.getBoundingClientRect(), s = w.parentElement.getBoundingClientRect(); + return Math.abs(r.left - s.left) < 2 && Math.abs(r.top - s.top) < 2; + }); + assert.ok(!(await atStart())); const wb = await p.locator(".widget-slot").boundingBox(), first = await p.locator(".slots > li").first().boundingBox(); await p.mouse.move(wb.x + wb.width / 2, wb.y + wb.height / 2); await p.mouse.down(); await settle(); assert.ok(await p.$(".widget-slot.lifted"), "pressing a widget with handles picks it up"); await p.mouse.move(first.x + first.width / 2, first.y + first.height / 2, { steps: 8 }); await settle(); await p.mouse.up(); await settle(); - assert.equal((await order())[0], "W", "dragged to the front"); + assert.ok(await atStart(), "dragged onto the top row, first cell"); // the apps flow into the cells beside it: a 2x2 widget in 5 columns leaves room for all four const beside = await p.$eval(".widget-slot", (w) => { const r = w.getBoundingClientRect(); diff --git a/web/index.html b/web/index.html index b04ba64..54dc83d 100644 --- a/web/index.html +++ b/web/index.html @@ -185,12 +185,15 @@ const r = lifted.getBoundingClientRect(); carry = { dx: x0 - r.left, dy: y0 - r.top, cell: -1 }; } - if (inside(lifted.getBoundingClientRect(), x, y)) return; + // A widget goes to the cell under it wherever that is (apps flow around it), so it + // can sit on any row; an app over another app takes its place in the order. + const widget = lifted.classList.contains("widget-slot"); + if (!widget && inside(lifted.getBoundingClientRect(), x, y)) return; // the cell under the finger: a slot there takes the lifted one's place in the order const [fc, fr] = cellAt(g, x - g.colW / 2, y - g.cell / 2); const to = slotAt(x, y) >= 0 ? slotAt(x, y) : slotAt(g.left + fc * (g.colW + g.gap) + g.colW / 2, g.top + fr * (g.cell + g.rgap) + g.cell / 2); - if (to >= 0) { carry.cell = -1; app.dispatch(DRAG_TO, to); return; } + if (to >= 0 && !widget) { carry.cell = -1; app.dispatch(DRAG_TO, to); return; } if (y > g.top + g.rows * (g.cell + g.rgap)) return; // below the grid const [col, row] = cellAt(g, x - carry.dx, y - carry.dy); const cell = row * 64 + Math.min(col, 63);