fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Deleting last row in server-side paginated table leads to empty state when there still are rows in the previous page

Open nulmete opened this issue 5 months ago β€’ 4 comments

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.
  1. Have 21 policies created
  2. Go to second page of policies.
  3. Delete the only policy in page 2.
  4. Notice the empty state being shown.

πŸ•―οΈ More info (optional)

N/A

nulmete avatar Jul 02 '26 16:07 nulmete

@nulmete Opened #48683 for this. It navigates back to the previous page when a delete empties the current page.

rrahul-1 avatar Jul 03 '26 14:07 rrahul-1

For QA: we should not only test the fix on the Policies page but also on other server-side paginated tables across other pages.

nulmete avatar Jul 08 '26 16:07 nulmete

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

xpkoala avatar Jul 28 '26 16:07 xpkoala

Tables turn pages, Empty state now retreats, Fleet's data engages.

fleet-release avatar Aug 06 '26 02:08 fleet-release