Skip to content

perf(search): paginate SearchResults to cap mounted cards per page - #1087

Open
AvatarMiiDe wants to merge 3 commits into
rinafcode:mainfrom
AvatarMiiDe:virtualization-searchresults
Open

perf(search): paginate SearchResults to cap mounted cards per page#1087
AvatarMiiDe wants to merge 3 commits into
rinafcode:mainfrom
AvatarMiiDe:virtualization-searchresults

Conversation

@AvatarMiiDe

Copy link
Copy Markdown
## Description

`SearchResults` previously rendered the entire result set into a CSS grid at once — mounting every card and its external image with no limit, causing layout jank on broad queries returning hundreds of courses.

This PR adds client-side pagination to cap the number of cards mounted per render:

- Results are sliced to `pageSize` items (default **12**) per page
- A Prev / Next pagination bar with a "Page N of M" indicator is rendered below the grid when `totalPages > 1`
- The static "Z results found" counter is replaced with a dynamic "Showing X–Y of Z results" range
- Page resets to 1 automatically via `useEffect` whenever the `results` prop changes (new search / filter)
- Two new optional props (`pageSize`, `initialPage`) are fully backward-compatible — all existing callers are unaffected
- 29 unit tests added in `SearchResults.test.tsx` covering slice correctness, navigation, boundary states, page reset, and sort controls

## Related Issue

Closes #

## Type of Change

- [x] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update

## Checklist

- [x] Code follows project style guidelines
- [x] Self-review completed
- [x] No console errors
- [x] Uses Lucide icons consistently (`ChevronLeft`, `ChevronRight` for pagination; existing icons preserved)
- [x] Responsive design implemented (pagination bar is flex-centered, grid remains 1/2/3-col responsive)
- [ ] Starknet best practices followed (not applicable — UI-only change)


Close #941

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@AvatarMiiDe Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done!
Kindly fix workflow to pass

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants