Let a widget be dragged onto any row, including the top

Dragging a widget over apps used to move it in the order, but a wide widget
can't fit beside earlier apps, so the packed flow kept pushing it below them.
A widget now always goes to the cell under it (MOVE_CELL) and the apps flow
around it; apps still reorder by dragging over each other.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NYASJ6JNxhYwNNJK7ypK2V
This commit is contained in:
Claude committed 2026-10-22 06:53:31 +00:00
1 parent d782c9c645
commit c3f3e4eedb
2 files changed
+11 -5

No files matched your search

+6 -3
View File
@@ -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();
+5 -2
View File
@@ -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);