Open Ellisthion opened 2 years ago
I have a suggested fix for this. Keep the history not changing the same to prevent spamming the history. But store an internal array of state changes so when pressing the back button in the browser you can replace state back to the previous state. Thus fixing both issues.
I'm not sure if this is actually related but, similarly, I've found that the back button doesn't navigate me away from the project page if I've come from a notification. For example, I click on a notification to go to the new upload, then I hit the back button, it loads briefly but just keeps me on the same page. I have to hold and manually select which page to go back to in order to escape, or spam the back button, in which case it goes back 2 pages and then I'm able to select forward and return to the notifications page.. I'm on Firefox on Windows 10.
Environment
No response
Describe the bug
Hitting the browser 'back' button does not allow you to go to a previous page when searching through mods.
Steps To Reproduce
You end up back on the home page, instead of on page 1 of the search results.
Expected behavior
Expected that you'd go back to the previous page of results.
Additional context
This issue is an unintended side-effect of the fix for modrinth/code#1899, wherein the browser history got spammed. The change for that was all search updates use
$router.replace
rather than$router.push
.The search can change from 4 different things, all handled by the same js function:
The search text should clearly stay as
replace
due to the original issue, and whether the dropdowns and filters should bereplace
orpush
is debatable and leaving them asreplace
is fine. However, if the event is triggered by the user changing pages, it should usepush
to allow the user to back/forward through the pages.