Skip to content

fix(repositories): keep deep-linked ?page=N when search hasn't changed#1246

Open
RenzoMXD wants to merge 1 commit into
entrius:testfrom
RenzoMXD:fix/repositories-pagination-snapback
Open

fix(repositories): keep deep-linked ?page=N when search hasn't changed#1246
RenzoMXD wants to merge 1 commit into
entrius:testfrom
RenzoMXD:fix/repositories-pagination-snapback

Conversation

@RenzoMXD
Copy link
Copy Markdown
Contributor

@RenzoMXD RenzoMXD commented May 19, 2026

Summary

The repositories leaderboard's pagination snaps back to page 1 after every click and on direct loads of /repositories?page=N. The table routes DebouncedSearchInput's onDebouncedChange through useDataTableParams.setFilter('search', ...), whose useCallback closes over react-router-dom's setSearchParams. That ref is recreated on every URL change, so every setPage(N) recreates the callback, which re-fires the wrapper's mount-anchored debounce effect. The fired commit deletes ?page via the filter's default resetPageOnChange, snapping the table back to page 1 right after the click.

Same root cause #1108 fixed for MinerPRsTable. This PR applies the same callsite gate: keep the latest committed searchQuery in a ref and skip setFilter('search', ...) when the wrapper hands back the value we already hold. Typing a new search still commits normally and resets ?page as intended; the mount fire and any re-render driven by an unrelated URL change no longer touches the page slot.

Closes #1247

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

Verified locally against npm run dev:

  • Direct load /repositories?page=1 retains ?page=1 and renders rows 13–15 of 15.
  • "Go to next page" / "Go to last page" advance to ?page=1 and stay (no snap-back).
  • Typing into the search input still commits the filter after the debounce and resets ?page so the result list starts at page 1.
  • npm run build — clean
  • npm run lint--max-warnings 0 clean
  • npx prettier --check — clean

Checklist

  • New components are modularized/separated where sensible
  • Uses predefined theme (e.g. no hardcoded colors)
  • Responsive/mobile checked (behavior is URL/query only)
  • Tested against the test API
  • npm run format and npm run lint:fix have been run
  • npm run build passes
  • Screenshots included for any UI/visual changes

Screenshots

Before:

Record_2026_05_19_08_23_49_199.mp4

After:

Record_2026_05_19_08_24_59_990.mp4

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 19, 2026
The repositories leaderboard table routes `DebouncedSearchInput`'s
`onDebouncedChange` through `useDataTableParams.setFilter('search', ...)`,
whose `useCallback` closes over `react-router-dom`'s `setSearchParams`.
That ref is recreated on every URL change, so every `setPage(N)` recreates
the callback, which re-fires the wrapper's mount-anchored debounce effect.
The fired commit deletes `?page` via the filter's default
`resetPageOnChange`, snapping the table back to page 1 right after the
click.

Same root cause entrius#1108 fixed for `MinerPRsTable`. Apply the same callsite
gate: keep the latest committed `searchQuery` in a ref and skip
`setFilter('search', ...)` when the wrapper hands back the value we
already hold. Typing a new search still commits normally and resets
`?page` as intended; the mount fire and any re-render driven by an
unrelated URL change no longer touches the page slot.

Verified locally:
- Direct load `/repositories?page=1` retains `?page=1` and renders rows
  13-15 of 15.
- "Go to next page" / "Go to last page" advance to `?page=1` and stay.
- Typing into the search input still commits the filter after the
  debounce and resets `?page` so the result list starts at page 1.
- `npm run build`, `npm run lint`, `npx prettier --check` all clean.
@RenzoMXD RenzoMXD force-pushed the fix/repositories-pagination-snapback branch from cdca008 to 83a3a27 Compare May 19, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] /repositories pagination snaps back to page 1 after every click and on direct URL load

1 participant