nativescript-angular
nativescript-angular copied to clipboard
fix: Cannot reattach ActivatedRouteSnapshot created from a different …
…route
PR Checklist
- [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
- [x] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
- [x] You have signed the CLA.
- [ ] All existing tests are passing: https://github.com/NativeScript/nativescript-angular/blob/master/DevelopmentWorkflow.md#running-the-tests
- [ ] Tests for the changes are included.
What is the current behavior?
Navigating between sibling routes may sometimes mess with the cache due to it using the key of a parent route, instead of the complete route.
What is the new behavior?
This now uses the correct key from the farthest children of the route
PARTIALLY Fixes #1993. (this issue has 2 problems on it: 1 is the one fixed in this PR, the other is that route guard/resolvers don't work on back navigation and may break navigation for a PRO)
Please don't merge this yet, as it seems it might not fully solve the issue
@edusperoni @NathanaelA
When debugging this issue in the use case Root => A => B, then back to A it looks like all keys to store/retrieve are generated correctly (also without this fix), but the error is still thrown.
The expression that causes the error to be thrown (curr.value.routeConfig !== result.value.routeConfig in https://github.com/angular/angular/blob/3817e5f1dfeb9de26fa2ea4068a37565f435214f/packages/router/src/create_router_state.ts#L52) will actually show equal properties and values when inspecting, but are not the same object reference. This only occurs with lazy loaded modules (if changed to "regular" route configs it works).
Perhaps the solution direction for this part of the issue is to either use a "deepEqual" instead of reference equality or to somehow make sure that the routeConfig reference stays the same for lazy loaded modules.
Hope this helps, cheers.