Skip to content

frontend: SimpleTable: Fix pagination bug#6477

Open
skools-here wants to merge 3 commits into
kubernetes-sigs:mainfrom
skools-here:fix-simpletable-pagination
Open

frontend: SimpleTable: Fix pagination bug#6477
skools-here wants to merge 3 commits into
kubernetes-sigs:mainfrom
skools-here:fix-simpletable-pagination

Conversation

@skools-here

Copy link
Copy Markdown
Contributor

Summary

Fixes a bug in SimpleTable where navigating to an empty page occurs when the total number of items is an exact multiple of the page size (e.g. exactly 10 items, viewing the second page).

Related Issue

Fixes #6476

Changes

  • Updated page validation check in SimpleTable.tsx from > to >= to capture exact boundary alignments.
  • Corrected the fallback page index calculation in SimpleTable.tsx to compute the maximum valid page index using Math.max(0, Math.floor((displayData.length - 1) / rowsPerPage)) .
  • Updated the filtered data reset check in SimpleTable.tsx from < to <= to return the page index to 0 when filters matching exactly page * rowsPerPage items are applied.
  • Added a new regression unit test in SimpleTable.test.tsx to verify correct page correction at page boundaries.

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: skools-here
Once this PR has been reviewed and has the lgtm label, please assign sniok for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 11, 2026
@illume illume requested a review from Copilot July 13, 2026 07:05

Copilot AI 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.

Pull request overview

This PR fixes an off-by-one pagination boundary in SimpleTable that could leave users on an empty page when the total row count is an exact multiple of rowsPerPage (e.g., 10 items with rowsPerPage=10 while on page index 1).

Changes:

  • Tightened the invalid-page guard to treat page * rowsPerPage === displayData.length as out of range, and corrected the fallback page calculation to the max valid index.
  • Adjusted the filtered-data page reset condition to also handle exact boundary matches.
  • Added a regression unit test covering the exact-multiple boundary case.

Reviewed changes

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

File Description
frontend/src/components/common/SimpleTable.tsx Fixes page validity checks and fallback page computation at exact pagination boundaries.
frontend/src/components/common/SimpleTable.test.tsx Adds regression coverage for boundary behavior when the requested page would otherwise render empty.

Comment thread frontend/src/components/common/SimpleTable.test.tsx Outdated
@skools-here skools-here force-pushed the fix-simpletable-pagination branch from 595b5e9 to f38b29f Compare July 13, 2026 08:43
@skools-here skools-here force-pushed the fix-simpletable-pagination branch from eb32b57 to f19d9c9 Compare July 13, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Off-by-One Pagination Boundary Bug in SimpleTable

2 participants