Skip to content

fix(fanout): replace full-enumeration pager with windowed pager with ellipsis - #455

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
Maqbool61:fix/fanout-windowed-pager
Jul 17, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
Maqbool61:fix/fanout-windowed-pager

Conversation

@Maqbool61

Copy link
Copy Markdown
Contributor

Problem

The HighFrequencyView pager rendered one button per page using Array.from({ length: totalPages }). With PAGE_SIZE = 10 and 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:

  • Added a pure getPagerItems(page, totalPages) helper that returns at most ~9 elements: ‹ 1 … n-1 n n+1 … last ›
  • When totalPages ≤ 7, all page numbers are shown with no ellipsis
  • Added Previous (‹) and Next (›) chevron buttons at the ends, disabled on the first/last page
  • Ellipsis (…) renders as a non-interactive muted <span>, not a button
  • Existing button styling preserved (h-7 w-7 p-0 text-xs, default variant for current page, ghost for the rest)

No new dependencies — the helper is a small pure function.

Acceptance criteria

  • With many pages (e.g. 500), the pager renders at most ~9 elements — it never overflows or wraps
  • The current page is always visible and highlighted; first/last pages are always one click away
  • Clicking a number, Previous, or Next changes the page exactly as before
  • With few pages (e.g. 3), all numbers show and there is no ellipsis

Testing

  • Manually tested with 3, 7, 8, and 500 total pages across multiple current page positions (first, middle, last, near boundaries)
  • yarn lint — 0 errors (pre-existing warnings in other files only)
  • yarn typecheck — clean
  • yarn format:check — all files use Prettier code style

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 gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@gkhngyk
gkhngyk merged commit 3e35540 into ansvisor:main Jul 17, 2026
4 checks passed
@Maqbool61
Maqbool61 deleted the fix/fanout-windowed-pager branch July 17, 2026 11:53
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.

Query Fan-out: High frequency pager renders every page number and overflows the row

2 participants