Fix infinite scroll total items - #2069
Conversation
utksh1
left a comment
There was a problem hiding this comment.
The intended Findings totalItems fix is mixed with unrelated CI workflow edits, scapy parser tests, and saved-view authentication tests. Please split the PR to Findings.tsx plus focused frontend coverage only, then resolve the failing backend/frontend checks.
utksh1
left a comment
There was a problem hiding this comment.
The intended Findings totalItems fix is mixed with unrelated CI workflow edits, scapy parser tests, and saved-view authentication tests. Please split the PR to Findings.tsx plus focused frontend coverage only, then resolve the failing backend/frontend checks.
…1862) totalItems was only set from the first /findings call. Subsequent loadMore fetches never updated it, so the 'Load More (X/Y)' guard used a stale total whenever filters changed the server-side count between pages. Changes: - Import FindingsResponse type and use it instead of �ny in the initial load callback; filter findings to those with string ids for safety - Add setTotalItems(data.total ?? moreFindings.length) inside loadMore after each successful paginated fetch, matching the same pattern already used on initial load; also apply the id-string filter to moreFindings - Add two unit tests for the totalItems sync: one verifies the button hides when totalItems drops to match findings.length after loadMore; the other verifies the counter keeps updating correctly across pages
5de7667 to
b23f7e0
Compare
|
Hello @utksh1, Split and squashed to a single commit — 2 files only (
✅ |
Description
totalItemsinFindings.tsxwas only ever set from the first/findingsAPI response (initial page load). TheloadMorefunction fetched subsequent pages but never updatedtotalItems, leaving it stale.This caused two bugs:
findings.length < totalItemsguard on the Load More button would use the old unfiltered total — showing the button when it shouldn't, or hiding it too early.Load More (X/Y)counter would show incorrect totals.Fix: Added
setTotalItems(data.total ?? moreFindings.length)insideloadMoreafter each successful paginated fetch — matching the same pattern already used in the initial load.Related Issues
Closes #1862
Type of Change
How Has This Been Tested?
npm run buildinfrontend/— clean build, 0 TypeScript errors, 3093 modules transformed.npm run test— all frontend unit tests passed.setTotalItems(data.total ?? moreFindings.length)matches the same pattern used in the initial load (line 255), anddata.totalis safely typed asnumber | undefinedinFindingsResponse.Checklist