Repository navigation
fix(fanout): replace full-enumeration pager with windowed pager with ellipsis - #455
Conversation
With many pages the old Array.from({length: totalPages}) rendered one
button per page, overflowing the flex row and squeezing/hiding buttons.
- Add getPagerItems(page, totalPages) helper that returns at most ~9
items: first, ...ellipsis, current-1, current, current+1, ...ellipsis, last
- When totalPages <= 7 all numbers are shown with no ellipsis
- Add Previous (‹) and Next (›) chevron buttons, disabled at boundaries
- Render ellipsis as a non-interactive muted span, not a button
- Keep existing button styling (h-7 w-7 p-0 text-xs, default/ghost variants)
Closes #446
gkhngyk
left a comment
There was a problem hiding this comment.
Traced getPagerItems through the boundary cases — page 1/2/3/4, mid-range, last-3 and last page at totalPages 8 and 500 — and it produces a contiguous, correctly-windowed list in all of them: the current page is always rendered, neighbors stay adjacent, no duplicate ellipsis, and the element count caps at 7 (+2 chevrons = 9) exactly as #446 asked. The ≤7 branch shows all numbers with no ellipsis, chevrons disable at the boundaries, ellipsis is a non-interactive span, and the existing button styling is preserved. CHANGELOG entry is a nice touch.
Heads-up (no action needed): #453 and #448 touch other regions of this same file — GitHub reports all three mergeable, so merge order won't matter.
LGTM, thanks!
Problem
The
HighFrequencyViewpager rendered one button per page usingArray.from({ length: totalPages }). WithPAGE_SIZE = 10and a few thousand sub-queries, this produced hundreds of buttons in a single non-wrapping flex row — the pager spanned the full card width, buttons got squeezed, and some page numbers were pushed out of view entirely.Fixes #446.
Solution
Replaced the full enumeration with a windowed pager:
getPagerItems(page, totalPages)helper that returns at most ~9 elements:‹ 1 … n-1 n n+1 … last ›totalPages ≤ 7, all page numbers are shown with no ellipsis‹) and Next (›) chevron buttons at the ends, disabled on the first/last page…) renders as a non-interactive muted<span>, not a buttonh-7 w-7 p-0 text-xs,defaultvariant for current page,ghostfor the rest)No new dependencies — the helper is a small pure function.
Acceptance criteria
Testing
yarn lint— 0 errors (pre-existing warnings in other files only)yarn typecheck— cleanyarn format:check— all files use Prettier code style