bug(survey): Going back after pressing `explore results` does not bring me back to survey's page
Bug Description
https://github.com/user-attachments/assets/3f9c124a-62cc-48c8-be06-267a0c5f5b1f
How to reproduce
- Have a survey that has a response.
- Click on
Explore Resultson the survey page - Click on the browser back button multiple times
- Unable to navigate back to the survey
Additional context
I tried only on chrome so far and only 1 survey.
Debug info
- [x] PostHog Cloud, Debug information:
Session: https://us.posthog.com/project/sTMFPsFhdP1Ssg/replay/019723bd-c6d8-7157-a566-734755227b85?t=2153
Admin: http://go/adminOrgUS/0196b42e-7da5-0000-5ebf-394ff456f41d (project ID 162378)
Some additional context:
I noticed that this bug happens only if the leave insight window alert is shown. If the leave insight alert isn't shown, the back button will go back to the correct url.
The window alert logic is in:
https://github.com/PostHog/posthog/blob/3370261c0ad9599b67a60fe2402513ef3fe8d98b/frontend/src/scenes/insights/insightSceneLogic.tsx#L395-L443
It seems like when confirm is clicked, the url is replaced:
https://github.com/user-attachments/assets/5de0d977-bfc7-4bbe-89fa-7da15a514149
Clicking on cancel will result in the alert to always show, and you can see that the url is constantly being replaced:
https://github.com/user-attachments/assets/43cc1781-c445-4013-abed-81da7fd45938
Hey @lshaowei18 thanks for your issue and PR! This is indeed a painful bug in the common browser UX.
I'll take a look on your code by Tuesday at most, and we can work together to get it merged