mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-05 01:29:32 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
63af255726
commit
bc1a97eee2
2 files changed
+14
-1
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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 }));
|
||||
|
||||
Reference in new issue
Block a user