Skip to content

ui: fix pagination metadata when filtering secrets#31763

Open
lklivingstone wants to merge 4 commits intohashicorp:mainfrom
lklivingstone:ui/fix-kv-filter-pagination
Open

ui: fix pagination metadata when filtering secrets#31763
lklivingstone wants to merge 4 commits intohashicorp:mainfrom
lklivingstone:ui/fix-kv-filter-pagination

Conversation

@lklivingstone
Copy link
Contributor

Description

Closes #31761

Fixes an issue in the KV secrets list view where pagination does not correctly reflect filtered results.

When applying a filter, the pagination component continued to use the unfiltered total count, resulting in incorrect page calculations.

Changes

  • Updated paginate utility to compute:
    • filteredTotal based on the full filtered dataset (before slicing)
    • lastPage based on the full filtered dataset
  • Updated KV list template to use filteredTotal when a filter is applied.
  • Updated existing unit test to reflect corrected filteredTotal semantics.
  • Added new test to validate filtered pagination behavior.

Why

Previously:

  • filteredTotal incorrectly reflected the page slice size.
  • Pagination UI showed incorrect page counts when filtering.

Now:

  • filteredTotal reflects full filtered dataset size.
  • lastPage correctly reflects filtered dataset size.
  • Pagination UI matches filtered results.

Screenshots:
Screenshot from 2026-02-17 00-59-38
Screenshot from 2026-02-17 00-59-58
Screenshot from 2026-02-17 01-00-04

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • Jira: If this change has an associated Jira, it's referenced either in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've documented the impact of any changes to security controls.

Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@lklivingstone lklivingstone requested a review from a team as a code owner February 17, 2026 15:19
@vercel
Copy link

vercel bot commented Feb 17, 2026

@lklivingstone is attempting to deploy a commit to the HashiCorp Team on Vercel.

A member of the Team first needs to authorize it.

@lklivingstone lklivingstone requested a review from a team as a code owner February 17, 2026 15:23
@heatherezell heatherezell added ui bug Used to indicate a potential bug labels Feb 17, 2026
prevPage: page - 1,
total: data.length,
filteredTotal: filteredData.length,
filteredTotal: fullFilteredDataLength,
Copy link
Contributor

Choose a reason for hiding this comment

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

Great work on the PR! Quick note: I think the previous logic in this file is actually the way to go, as it covers some specific requirements we have. Could we revert this file to the previous version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @kiannaquach
The previous logic sets the filteredTotal to filteredData.slice(start, end);, which means if filtered items are more than 100, it will still show 100 items and will only display one page.

My fix changes the filteredTotal to be equal to the actual number of filtered items, which can be used in list.hbs file.

If you want the previous logic to be unchanged, I will have to assign total to be equal to the total filtered items, and revert the change in list.hbs. I have tested this and works as expected, if this seems ok i can commit them.

@showSizeSelector={{false}}
@models={{@currentRouteParams}}
@totalItems={{@secrets.meta.total}}
@totalItems={{if @filterValue @secrets.meta.filteredTotal @secrets.meta.total}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice work using @filterValue to determine which total to show!

const expected = [18, 19];
assert.deepEqual(paginatedData, expected, 'returns correct items for last page');
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding the test!

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

Labels

bug Used to indicate a potential bug ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vault UI : Incorrect pagination when filtering secrets

3 participants