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
When I add a guard with onBeforeRouteLeave (inside a composable), the specified guard function is registered and called as expected. If I however manage to leave the page (because the guard allowed it) and then enter the same route/component again, a new guard is registered but the previous one is also still active and called. I validated this by printing out calls to the guard, including an auto-generated id of a computed ref that is created within the component.
This is problematic in my case because the guard relies on a computed "canLeave" flag to prompt for user confirmation and that is never updated after the page was left, meaning if the page was left, reentered and then the user wants to leave again, they will always be prompted even if they didn't make any changes on the page they are currently on.
The text was updated successfully, but these errors were encountered:
I worked around this by adding another flag that I set just before I allow leaving the page and that I check as the first thing whenever the guard is called. While it still means the guard is never cleaned up, it does allow the user to leave a page when they should be able to without getting prompted.
This is on Vue 2.7.
When I add a guard with
onBeforeRouteLeave
(inside a composable), the specified guard function is registered and called as expected. If I however manage to leave the page (because the guard allowed it) and then enter the same route/component again, a new guard is registered but the previous one is also still active and called. I validated this by printing out calls to the guard, including an auto-generated id of a computed ref that is created within the component.This is problematic in my case because the guard relies on a computed "canLeave" flag to prompt for user confirmation and that is never updated after the page was left, meaning if the page was left, reentered and then the user wants to leave again, they will always be prompted even if they didn't make any changes on the page they are currently on.
The text was updated successfully, but these errors were encountered: