fix(repositories): keep deep-linked ?page=N when search hasn't changed#1246
Open
RenzoMXD wants to merge 1 commit into
Open
fix(repositories): keep deep-linked ?page=N when search hasn't changed#1246RenzoMXD wants to merge 1 commit into
?page=N when search hasn't changed#1246RenzoMXD wants to merge 1 commit into
Conversation
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.
cdca008 to
83a3a27
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The repositories leaderboard's pagination snaps back to page 1 after every click and on direct loads of
/repositories?page=N. The table routesDebouncedSearchInput'sonDebouncedChangethroughuseDataTableParams.setFilter('search', ...), whoseuseCallbackcloses overreact-router-dom'ssetSearchParams. That ref is recreated on every URL change, so everysetPage(N)recreates the callback, which re-fires the wrapper's mount-anchored debounce effect. The fired commit deletes?pagevia the filter's defaultresetPageOnChange, 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 committedsearchQueryin a ref and skipsetFilter('search', ...)when the wrapper hands back the value we already hold. Typing a new search still commits normally and resets?pageas 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
Testing
Verified locally against
npm run dev:/repositories?page=1retains?page=1and renders rows 13–15 of 15.?page=1and stay (no snap-back).?pageso the result list starts at page 1.npm run build— cleannpm run lint—--max-warnings 0cleannpx prettier --check— cleanChecklist
npm run formatandnpm run lint:fixhave been runnpm run buildpassesScreenshots
Before:
Record_2026_05_19_08_23_49_199.mp4
After:
Record_2026_05_19_08_24_59_990.mp4