fix(frontend): adjust pagination totalPages and currentPage to respect search filters (#262)#274
fix(frontend): adjust pagination totalPages and currentPage to respect search filters (#262)#274yashvi-3106 wants to merge 2 commits into
Conversation
|
Thank you for submitting a pull request. Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully. Formatting and Branching
|
jagdish-15
left a comment
There was a problem hiding this comment.
I noticed one remaining edge case while testing.
When the search results contain more than 25 users, we intentionally render all matching results on a single page. However, the pagination controls still think there are multiple pages, so the information above the table (e.g. Total Users: 74 | Showing: 1-25 | Page: 1/3) becomes inconsistent.
Instead of trying to paginate search results, I think we could simply treat search mode as a single-page view. That would mean:
- Disabling the pagination controls while a search is active.
- Updating the information above the table to reflect the filtered results (e.g.
Total Users: 74 | Showing: 1-74). This count should include users marked asNOT ACTIVE YETif they match the search query, rather than being based on the underlying leaderboard dataset.
Could you update the implementation accordingly?
…during active search
|
@jagdish-15 you can review it now i fixed it! |
Description
This PR fixes issue #262 where pagination controls did not dynamically adapt to search filters, letting users navigate to extra empty pages, and currentPage did not reset to 1 upon search query changes.
Linked Issue
Fixes #262
Changes Made
search.js: ResetcurrentPage = 1on input, clear button click, and escape keypress.leaderboard.html: Saved dynamic filtered page count towindow.totalPagesinsideapplyFiltersAndRender().pagination.js: Updated the "Next" page click listener to usewindow.totalPagesinstead of recalculating from the raw global dataset length.Type of Change
Testing
Note: Verified by starting the server locally, navigating to page 3, searching for "Nikhil" (which only has 1 match), confirming the pagination stats correctly updated to
Page: 1/1, and verifying the "Next" button was disabled. Clearing search successfully restored normal multi-page pagination.Checklist
npx prettier --write .before submittingfeature/*branch, not themainbranch