Skip to content

Fix duplicate page tokens when navigating jelly-pagination window#2

Draft
bmson with Copilot wants to merge 2 commits into
mainfrom
copilot/jelly-pagination-fix-duplicate-page-5
Draft

Fix duplicate page tokens when navigating jelly-pagination window#2
bmson with Copilot wants to merge 2 commits into
mainfrom
copilot/jelly-pagination-fix-duplicate-page-5

Conversation

Copilot AI commented Jul 25, 2026

Copy link
Copy Markdown

Pagination intermittently rendered duplicate numeric buttons when crossing window boundaries (e.g., moving from page 1 to 6 could show 5 twice). This change makes page-window construction uniqueness-safe and adds a focused regression covering the reported path.

  • Pagination window generation

    • Reworked pagesToShow() to build candidate pages via a Set (1, total, current ± 1) and then render sorted pages.
    • Ellipsis insertion now depends on actual numeric gaps between adjacent rendered pages, preventing duplicate tokens.
  • Regression coverage

    • Added a pagination test that advances from page 1 to page 6 via next-button clicks and asserts:
      • page state is correct (page === 6)
      • numeric page labels are unique
      • page 5 appears exactly once
const pages = new Set<number>([1, total]);
for (let p = cur - 1; p <= cur + 1; p++) {
  if (p >= 1 && p <= total) pages.add(p);
}
for (const p of [...pages].sort((a, b) => a - b)) {
  if (previous !== null && p - previous > 1) out.push('…');
  out.push(p);
  previous = p;
}

Copilot AI linked an issue Jul 25, 2026 that may be closed by this pull request
@bmson bmson added the bug Something isn't working label Jul 25, 2026
Copilot AI changed the title [WIP] Fix duplicated page 5 in jelly pagination Fix duplicate page tokens when navigating jelly-pagination window Jul 25, 2026
Copilot finished work on behalf of bmson July 25, 2026 04:24
Copilot AI requested a review from bmson July 25, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<jelly-pagination> from page 1 click to 6, 5 will show twice

2 participants