Dragging a pane down: reaching any part of a pane below is enough

The drop place was decided by the midpoint of the pane under the pointer, so
a pane dragged down onto the top of the one below went nowhere.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
thalladaandClaude Fable 5.2 committed 2026-11-16 15:48:58 -05:00
1 parent 7bddb03d0d
commit ec19a23051
2 files changed
+14 -3

No files matched your search

+3
View File
@@ -510,6 +510,9 @@ test("a pane is dragged by its grip, or its tab, up or down its column; the orde
await page.reload();
await page.waitForSelector(".strip .pane");
expect((await columns(page))[1]).toEqual([kids[4], ...kids.slice(0, 4)]);
// Downward, reaching the top of a pane below is enough: the dragged pane lands after it.
await drag(kids[4], kids[1]);
expect((await columns(page))[1]).toEqual([kids[0], kids[1], kids[4], kids[2], kids[3]]);
// And by its tab, in a crowded column.
await page.setViewportSize({ width: 1920, height: 1080 });
await expect.poll(() => page.locator(".strip > .col").nth(1).getAttribute("class")).toContain("crowded");
+11 -3
View File
@@ -572,13 +572,21 @@ export function Panes() {
drag.line.className = "drop-line";
wrap.appendChild(drag.line);
}
const others = [...drag.col.querySelectorAll<HTMLElement>(":scope > .pane")].filter((p) => Number(p.dataset.tid) !== drag!.tid);
const panes = [...drag.col.querySelectorAll<HTMLElement>(":scope > .pane")];
const mine = panes.findIndex((p) => Number(p.dataset.tid) === drag!.tid);
const others = panes.filter((_, k) => k !== mine);
const c = drag.col.getBoundingClientRect();
const tops = others.map((p) => Math.max(c.top, Math.min(c.bottom, p.getBoundingClientRect().top)));
const ends = others.map((p, i) => Math.min(tops[i + 1] ?? c.bottom, Math.max(c.top, Math.min(c.bottom, p.getBoundingClientRect().bottom))));
const i = others.findIndex((_, k) => e.clientY < (tops[k] + ends[k]) / 2);
// The pane under the pointer gives way: one that was below the dragged pane lets it in after
// itself, one that was above lets it in before. So reaching any part of a pane is enough, in
// either direction.
let k = -1;
while (k + 1 < others.length && tops[k + 1] <= e.clientY) k++;
const at = k < 0 ? 0 : k >= mine || e.clientY >= ends[k] ? k + 1 : k;
const i = at < others.length ? at : -1;
drag.before = i < 0 ? null : Number(others[i].dataset.tid);
const y = i < 0 ? (ends[ends.length - 1] ?? c.top) : tops[i];
const y = at === 0 ? (tops[0] ?? c.top) : ends[at - 1];
const box = wrap.getBoundingClientRect();
Object.assign(drag.line!.style, { left: `${c.left - box.left}px`, width: `${c.width}px`, top: `${y - box.top - 1}px` });
};