Skip to content

fix(frontend): adjust pagination totalPages and currentPage to respect search filters (#262)#274

Open
yashvi-3106 wants to merge 2 commits into
codepvg:mainfrom
yashvi-3106:feature/pagination-search-fix
Open

fix(frontend): adjust pagination totalPages and currentPage to respect search filters (#262)#274
yashvi-3106 wants to merge 2 commits into
codepvg:mainfrom
yashvi-3106:feature/pagination-search-fix

Conversation

@yashvi-3106

Copy link
Copy Markdown
Contributor

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: Reset currentPage = 1 on input, clear button click, and escape keypress.
  • leaderboard.html: Saved dynamic filtered page count to window.totalPages inside applyFiltersAndRender().
  • pagination.js: Updated the "Next" page click listener to use window.totalPages instead of recalculating from the raw global dataset length.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

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

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

@jagdish-15 jagdish-15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

screencapture-localhost-3000-leaderboard-2026-07-01-20_24_18

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 as NOT ACTIVE YET if they match the search query, rather than being based on the underlying leaderboard dataset.

Could you update the implementation accordingly?

@yashvi-3106

Copy link
Copy Markdown
Contributor Author

@jagdish-15 you can review it now i fixed it!

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.

bug: Pagination totalPages count does not respect active search filters

2 participants