Losing URL Search params on navigate.push under certain scenarios
See original GitHub issueDescription
Under certain conditions (see Loom video for example) we are finding that we are losing URL search params after a navigate.push
call and are having a hard time understanding why this is happening. General debugging would suggest to look for unintentional follow-up calls to navigate.push
, but since we wrap all navigate method calls with our own wrapper with debug output, we are finding only a single navigate.push
call is made (with correct path + search params) but yet browser history appears to immediately update and we lose search params.
Example scenario:
- Visit https://contra.com/discover/independents and click on a “Get In Touch” button.
- You’ll be presented with a modal indicating you need to “Complete Sign Up”. Click the “Complete Sign Up” button which will redirect you to the
/sign-up
route with attached search params (redirectTo
, etc). - Note that the URL is in the browser address bar is correct, and the search params exist in the path.
- Hit the “back” button in your browser to go back to the
/discover/independents
page. - Click on a “Get In Touch” button followed up by the modals “Complete Sign Up” button.
- Notice how you are navigated to the
/sign-up
route with search params, and then almost immediately lose search params as another entry to the history stack is made for the same path (but now without the search params). Note how you lost the search params in the browser address bar. - If you were to hit “back” in the browser again now, you’ll notice that the search params come back.
Again, we only see one call from our code to navigate.push()
happening, but clearly for some reason we are getting two entries in the browser history, one correctly with the search params, immediately followed by another entry without them.
https://www.loom.com/share/9dc365e4e4a948369080d76d6549b89c
Not sure how this would be taking place and would love any guidance on debugging this behavior from vite-plugin-ssr
client routing.
Error Stack
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:14 (9 by maintainers)
Top GitHub Comments
I recommend to do this then. This should definitely tell you why
pushState()
is being called twice.Yeah thanks @brillout. I’ll keep digging here. I’ll update you later.