Skip to content

Fix infinite scroll total items - #2069

Open
Khanvilkarshravani27 wants to merge 3 commits into
utksh1:mainfrom
Khanvilkarshravani27:fix-infinite-scroll-total-items
Open

Fix infinite scroll total items#2069
Khanvilkarshravani27 wants to merge 3 commits into
utksh1:mainfrom
Khanvilkarshravani27:fix-infinite-scroll-total-items

Conversation

@Khanvilkarshravani27

@Khanvilkarshravani27 Khanvilkarshravani27 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Description

totalItems in Findings.tsx was only ever set from the first /findings API response (initial page load). The loadMore function fetched subsequent pages but never updated totalItems, leaving it stale.

This caused two bugs:

  • Filtering: After applying a filter that changes the server-side total, the findings.length < totalItems guard on the Load More button would use the old unfiltered total — showing the button when it shouldn't, or hiding it too early.
  • Subsequent pages: The displayed Load More (X/Y) counter would show incorrect totals.

Fix: Added setTotalItems(data.total ?? moreFindings.length) inside loadMore after each successful paginated fetch — matching the same pattern already used in the initial load.

Related Issues

Closes #1862

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Ran npm run build in frontend/ — clean build, 0 TypeScript errors, 3093 modules transformed.
  • Ran npm run test — all frontend unit tests passed.
  • Code-reviewed: setTotalItems(data.total ?? moreFindings.length) matches the same pattern used in the initial load (line 255), and data.total is safely typed as number | undefined in FindingsResponse.

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

@utksh1 utksh1 added level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label area:frontend Frontend React/UI work labels Jul 24, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@Khanvilkarshravani27
Khanvilkarshravani27 force-pushed the fix-infinite-scroll-total-items branch from 5de7667 to b23f7e0 Compare July 25, 2026 08:39
@Khanvilkarshravani27

Copy link
Copy Markdown
Collaborator Author

Hello @utksh1,

Split and squashed to a single commit — 2 files only (Findings.tsx + Findings.test.tsx). All unrelated changes (CI, backend, plugins) dropped.

npm run build — 0 TS errors | ✅ npm run test — 27/27 passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Frontend React/UI work level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#87] Findings infinite-scroll loadMore never updates totalItems

2 participants