Skip to content
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

fix: Cannot reattach ActivatedRouteSnapshot created from a different … #2279

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

edusperoni
Copy link
Collaborator

…route

PR Checklist

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)

@cla-bot cla-bot bot added the cla: yes label Oct 19, 2020
@edusperoni
Copy link
Collaborator Author

Please don't merge this yet, as it seems it might not fully solve the issue

@NathanaelA NathanaelA marked this pull request as draft October 20, 2020 02:12
@jcarolus
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot reattach ActivatedRouteSnapshot created from a different route
2 participants