Skip to content

OCPBUGS-78390: Reset pagination page when changing namespace#16138

Open
rhamilto wants to merge 1 commit intoopenshift:mainfrom
rhamilto:OCPBUGS-78390
Open

OCPBUGS-78390: Reset pagination page when changing namespace#16138
rhamilto wants to merge 1 commit intoopenshift:mainfrom
rhamilto:OCPBUGS-78390

Conversation

@rhamilto
Copy link
Member

@rhamilto rhamilto commented Mar 12, 2026

Summary

Fixes OCPBUGS-78390 - When switching namespaces/projects via the project picker, the page query parameter was persisting from the previous namespace, causing the table to display incorrectly (e.g., showing "51-3 of 3" with no data rows).

After

Screen.Recording.2026-03-12.at.2.43.28.PM.mov

Changes

This fix addresses the issue at two layers:

  1. Navigation layer (ui.ts) - formatNamespaceRoute() removes the page query parameter when building the new URL during namespace changes, while preserving perPage as a user preference.

  2. Component layer (useConsoleDataViewData.tsx) - Tracks namespace changes and resets pagination to page 1 when the namespace changes, similar to how it already resets when filters change.

Testing

  • ✅ All existing tests pass
  • ✅ Added 5 new test cases to verify pagination query parameter handling
  • ✅ Manually tested: Navigate to /k8s/all-namespaces/core~v1~Pod?page=2&perPage=50, switch to a different namespace → pagination resets to page 1, perPage is preserved
  • ✅ Manually tested: Switching namespaces when on page 1 preserves all query params

Test Plan

  1. Navigate to /k8s/all-namespaces/core~v1~Pod?page=2&perPage=50
  2. Use the project picker to switch to the openshift-apiserver namespace
  3. Verify the table displays correctly with data from page 1
  4. Verify the URL shows ?perPage=50 (page param removed, perPage preserved)
  5. Verify pagination controls show "1-X of Y" correctly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed pagination reset behavior when switching between namespaces. The page now correctly returns to the first page while maintaining other active filters and display settings for consistent navigation.

When switching namespaces/projects via the project picker, the page
query parameter was persisting from the previous namespace, causing
the table to display incorrectly (e.g., showing "51-3 of 3" with no
data rows when navigating from page 2 of one project to another
project with fewer items).

This fix addresses the issue at two layers:

1. Navigation layer (formatNamespaceRoute): Removes the 'page' query
   parameter when building the new URL during namespace changes, while
   preserving 'perPage' as a user preference.

2. Component layer (useConsoleDataViewData): Tracks namespace changes
   and resets pagination to page 1 when the namespace changes, similar
   to how it already resets when filters change.

Together, these changes ensure pagination properly resets to page 1
when switching namespaces while preserving the user's items-per-page
preference.

Tests have been added to verify the pagination query parameter handling
in formatNamespaceRoute, covering namespace changes, query param
preservation, and edge cases.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 12, 2026
@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-78390, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

Fixes OCPBUGS-78390 - When switching namespaces/projects via the project picker, the page query parameter was persisting from the previous namespace, causing the table to display incorrectly (e.g., showing "51-3 of 3" with no data rows).

Changes

This fix addresses the issue at two layers:

  1. Navigation layer (ui.ts) - formatNamespaceRoute() removes the page query parameter when building the new URL during namespace changes, while preserving perPage as a user preference.

  2. Component layer (useConsoleDataViewData.tsx) - Tracks namespace changes and resets pagination to page 1 when the namespace changes, similar to how it already resets when filters change.

Testing

  • ✅ All existing tests pass
  • ✅ Added 5 new test cases to verify pagination query parameter handling
  • ✅ Manually tested: Navigate to /k8s/all-namespaces/core~v1~Pod?page=2&perPage=50, switch to a different namespace → pagination resets to page 1, perPage is preserved
  • ✅ Manually tested: Switching namespaces when on page 1 preserves all query params

Test Plan

  1. Navigate to /k8s/all-namespaces/core~v1~Pod?page=2&perPage=50
  2. Use the project picker to switch to the openshift-apiserver namespace
  3. Verify the table displays correctly with data from page 1
  4. Verify the URL shows ?perPage=50 (page param removed, perPage preserved)
  5. Verify pagination controls show "1-X of Y" correctly

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from jhadvig and spadgett March 12, 2026 18:48
@openshift-ci openshift-ci bot added component/core Related to console core functionality approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 12, 2026
@rhamilto
Copy link
Member Author

/assign @vikram-raj
since he's been looking at this code recently.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

This change implements pagination reset logic when the active namespace changes within the data view. The implementation tracks namespace changes via a ref comparison, extends the pagination reset condition to trigger on namespace changes, and modifies the formatNamespaceRoute function to remove the page parameter from URL search params when the namespace changes while preserving other search parameters and the location hash. Supporting tests verify the page parameter removal on namespace transitions, preservation of other query parameters, and handling of edge cases like empty query strings.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: resetting pagination when switching namespaces, which is the core fix for OCPBUGS-78390.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use oxc to improve the quality of JavaScript and TypeScript code reviews.

Add a configuration file to your project to customize how CodeRabbit runs oxc.

@rhamilto
Copy link
Member Author

/cherry-pick release-4.21

@openshift-cherrypick-robot

@rhamilto: once the present PR merges, I will cherry-pick it on top of release-4.21 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@rhamilto
Copy link
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 12, 2026
@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-78390, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from yapei March 12, 2026 19:19
@rhamilto
Copy link
Member Author

/retest

2 similar comments
@rhamilto
Copy link
Member Author

/retest

@rhamilto
Copy link
Member Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 13, 2026

@rhamilto: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Member

@vikram-raj vikram-raj left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 13, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto, vikram-raj

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

The pull request process is described 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

@rhamilto
Copy link
Member Author

/assign @yapei

@yapei
Copy link
Contributor

yapei commented Mar 16, 2026

@yanpzhan will help verify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants