fix(TableView): reset pagination when data reduces below current page#34562
fix(TableView): reset pagination when data reduces below current page#34562
Conversation
There was a problem hiding this comment.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Improper key usage for forcing re-renders ▹ view | 🧠 Not in standard |
Files scanned
| File Path | Reviewed |
|---|---|
| superset-frontend/src/explore/components/DataTablesPane/components/SingleQueryResultPane.tsx | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
superset-frontend/src/explore/components/DataTablesPane/components/SingleQueryResultPane.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a pagination bug in the "View as Table" feature where filtering data after navigating to the last page would cause an error. The fix ensures that pagination resets to page 1 whenever a filter is applied.
- Added a
keyprop to the TableView component that changes with the filter text, forcing component remount and pagination reset - Added comprehensive test coverage for the filtering and pagination behavior
- Ensured the
initialPageIndex={0}prop is set to guarantee proper pagination initialization
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| SingleQueryResultPane.tsx | Added key={filterText} and initialPageIndex={0} props to TableView to fix pagination reset issue |
| SingleQueryResultPane.test.tsx | Added new test file with comprehensive coverage for filtering behavior and pagination reset functionality |
superset-frontend/src/explore/components/DataTablesPane/test/SingleQueryResultPane.test.tsx
Outdated
Show resolved
Hide resolved
|
@rusackas Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments |
|
@rusackas Ephemeral environment spinning up at http://35.87.199.83:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup. |
PR Rebased and ImprovedRebased onto latest master and addressed review comments. Review Comment Responses1. Korbit AI - "Improper key usage for forcing re-renders" The
The TableView component uses
The 2. Copilot - "Using 'as any' bypasses TypeScript's type safety" Fixed. The test now uses proper typing with Other Improvements
|
superset-frontend/src/explore/components/DataTablesPane/components/SingleQueryResultPane.tsx
Outdated
Show resolved
Hide resolved
|
Rebased on latest master and fixed the TypeScript CI failure: Changes:
The remaining CI errors (in |
Addressed CodeAnt AI Performance FeedbackGood catch on the performance issue! I've updated the implementation. The ProblemUsing
The SolutionChanged from key={Math.ceil(filteredData.length / dataSize) || 1}This means the table only remounts when the number of pages actually changes, not on every keystroke. This:
Why Not
|
Response to CodeAnt AI Performance SuggestionThanks for the thoughtful review! I considered the suggested Why the simpler toggle approach doesn't work: Why
I've updated the inline comment to document this trade-off for future maintainers. |
Code Review Agent Run #987ddbActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
@SBIN2010 This workflow is deprecated! Please use the new Superset Showtime system instead:
Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments |
|
@SBIN2010 Ephemeral environment spinning up at http://44.255.205.130:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup. |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Code Review Agent Run #586eb2
Actionable Suggestions - 1
-
superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.tsx - 1
- Pagination Reset Logic Bug · Line 257-267
Review Details
-
Files reviewed - 3 · Commit Range:
2826249..d357454- superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.test.tsx
- superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.tsx
- superset-frontend/src/explore/components/DataTablesPane/test/SingleQueryResultPane.test.tsx
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.tsx
Outdated
Show resolved
Hide resolved
When using "View as Table" on a chart, navigating to the last page and
then searching for text that reduces the result set would cause an error:
"getPaginationModel(): currentPage shouldn't be greater than totalPages"
This fix uses React's key prop pattern to reset TableView's internal state
when the filter text changes. When the key changes, React treats it as a
new component instance and resets all internal state including pagination.
Changes:
- Add key={filterText} to TableView to reset pagination on filter change
- Add initialPageIndex={0} as explicit default
- Add explanatory comment in component
- Add tests following flat test() pattern per project guidelines
Fixes #31403
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use GenericDataType enum instead of numeric literals - Cast data through unknown to satisfy strict TypeScript checking Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addresses CodeAnt AI review by documenting why key={filterText} is used
despite the per-keystroke remount, and why key={filterText ? 'filtered' : 'unfiltered'}
wouldn't solve the problem.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When filtering a paginated table, if the current page exceeds the new page count, the pagination state becomes invalid. This adds automatic reset-to-first-page behavior to TableView, matching what ListView already does. This is a proper fix that handles the issue at the component level rather than requiring consumers to use React key patterns for remounting. Fixes #31403 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review Agent Run #149a4f
Actionable Suggestions - 1
-
superset-frontend/src/explore/components/DataTablesPane/test/SingleQueryResultPane.test.tsx - 1
- Type mismatch in data prop · Line 39-42
Additional Suggestions - 1
-
superset-frontend/src/explore/components/DataTablesPane/test/SingleQueryResultPane.test.tsx - 1
-
Test lacks behavior assertion · Line 77-86This test only checks that a table element renders, without asserting the underlying data display logic. Per BITO rule [6262], tests should verify actual behavior like correct data rendering and pagination, not just component presence.
Code suggestion
@@ -83,3 +83,8 @@ - // Verify TableView is rendered - const tableView = container.querySelector('.table-condensed'); - expect(tableView).toBeInTheDocument(); + // Verify TableView is rendered + const tableView = container.querySelector('.table-condensed'); + expect(tableView).toBeInTheDocument(); + // Verify table displays data correctly (first page, 10 items) + expect(screen.getByText('Item 1')).toBeInTheDocument(); + expect(screen.getByText('Item 10')).toBeInTheDocument(); + expect(screen.queryByText('Item 11')).not.toBeInTheDocument();
-
Review Details
-
Files reviewed - 3 · Commit Range:
ddfcfa1..166ec49- superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.test.tsx
- superset-frontend/packages/superset-ui-core/src/components/TableView/TableView.tsx
- superset-frontend/src/explore/components/DataTablesPane/test/SingleQueryResultPane.test.tsx
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
| // Note: The SingleQueryResultPaneProp type expects Record<string, any>[][] | ||
| // but useFilteredTableData and useTableColumns actually work with Record<string, any>[] | ||
| // This type mismatch exists in the codebase - cast through unknown to satisfy TypeScript | ||
| data: mockData as unknown as Record<string, unknown>[][], |
There was a problem hiding this comment.
The type cast here works around a mismatch where the interface defines data as a nested array, but hooks like useFilteredTableData and useTableColumns expect a flat array of row objects. This could lead to runtime errors if data structures don't align. Consider fixing the type definition in QueryResultInterface for better type safety.
Code Review Run #149a4f
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
SUMMARY
Fixes #31403
When using "View as Table" on a Mixed Chart, navigating to the last page and then searching for text not present in the table would cause a pagination error because the current page exceeds the available pages after filtering.
Root Cause:
TableViewusesreact-tableinternally and manages pagination state. When filtering reduces the data to fewer pages than the current page number, the internal state becomes invalid.Fix:
Added automatic pagination reset to
TableViewwhen the current page exceeds available pages. This matches the existing behavior inListViewand handles the issue at the component level rather than requiring consumers to implement workarounds.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: Error/unexpected behavior when searching after navigating to last page
After: Pagination resets to page 1 when filtering reduces page count, no error
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
🤖 Generated with Claude Code