-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Child Route activate() called before childRouter has refreshed baseUrl #378
Comments
The only way to redirect during a navigation is to return a navigation comment (such as Redirect or RedirectToRouter) from the |
@EisenbergEffect This doesn't seem to be working with child routes. I created a gist: https://gist.run/?id=1bca105623d3c88400738985d008fc2e Have I misunderstood something, or is this a bug in the router? |
Unanswered question. |
I'm thinking this has been fixed by 1432234. Please reoopen if not. |
Looks like I still have the same issue. I seem to have overwritten the GistRun above, but the code from #306 still behaves the same with router 1.5.0. Original gist: https://gist.run/?id=8a73eca78d76065306dd459b64929ceb
The call from activate() will generate the url |
As above, seems this might be a regression, we're getting the same issue again with router 1.5.0 (was fixed previously) |
I'm submitting a bug report
1.0.0-rc1.0.5
Current behavior:
Originally in Gitter chat:
So I have a AppRouter (A) which has a Route (B) which is a ChildRouter under the likes of "/register", I want to dynamically throw the user around different routes in this child router. So I started by creating essentially an index route (C) for ChildRouter (B) (i.e. it handles the "") request. What I would ideally do, is, in the activate() method of the index route (C), return a promise which is a redirect to a different route (D) (which might be like "/step-1", so in sum it should be "/register/step-1"),as a route that belongs to ChildRouter (B). Catch is, if I try to router.navigateToRoute("route-d") sort of thing in the activate method of C, then it trys to redirect to the absolute app root ("/step-1" and not "/register/step-1"). If I call the same navigateToRoute method but later as part of click.delegate() call, it works perfectly. I cannot work out why it doesn't work in the activate method?
We established my approach was largely flawed anyway for the use case, but I can at least answer why I had this issue.
After debugging, I tracked it down to the activate() method of a child VM (C) of the child router (B) is being called before "refreshBaseUrl()" is called. Calling refreshBaseUrl() at the start of generate for example then breaks because the parent (AppRouter) is currently navigating and doesn't have a currentInstruction of it landing on the childRouter.
It might be a bit of a failing of my understanding of the router in that, I would have thought at the point that we were activate()'ing a one of the childRouter's child routes, that the AppRouter would have had a currentInstruction (ie, it landed on the childRouter).
Regardless, the behaviour as described below is not documented anywhere at present.
"During the activation of a VM belonging to a route within a ChildRouter, redirectToRoute on the child router will not generate the correct URL as the AppRouter has not resolved for the currentInstruction"
Happy to discuss further, would love to give an example but a bit time crunched at present but will aim to do so.
The text was updated successfully, but these errors were encountered: