Description
Navigations are initialized by sending a new value into Router.transitions
. In order to do so, we take the new value and merge it with the previous value. However, that previous value will always be the previous value prior to navigations having been run.
The real data we need is the NavigationTransition
that most recently passed to the subscribe
on Router.navigations
. This will contain reference to the recent urlAfterRedirects
and any other data added to the transition through the process of navigating.
Starting with old values can produce incorrect behavior. For instance, a test in Google navigates to a route, then navigates to the same route again, which in the router codebase falls into a path that essentially marks it to do nothing. Upon marking it to do nothing, we attempt to get the state right for the next navigation. However, the value is stale due to the above description.
The next navigation they are performing in the test is hitting back
, which goes to the root. Because they happened to start on root, then navigate twice to the same place, then specifically go back
to the root again, the back
operation does nothing because the router thinks it’s already there.
Activity
jasonaden commentedon May 8, 2019
When fixed, need to un-revert this PR and verify this set of tests pass.
fix(router): ensure navigations start with the current URL value inca…
fix(router): ensure navigations start with the current URL value inca…
fix(router): ensure navigations start with the current URL value inca…
broweratcognitecdotcom commentedon Jul 31, 2019
I see a difference in behavior betwen ng6 and ng8 and I am wondering if it is because of these changes. In ng6, navigating to the same route for the purposes of updating the query params did not trigger NavigationStart and NavigationEnd events. In ng8 it is so that navigating to the same route for the purposes of updating the query params does trigger NavigationStart and NavigationEnd events. Was this behavior change intended?
angular-automatic-lock-bot commentedon Sep 15, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.