From bc1a97eee2080d1703d17c2597d179aaf3ae655c Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Thu, 3 Dec 2026 10:45:42 +0100 Subject: [PATCH] fix(desktop): a server tab can be dragged into the last place Dragging a tab as far right as it goes left it one place short of the end (4 tabs: the first one landed third, the move posted to: 2). The clamp stops the dragged tab with its centre exactly on the last tab's centre, and the comparison was strict. A tab after the dragged one now counts as passed once the centres meet; one before it still needs the centre to cross, so a press that does not move stays in place. Found while integrating #852 with #816 (shipped in 1.52.0). The strip walk in test/desktop-tabs-pages.browser.test.ts drags past the end; that check fails without the fix. Co-Authored-By: Claude Opus 5.5 --- packages/desktop/assets/tabs.html | 7 ++++++- test/desktop-tabs-pages.browser.test.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/desktop/assets/tabs.html b/packages/desktop/assets/tabs.html index 7fd20099..e5298f88 100644 --- a/packages/desktop/assets/tabs.html +++ b/packages/desktop/assets/tabs.html @@ -449,9 +449,14 @@ dx = Math.max(minDx, Math.min(maxDx, dx)); drag.root.style.transform = 'translateX(' + dx + 'px)'; var centre = r0.left + r0.width / 2 + dx; + // A tab after the dragged one is passed once the centres meet, not only once they cross: + // the clamp stops a tab dragged all the way right with its centre ON the last tab's + // centre, and a strict comparison there left it one place short of the end. var to = 0; for (var i = 0; i < rects.length; i++) { - if (i !== drag.from && centre > rects[i].left + rects[i].width / 2) to++; + if (i === drag.from) continue; + var c = rects[i].left + rects[i].width / 2; + if (i > drag.from ? centre >= c : centre > c) to++; } drag.to = to; drag.roots.forEach(function (r, i) { diff --git a/test/desktop-tabs-pages.browser.test.ts b/test/desktop-tabs-pages.browser.test.ts index 6fa098a3..fa806490 100644 --- a/test/desktop-tabs-pages.browser.test.ts +++ b/test/desktop-tabs-pages.browser.test.ts @@ -472,6 +472,14 @@ async function stripWalk(browser: Browser) { same(await order(), [14, 12, 13, 11]) && (await page.textContent(sel(12, '.name'))) === 'twelve', await order() ); + // As far right as it goes: the clamp stops the tab with its centre on the last tab's centre, + // which must still count as passing it. + await page.mouse.move(await centre(14), 22); + await page.mouse.down(); + await page.mouse.move((await centre(11)) + 400, 22, { steps: 12 }); + await page.mouse.up(); + check('dragged past the end, a tab lands in the last place', same(await take(), [{ cmd: 'move', id: 14, to: 3 }])); + check('and shows there', same(await order(), [12, 13, 11, 14]), await order()); // 8. Many tabs and long names. const many = Array.from({ length: 30 }, (_, i) => tab(100 + i, 'server-' + i, { active: i === 0 }));