Table server pagination shows 0 and removes the configured page size when row count is smaller
- Dominant language
- Python
- Stars
- 74.8k
- Forks
- 18.3k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 685
Description
### Bug description
In the standard **Table** chart, the server-pagination page-size selector behaves incorrectly when the total row count is smaller than the configured **Server Page Length**.
With 12 total rows and `Server Page Length = 20`, all 12 rows are correctly displayed on one page, but the **Show entries per page** selector initially contains only `0` and `10`. The configured value `20` is never shown.
After selecting `10`, the table correctly changes to two pages. However, `0` then disappears from the selector, leaving only `10`. It is impossible to return to the one-page display without refreshing the page.
### How to reproduce the bug
1. Create a standard **Table** chart whose query returns exactly 12 rows.
2. Set **Row limit** to `10000`.
3. Enable **Server pagination**.
4. Set **Server Page Length** to `20`.
5. Save or render the chart.
6. Observe that all 12 rows are displayed on one page, while the page-size selector contains only `0` and `10`; `20` is absent.
7. Select **Show 10 entries per page**.
8. Observe that the table now has two pages.
9. Open the page-size selector again and observe that `0` has disappeared and only `10` is available.
### Expected results
- The selector should display `20` as the current page size.
- The configured page size should remain available even when it is greater than the total row count.
- Users should be able to switch from `10` back to `20` without refreshing.
- A page size of `0` should not appear unless it is a real supported option.
### Actual results
- Initially, the selector contains only `0` and `10`; `20` is never shown.
- Despite the selector showing `0`, all 12 rows are displayed on one page.
- After selecting `10`, `0` disappears and only `10` remains.
- The only way to restore the configured one-page display is to refresh the page.
### Suspected cause
In `TableChart.tsx`, server page-size options are filtered using `n <= rowCount`:
https://github.com/apache/superset/blob/6.1.0/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx#L388-L395
When `rowCount = 12`, the configured page size `20` is removed from the available options.
Then, in `DataTable.tsx`, when no available option is greater than or equal to the current server page size, `resultCurrentPageSize` is changed to `0`:
https://github.com/apache/superset/blob/6.1.0/superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx#L460-L473
A possible fix would be to avoid filtering server-side page-size options by `rowCount`, or at least always preserve the configured/current page size. The component should also avoid converting a valid current page size to `0`.
### Environment
- Apache Superset: 6.1.0
- Installation: PyPI
- Python: 3.11
- Server OS: OpenCloudOS
- Database: MySQL
- Visualization: Standard Table
- Server pagination: Enabled
- Row limit: 10000
- Server Page Length: 20
- Total result rows: 12
### Additional context
The issue is reproducible after saving the chart and also in the rendered/shared table. Refreshing the page temporarily restores the configured page size, but the incorrect selector state returns.
Contributor guide
Research direction
Start by reading the server page-size filtering in superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx around lines 388-395, then trace the current-size handling in DataTable/DataTable.tsx around lines 460-473. Verify the behavior with a table returning 12 rows and a Server Page Length of 20. Done means 20 remains available and selected, 0 is not introduced, and switching to 10 still allows returning to 20 without refreshing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100