fix: cap the first tab on every pass, before a selection widens it (#748)

selectSession() toggles .active at once while _syncTabStripCorner() only runs in
the debounced render, so a cap set after measuring left a newly selected first
tab wider than the room and dropped the first row below the toolbar until then.
max-width changes nothing on a narrower tab, so the cap is simply always on, and
the clear-before-measure and finish-the-animation loops go. The no-usable-room
test uses 8 tabs: at 40 the scroll fallback fires first and it passed at any
threshold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-11-04 16:48:57 +01:00
1 parent 823013226d
commit d9d6fad698
4 files changed
+24 -19

No files matched your search

+13 -3
View File
@@ -200,14 +200,22 @@ describe('L-shaped header tab strip (real Chromium)', () => {
expect(await select(3)).toEqual({
cornered: true,
overlapping: [],
first: { besideToolbar: true, trimmed: false },
first: { besideToolbar: true, trimmed: true },
});
expect(await select(1)).toEqual({ cornered: true, overlapping: [], first: { besideToolbar: true, trimmed: true } });
expect(await select(3)).toEqual({
cornered: true,
overlapping: [],
first: { besideToolbar: true, trimmed: false },
first: { besideToolbar: true, trimmed: true },
});
// selectSession() widens the tab at once and the corner sync is debounced: the
// cap has to be on already, or the first row drops below the toolbar until then.
await p.evaluate(() => {
document
.querySelectorAll('#sessionTabs > .session-tab')
.forEach((tab, i) => tab.classList.toggle('active', i === 0));
});
expect(await firstTab()).toEqual({ besideToolbar: true, trimmed: true });
await p.close();
});
@@ -240,7 +248,9 @@ describe('L-shaped header tab strip (real Chromium)', () => {
});
it('keeps the plain wrap when the toolbar leaves no usable room beside it', async () => {
await open({ tabs: 40 });
// Few enough that the strip does not scroll: at 40 the scroll fallback turns the
// corner off before the room check is reached, and this would pass at any threshold.
await open({ tabs: 8 });
await p.evaluate(() => {
const head = document.querySelector('.header')!.getBoundingClientRect();
const right = document.getElementById('headerRight')!;