Skip to content

fix(DataTable): fix page number bug #6125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 30, 2025
Merged

fix(DataTable): fix page number bug #6125

merged 8 commits into from
May 30, 2025

Conversation

francinelucca
Copy link
Member

Closes https://github.com/github/primer/issues/5216

Refactors Table.Pagination to use the same page rendering logic that the Pagination component uses. This solves a bug where page numbers were being repeated in the pagination component.

Changelog

New

  • Refactored Table.Pagination to use buildPaginationModel for page rendering logic
  • Added test case to cover for found bug

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@Copilot Copilot AI review requested due to automatic review settings May 28, 2025 15:53
@francinelucca francinelucca requested a review from a team as a code owner May 28, 2025 15:53
@francinelucca francinelucca requested a review from jonrohan May 28, 2025 15:53
Copy link

changeset-bot bot commented May 28, 2025

🦋 Changeset detected

Latest commit: 076ce68

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@francinelucca francinelucca requested a review from hectahertz May 28, 2025 15:53
@github-actions github-actions bot added the staff Author is a staff member label May 28, 2025
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label May 28, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Table.Pagination component to leverage the shared buildPaginationModel logic, fixing a bug where page numbers could repeat. It also adds a new test to cover the specific page-range behavior.

  • Replaced custom offset/truncation state with a useMemo-driven pagination model
  • Removed manual calculation helpers (MAX_TRUNCATED_STEP_COUNT, getDefaultOffsetStartIndex)
  • Added a test case for navigating to page 4 with 100 items at 15 items/page

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/react/src/DataTable/tests/Pagination.test.tsx New test validating page range and full page list for page 4
packages/react/src/DataTable/Pagination.tsx Refactored pagination rendering to use buildPaginationModel
Comments suppressed due to low confidence (1)

packages/react/src/DataTable/Pagination.tsx:244

  • [nitpick] Using the array index as the React key may lead to rendering issues when the model array changes; consider using a stable identifier such as page.num or a combination of page.type and i.
<Step key={i}>

Copy link
Contributor

github-actions bot commented May 28, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 94.46 KB (0%)
packages/react/dist/browser.umd.js 94.49 KB (0%)

@github-actions github-actions bot requested a deployment to storybook-preview-6125 May 28, 2025 16:00 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6125 May 28, 2025 16:15 Inactive
@@ -1,6 +1,6 @@
import {ChevronLeftIcon, ChevronRightIcon} from '@primer/octicons-react'
import type React from 'react'
import {useCallback, useState} from 'react'
import {useCallback, useMemo, useState} from 'react'
import styled from 'styled-components'
Copy link
Member

Choose a reason for hiding this comment

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

🤦🏻 styled-components still

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels May 28, 2025
@github-actions github-actions bot requested a deployment to storybook-preview-6125 May 28, 2025 22:50 Abandoned
@github-actions github-actions bot requested a deployment to storybook-preview-6125 May 28, 2025 22:55 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6125 May 28, 2025 23:07 Inactive
@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/380421

@primer-integration
Copy link

🟢 golden-jobs completed with status success.

@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels May 30, 2025
@francinelucca francinelucca added this pull request to the merge queue May 30, 2025
Merged via the queue into main with commit 91b3c71 May 30, 2025
35 checks passed
@francinelucca francinelucca deleted the fix/pagination-bug branch May 30, 2025 11:13
@primer primer bot mentioned this pull request May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants