Deleting last row in server-side paginated table leads to empty state when there still are rows in the previous page
Fleet versions
- Discovered: 4.89
- Reproduced: 4.89
Web browser and operating system: Latest Chrome
π₯ Β Actual behavior
I had 21 policies and (20 in page 1; 1 in page 2), deleted the policy from page 2 and that led me to the empty state. Note: policies is paginated server-side and this happens on all server-side paginated tables.
https://github.com/user-attachments/assets/ddf52663-cd13-426e-98f5-154d928d6f8a
π οΈ Expected behavior
Empty state shouldn't be shown when there still are rows in other pages of the table. Suggestion: navigate to previous page.
π§βπ» Β Steps to reproduce
These steps:
- [x] Have been confirmed to consistently lead to reproduction in multiple Fleet instances.
- [ ] Describe the workflow that led to the error, but have not yet been reproduced in multiple Fleet instances.
- Have 21 policies created
- Go to second page of policies.
- Delete the only policy in page 2.
- Notice the empty state being shown.
π―οΈ More info (optional)
N/A
@nulmete Opened #48683 for this. It navigates back to the previous page when a delete empties the current page.
For QA: we should not only test the fix on the Policies page but also on other server-side paginated tables across other pages.
Validation: #48641 β Deleting last row on a paginated page shows empty state instead of going back
Verdict: β CONFIRMED FIXED β code review + unit tests + live UI repro across three server-side paginated tables Instance/branch: localhost:8080 Β· v4.90.0-rc.2607232113 Β· rc-minor-fleet-v4.90.0 Fix: PR #48683 "Return to previous page when the last policy on a page is deleted", commit c92b848919, merged 2026-07-08, on the RC branch
1. Code review β
Fix lives in the SHARED components/TableContainer/TableContainer.tsx (a useEffect), so it covers ALL server-side paginated tables at once (Policies, Reports, Hosts, etc.):
// when a non-first page is empty (last row deleted, or URL page no longer exists),
// navigate back to a page with data instead of stranding on the empty state
if (data.length === 0 && pageIndex !== 0) {
lastValidPageIndex = totalCount known ? ceil(totalCount/pageSize)-1 : pageIndex-1
onPaginationChange(max(0, min(lastValidPageIndex, pageIndex-1)))
}
On RC branch (c92b848919 ancestor of HEAD).
2. Unit tests β (generic TableContainer β table-agnostic)
npx jest TableContainer.tests.tsx -> 5/5 PASS: β navigates back to the last page with data when a non-first page is empty β shows the empty state and stays put on the first page β does not redirect while the page is still loading β settles on the last page with data when entered on an out-of-range page β jumps straight to the first page when the total count is a known zero
3. Live UI repro β (Policies β exact issue steps)
Created 21 policies (20 on page 1, 1 on page 2). Headless Chrome: BEFORE /policies/manage?...&page=1 -> 1 row, no empty state (selected the row, Delete, confirmed) AFTER /policies/manage?...&page=0 -> 20 rows, no empty state Deleting the last row on page 2 navigated back to page 1 with the remaining rows β NOT the empty state.
4. Cross-table coverage β (server-side paginated tables β per @nulmete's QA note)
Verified LIVE on three independent server-side paginated tables (navigate to page 2 with 1 row β delete it β auto-navigate back to page 1). Covers two different page sizes:
| Table | Pagination | Page size | Live test | Result |
|---|---|---|---|---|
| Policies | server-side | 20 | 21 policies, deleted lone row on p2 | β page 1β0, 20 rows, no empty state |
| Reports (queries) | server-side | 20 | 21 reports, deleted lone row on p2 | β page 1β0, 20 rows |
| Hosts | server-side | 50 | enrolled 51 fake hosts (isolated by search), deleted lone row on p2 | β page 1β0, 50 rows |
Tables turn pages, Empty state now retreats, Fleet's data engages.