Skip to content

fix(databases): reset to page 1 when the table filter changes#1465

Open
dawsontoth wants to merge 1 commit into
stagefrom
fix/1463-reset-pagination-on-filter-change
Open

fix(databases): reset to page 1 when the table filter changes#1465
dawsontoth wants to merge 1 commit into
stagefrom
fix/1463-reset-pagination-on-filter-change

Conversation

@dawsontoth

Copy link
Copy Markdown
Contributor

Problem

Fixes #1463.

In the database/table browser (DatabaseTableView), the current page (offset) is not reset when a column filter is applied or cleared. pageIndex is translated straight into offset: pageIndex * pageSize for the search request, so if you're on page 3+ (offset ≥ 40) and apply a filter whose matches all live earlier, the server gets offset: 40 against a result set with fewer than 41 rows and returns an empty page — the list looks empty even though matches exist on page 1.

Steps to reproduce

  1. Open a table with enough rows to paginate and page forward to page 2+.
  2. Apply a column filter whose matching rows fall on page 1.
  3. The result list comes back empty.

Fix

Add appliedSearchConditions to the pageIndex useEffectedState dependency list so the page resets to 0 whenever the applied filter changes:

const [pageIndex, setPageIndex] = useEffectedState(0, [databaseName, tableName, appliedSearchConditions]);

This is the same reset-on-dependency-change pattern the file already uses for sort, selectedIds, wantExactCount, and pageIndex-on-table-change. Because it keys off the applied-filter state that actually drives the query, it covers both the apply and clear paths (applyFilters / clearFilters) and any future code path that mutates the applied filter — the reset can't be forgotten. It mirrors the existing imperative precedents (changePageSize in TablePagination, and the org-list onFilterByNameChanged), which also reset the page to 0 on a window change.

DatabaseTableView is the only list view in the app with both server-side offset pagination and filtering that wasn't already resetting the page (the org list already handles it; logs/deployments/SimpleBrowseDataTable-based views don't use offset pagination).

Testing

  • tsc -b — clean
  • oxlint — clean
  • vitest run — 1267 passed / 11 skipped (full suite; the 6 databases-feature test files pass)

Browser verification of the exact flow deferred — will confirm together against real cluster data.

🤖 Generated with Claude Code

The database/table browser keeps its current page (offset) when a
column filter is applied or cleared. On page 3+ (offset >= 40) a filter
that matches fewer rows than the offset returns an empty page, so the
list looks empty even though matches exist on page 1 (#1463).

Add `appliedSearchConditions` to the `pageIndex` useEffectedState deps
so the page resets to 0 whenever the applied filter changes — the same
reset-on-dependency-change pattern the file already uses for sort,
selectedIds, and pageIndex-on-table-change. This covers both the apply
and clear paths (and any future path that mutates the applied filter).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dawsontoth dawsontoth requested a review from a team as a code owner July 10, 2026 18:50

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates 'DatabaseTableView.tsx' to reset the table's page index to 0 whenever the applied search conditions change, preventing issues where a stale page offset results in empty query results. There are no review comments, so I have no feedback to provide.

@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 46.94% 4393 / 9358
🔵 Statements 47.29% 4687 / 9911
🔵 Functions 38.98% 1049 / 2691
🔵 Branches 39.25% 2852 / 7266
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/features/instance/databases/components/DatabaseTableView.tsx 0% 0% 0% 0% 66-578
Generated in workflow #1430 for commit bb7e456 by the Vitest Coverage Report Action

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio filters don't reset pagination on change

1 participant