Skip to content

fix: prevent browse page reset on back navigation in app#6390

Closed
stijnwtf wants to merge 1 commit into
modrinth:mainfrom
stijnwtf:fix/app-browse-back-page-reset
Closed

fix: prevent browse page reset on back navigation in app#6390
stijnwtf wants to merge 1 commit into
modrinth:mainfrom
stijnwtf:fix/app-browse-back-page-reset

Conversation

@stijnwtf

Copy link
Copy Markdown

Summary

  • Fixes a bug in the app where browsing content within an instance (e.g. a modpack), navigating to a project page, and then using the back button always returned to page 1 instead of the page the user was on.
  • Root cause: useBrowseSearch resets currentPage to 1 whenever filters/sort/query change. This reset watcher also fired during the initial setup of the Browse page, when a default server_game_version filter is pushed for the instance's game version, overwriting the page number restored from the b query param before it could take effect.
  • Fix: the reset watcher is now guarded by a hasInitialized flag that only becomes true after the first refreshSearch() completes, so setup-time filter pushes no longer reset the page while user-driven filter changes still reset it as expected.

Test plan

  • In the app, open an instance and browse mods/resource packs
  • Navigate to page 4 of results
  • Click into a project, then click the back button
  • Verify the browse page returns to page 4 (not page 1)
  • Verify changing filters, sort, or search query while browsing still resets to page 1

The pagination reset watcher fired on the initial filter setup
(e.g. pushing a default server_game_version filter from an instance
context), resetting currentPage to 1 before the page restored from
the URL could be used. Guard the reset until after the first search
completes.
Copilot AI review requested due to automatic review settings June 13, 2026 16:34
@modrinth-bot

Copy link
Copy Markdown
Member

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds an initialization guard to prevent the browse search watcher from resetting pagination (currentPage) before the first search lifecycle has completed.

Changes:

  • Introduces a hasInitialized flag to gate the page-resetting watcher.
  • Marks initialization complete in a finally block after the search routine finishes.


let searchVersion = 0
let searchDebounceTimer: ReturnType<typeof setTimeout> | null = null
let hasInitialized = false
Comment on lines +191 to 192
if (!hasInitialized) return
currentPage.value = 1
Comment on lines +252 to 254
} finally {
hasInitialized = true
}

let searchVersion = 0
let searchDebounceTimer: ReturnType<typeof setTimeout> | null = null
let hasInitialized = false
@Prospector

Copy link
Copy Markdown
Member

Do not submit AI generated pull requests, if you do this again you will be permanently blocked.

@Prospector Prospector closed this Jun 13, 2026
@stijnwtf stijnwtf deleted the fix/app-browse-back-page-reset branch June 13, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants