You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Click on Go to /home link or click on the back button inyour browser - at this point onBeforeRouteLeave callback is called only once what you can see in the console logs
Log out from the app, refresh page, and again follow steps 1-3. Now you should see the bug where onBeforeRouteLeave is called twice and it only occurs when you click on the back button in your browser. if you click on Router link it's only called once.
What is expected?
onBeforeRouteLeave to be called only once
The text was updated successfully, but these errors were encountered:
sqal
changed the title
onBeforeRouteLeave is called twice when in some cases
onBeforeRouteLeave is called twice in some cases
Mar 16, 2022
I too see onBeforeRouteLeave called twice, even in 4.1.6 version.
Might be a regression of this issue, but frankly it's hard to tell, as the repo in the repro link above is not available anymore and there were exactly zero tests written as part of the faa8562 commit that tried to fix it.
I might create repro when I have a free couple of hours, but in the meantime I would like to humbly propose the advantages of starting every fix by writing a failing test. Creating a repro for a router is not exactly easy, you need a full-blown front-end project for that. All the more reason for strong test coverge.
@ivos I am sorry for deleting my original repository. I have restored it. As for the bug itself, I no longer see it in vue-router 4.1.6. Maybe yours is different from mine.
Version
4.0.14
Reproduction link
https://github.com/sqal/vue-rotuer-bug
It's vite app so
npm install && npm run dev
Steps to reproduce
Go to /home
link or click on the back button inyour browser - at this point onBeforeRouteLeave callback is called only once what you can see in the console logssteps to reproduce bug:
Log out from the app, refresh page, and again follow steps 1-3. Now you should see the bug where onBeforeRouteLeave is called twice and it only occurs when you click on the back button in your browser. if you click on Router link it's only called once.
What is expected?
onBeforeRouteLeave to be called only once
The text was updated successfully, but these errors were encountered: