Skip to content

refactor(ui): unify DataTable pagination into a single callback#10863

Open
pfe-nazaries wants to merge 4 commits intomasterfrom
fix/data-table-unified-pagination-callback
Open

refactor(ui): unify DataTable pagination into a single callback#10863
pfe-nazaries wants to merge 4 commits intomasterfrom
fix/data-table-unified-pagination-callback

Conversation

@pfe-nazaries
Copy link
Copy Markdown
Contributor

@pfe-nazaries pfe-nazaries commented Apr 23, 2026

Context

DataTablePagination in controlled mode exposed two separate callbacks, onPageChange and onPageSizeChange, and fired them back-to-back in the same tick when the user picked a new page size. Consumers that drove state through router.push (reading useSearchParams() inside each handler) silently reverted the size change: the second push reconstructed the URL from a stale searchParams snapshot taken before the first push and overwrote the new pageSize param.

The race surfaced most clearly in the Attack Paths scan selector, where picking a new page size from the "Rows per page" selector appeared to do nothing. The Attack Paths scans pagination fix #10864 carries a short-term suppressNextPageResetRef workaround in scan-list-table.tsx so the reported bug is unblocked; that workaround should be removed once this refactor lands.

Description

Unify the two callbacks into a single onPaginationChange(page, pageSize) that always emits the full post-event state. When the user changes the page size, DataTablePagination now calls it once with (1, newSize), so the consumer applies both values in a single update and cannot race on a stale snapshot.

  • components/ui/table/data-table-pagination.tsx: replace the two-callback API with onPaginationChange; the size-change branch now emits a single atomic call
  • components/ui/table/data-table.tsx: forward the new prop, refresh the JSDoc example
  • components/resources/table/resource-detail-content.tsx: collapse the two handlers into one onPaginationChange (React state batches already prevented a visible race here, but the unified API is cleaner)
  • attack-paths/query-builder/_components/scan-list-table.tsx: switch to onPaginationChange

Related PR

Steps to review

  1. cd ui && pnpm run typecheck — passes.
  2. cd ui && pnpm run lint:fix — passes.
  3. cd ui && pnpm vitest run — full suite (535 tests) passes.
  4. Manual check of the two affected tables:
    • Attack Paths /attack-paths/query-builder: with enough scans to trigger the "Rows per page" selector (totalEntries > 10), change the page size. The size change must stick and the table must reset to page 1.
    • Resources drawer: open a resource with many findings, paginate + change page size; behaviour unchanged.

Checklist

Community Checklist
  • This feature/issue is listed in here or roadmap.prowler.com
  • Is it assigned to me, if not, request it via the issue/feature in here or Prowler Community Slack

UI (if applicable)

  • All issue/task requirements work as expected on the UI
  • Screenshots/Video - Mobile (X < 640px)
  • Screenshots/Video - Tablet (640px > X < 1024px)
  • Screenshots/Video - Desktop (X > 1024px)
  • Ensure new entries are added to ui/CHANGELOG.md

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@pfe-nazaries pfe-nazaries requested a review from a team as a code owner April 23, 2026 07:37
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

✅ All necessary CHANGELOG.md files have been updated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

Conflict Markers Resolved

All conflict markers have been successfully resolved in this pull request.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

🔒 Container Security Scan

Image: prowler-ui:3c3176b
Last scan: 2026-04-27 07:44:25 UTC

📊 Vulnerability Summary

Severity Count
🔴 Critical 2
Total 2

2 package(s) affected

⚠️ Action Required

Critical severity vulnerabilities detected. These should be addressed before merging:

  • Review the detailed scan results
  • Update affected packages to patched versions
  • Consider using a different base image if updates are unavailable

📋 Resources:

Pablo F.G added 3 commits April 23, 2026 12:00
- Replace onPageChange/onPageSizeChange pair with onPaginationChange(page, pageSize)
- Fix silent revert of page-size change when consumers drive state via router.push
- Update consumers ScanListTable and ResourceDetailContent
- Rephrase to focus on user-facing symptom (rows-per-page selector)
- Drop implementation detail; add PR link
@pfe-nazaries pfe-nazaries force-pushed the fix/data-table-unified-pagination-callback branch from b344575 to 5715bb7 Compare April 23, 2026 10:01
…ied-pagination-callback

# Conflicts:
#	ui/CHANGELOG.md
#	ui/app/(prowler)/attack-paths/(workflow)/query-builder/_components/scan-list-table.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant