Deactivation Guard breaks the routing history #13586
Comments
|
A |
yeah. So just returning history to the previous state is the only way I can think of here. |
|
Hi,
|
|
@michelherv yeah, reproduce on plunkr and file a new issue pls |
|
@DzmitryShylovich done! You can found the description here #14645 |
|
This is still broken in Angular 4.0. Any plans to fix it? |
|
Is there a work around for this by any chance? |
|
I couldn't find any workaround inside my candeactivate class. Still waiting for the PR |
|
It seems it should work like resolve does, no? That is, it doesn't navigate until canDeactivate cancels or confirms whether the component can be deactivated (or routed away from). Otherwise, I don't really understand what it's purpose is. |
|
Skaiser, its purpose is what you described, but there is a bug currently. A PR has been made to solve the issue, but until then the CanDeactivate guard breaks your history. |
|
Our team develops an application that uses browser history heavily to navigate through pages. Unfortunately, we have faced the same issue which causes a bit weird navigation experience for users. |
|
Hey Guys |
|
Hi all, what's the status on this issue? Or is there any workaround? |
|
I am also using Angular 4.0 and Router 4.0. Having this issue as well. This is a major bug and is a big setback for our application. Would be great if a workaround could be found or fix be made to this. |
|
Still a problem, any ideas ? |
|
Still have no fix ? |
|
Can someone give the state of this issue? |
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
|
Any updates on this? Inquiring minds want to know... |
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
|
Is the Activate Guard also being worked on for the same issue here or are the changes just targeting Deactivation Guards? |
I don't have an answer, but I want to also step in and +1 this point. Our setup calls for an activation guard to stop navigation to particular routes when a condition is met. The same exact problem detailed in this issue happens on this scenario also. |
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
|
Why hasn't this been fixed yet? Is there any sign from the angular dev team? |
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
|
Can @aahmedayed say in what version this fix will be coming out? 12? |
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the “back” or the “forward” using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before popstate is triggered and when the guard returns “false”. So by using the `goTo` method, we can bring the user back to the page where he is supposed to be after performing the action. add the pageId field and use it instead of navigationId. fixes angular#13586
Since we can’t determine whether the user actually meant the `back` or the `forward` using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before `popstate` is triggered and when the guard returns `false`. So by using the `History#go` method, we can bring the user back to the page where he is supposed to be after performing the action. Add the `ngRouterPageId` in the `RestoredState`. Add a solution to the navigation with `skipLocationChange`. add a solution to the navigation with `replaceUrl`. Add a solution to the navigation with `eager` `urlUpdateStrategy` Add `cancelNavigationTransition` method to the router. change the behavior of cancelNavigationTransition method. fixes angular#13586
Since we can’t determine whether the user actually meant the `back` or the `forward` using the popstate event. We could use this as the solution for the issue of getting the url back to it’s initial state, right before `popstate` is triggered and when the guard returns `false`. So by using the `History#go` method, we can bring the user back to the page where he is supposed to be after performing the action. Add the `ngRouterPageId` in the `RestoredState`. Add a solution to the navigation with `skipLocationChange`. add a solution to the navigation with `replaceUrl`. Add a solution to the navigation with `eager` `urlUpdateStrategy` Add `cancelNavigationTransition` method to the router. fixes angular#13586
… is cancelled We can’t determine whether the user actually meant the `back` or the `forward` using the popstate event (triggered by a browser back/forward) so we instead need to store information on the state and compute the distance the user is traveling withing the browser history. So by using the `History#go` method, we can bring the user back to the page where he is supposed to be after performing the action. implementation for angular#13586
… is cancelled (#38884) We can’t determine whether the user actually meant the `back` or the `forward` using the popstate event (triggered by a browser back/forward) so we instead need to store information on the state and compute the distance the user is traveling withing the browser history. So by using the `History#go` method, we can bring the user back to the page where he is supposed to be after performing the action. implementation for #13586 PR Close #38884
… is cancelled (#38884) We can’t determine whether the user actually meant the `back` or the `forward` using the popstate event (triggered by a browser back/forward) so we instead need to store information on the state and compute the distance the user is traveling withing the browser history. So by using the `History#go` method, we can bring the user back to the page where he is supposed to be after performing the action. implementation for #13586 PR Close #38884
|
Hi, quick update here:
|
I'm submitting a ... (check one with "x")
Current behavior
Currently, I have a deactivation guard on a route which will return false or true depending on a condition. To get to this guarded route, the user must pass though 3 navigation step. Now, once on the guarded route, when using
location.back(), the guard is called. If it returnstrue, the previous route is loaded. If the guard returns false, the navigation is cancelled. But if we redo a Location.back() after a failed navigation, the previous route that will be loaded will be 2 steps in the history instead of 1 (user perception).Workflow
Expected behavior
An expected behavior for a user would be that navigating back brings back to the previous routed page.
Workflow
Minimal reproduction of the problem with instructions
Plnkr
Personnal investigation
After some investigation, I saw that in
routerState$.then(router.ts line 752) this logic used whennavigationIsSuccessful == falseis pretty simply but it is the actual cause of this bug. Basically, when a deactivation guard is hit, the location of the browser is already changed to the previous route. Which means that when the guard returns false, therouterState$runs his logic and callsresetUrlToCurrentUrlTree(). At this point we can see that we replace the state of the current location. But by doing this, we loose that route in the history which means that in my plunker, if we click the block nav back 3 times and then click the nav back we will actually kill the application.What is the motivation / use case for changing the behavior?
This is for me a pretty big bug since a guard that returns false breaks alters the current routing history. In the case of our application this breaks the workflow and brings wrong business scopes to a user.
Please tell us about your environment:
Windows 10, NPM, Nodejs, Visual Studio 2015 (using nodejs for typescript compilation)
Angular version: 2.3.3
Browser: [ all ]
Language: [TypeScript 2.0.10 | ES5]
The text was updated successfully, but these errors were encountered: