Skip to content

fix: keep the active tab visible when the header row overflows - #238

Merged
therealsama merged 1 commit into
mainfrom
fix/header-active-tab-overflow
Sep 5, 2026
Merged

therealsama merged 1 commit into
mainfrom
fix/header-active-tab-overflow

Conversation

@therealsama

@therealsama therealsama commented Aug 29, 2026 •

Copy link
Copy Markdown
Collaborator

The bug

On a narrow phone the header fits one pill plus More. Opening Ask, New or Show from that menu left the bar reading Best — the active pill was packed into the very menu it had been chosen from. From and User were unaffected.

before, at 320px on /show after
bar reads Best | More bar reads Show | More

Why

usePackedNav fills the row strictly left-to-right and stops at the first pill that doesn't fit, and deriveHeaderState emits feed tabs in fixed best → show → ask → newest order with isActive as a flag the packer never reads. One slot therefore always went to Best.

An active contextual pill (comments/user/from) is pushed at index 0, which is why those two looked fine — they were surviving by position, not by being active.

The fix

PackableItem gains an optional pinned, claimed before the left-to-right pass; Header sets pinned: it.isActive.

Promoting the active feed to the front would have been simpler and was rejected: fixed tab order is deliberate (Header.test.tsx already locks it), and reordering makes tabs jump as you move between feeds. So:

  • the row keeps caller order — where two pills fit and New is active you get Best New, not New Best;
  • a pin too wide to fit alone is dropped, since nothing justifies overflowing the row;
  • visible/hidden are filtered rather than sliced, because a pinned item can sit past the run that fits.

Test plan

  • usePackedNav.test.ts: the one-slot case (the bug, at real pill widths), order preservation around a pin, the too-wide fallback, and the pin being inert when everything fits.
  • Header.test.tsx: the active item is pinned on each feed and contextual route, and nothing is pinned on /. Asserted on the packer's input, since the packer is mocked there.
  • e2e/header-overflow.spec.ts: at 320px with a real ResizeObserver, each of show/ask/new is a visible aria-current="page" pill and not a menu item.
  • Mutation-tested: dropping the Header pin fails all three e2e cases, dropping the reservation fails the two behavioural hook tests, and making the reservation unconditional fails the too-wide test.
  • Full suite: typecheck, lint, 984 unit, build, 728 e2e. One pre-existing axe colour-contrast flake on Firefox (domain filter page), re-run 4/4 clean.

@therealsama
therealsama requested a review from kplachkov as a code owner August 29, 2026 19:10
@therealsama
therealsama force-pushed the feat/mobile-touch-feel branch from b04e134 to bb8e7fe Compare August 29, 2026 20:03
@therealsama
therealsama force-pushed the fix/header-active-tab-overflow branch from 053b9c3 to bccdc1a Compare August 29, 2026 20:14
@therealsama
therealsama force-pushed the feat/mobile-touch-feel branch from bb8e7fe to 7026195 Compare September 1, 2026 23:12
@therealsama
therealsama force-pushed the fix/header-active-tab-overflow branch from bccdc1a to a1f196a Compare September 1, 2026 23:13
@therealsama
therealsama force-pushed the feat/mobile-touch-feel branch from 7026195 to f37041f Compare September 2, 2026 04:22
@therealsama
therealsama force-pushed the fix/header-active-tab-overflow branch from a1f196a to 156059a Compare September 2, 2026 04:22
@therealsama
therealsama force-pushed the feat/mobile-touch-feel branch from f37041f to 4d30236 Compare September 2, 2026 04:45
@therealsama
therealsama force-pushed the fix/header-active-tab-overflow branch from 156059a to 9868c4c Compare September 2, 2026 04:47
Base automatically changed from feat/mobile-touch-feel to main September 2, 2026 07:32
@therealsama
therealsama force-pushed the fix/header-active-tab-overflow branch from 9868c4c to 41e35ea Compare September 2, 2026 07:35
The nav packer filled the row strictly left-to-right, so a 320px bar spent
its only slot on Best whichever feed was open. Picking Ask from the More
menu left the bar reading Best, with the active pill hidden inside the menu
it had just been chosen from. An active contextual pill escaped this only
because it already sits at index 0.

usePackedNav now takes a pinned item that claims its slot before the pass,
and Header pins the active tab. The row still reads in canonical order, and
a pin too wide to fit alone is dropped rather than overflowing the row.
@therealsama
therealsama force-pushed the fix/header-active-tab-overflow branch from 41e35ea to 84f2e56 Compare September 5, 2026 11:25
@therealsama
therealsama merged commit 3445034 into main Sep 5, 2026
4 checks passed
@therealsama
therealsama deleted the fix/header-active-tab-overflow branch September 5, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants