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(router): Only retrieve stored route when reuse strategy indicates it should reattach #30263
Conversation
This comment has been minimized.
This comment has been minimized.
ae081b9
to
0641592
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the commit message to describe what prompted this change. It doesn't appear to be just a "refactor" as it would change whether retrieve
were called. Also, would this resolve #23162? If so, can you please add that as a note in the commit message as well?
0641592
to
f0c7f7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving but since I went ahead and applied fixes to this PR it should be reviewed by someone else as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good. I'm wondering if it's possible (and worthwhile) to add a test that would reproduce the original problem? It looks like the tests were updated to reflect the new behavior, should we also check that the retrieve
function is never called in these scenarios?
… it should reattach When creating the router state, the `RouteReuseStrategy#retrieve` should only be called when `RouteReuseStrategy#shouldAttach` returns `true`. That is, we should only retrieve a stored route when the reuse strategy indicates that there is one stored and that it should be reattached. This now matches the behavior in the route activation: https://github.com/angular/angular/blob/1d12c50f63f90c91636185b2287e31e9c0291121/packages/router/src/operators/activate_routes.ts#L170-L172 Fixes angular#23162
f0c7f7b
to
df2efd2
Compare
@AndrewKushnir -- Oops! I had done that but didn't add it to the commit. PTAL |
Regarding #23162 It seems like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atscott LGTM 👍
@StevenLiekens it may be possible but I'm wondering why it would be necessary. Shouldn't the |
Yep, that's why I'm thinking the method shouldn't even be tested (you already know the answer). But it would only be a minor optimization so leaving it as-is seems completely reasonable. |
global presubmit edit: full global presubmit (green) |
caretaker note: please merge and sync this one on its own. Global presubmit is green but it would still be good to do since this is a router change. |
… it should reattach (#30263) When creating the router state, the `RouteReuseStrategy#retrieve` should only be called when `RouteReuseStrategy#shouldAttach` returns `true`. That is, we should only retrieve a stored route when the reuse strategy indicates that there is one stored and that it should be reattached. This now matches the behavior in the route activation: https://github.com/angular/angular/blob/1d12c50f63f90c91636185b2287e31e9c0291121/packages/router/src/operators/activate_routes.ts#L170-L172 Fixes #23162 PR Close #30263
… it should reattach (#30263) When creating the router state, the `RouteReuseStrategy#retrieve` should only be called when `RouteReuseStrategy#shouldAttach` returns `true`. That is, we should only retrieve a stored route when the reuse strategy indicates that there is one stored and that it should be reattached. This now matches the behavior in the route activation: https://github.com/angular/angular/blob/1d12c50f63f90c91636185b2287e31e9c0291121/packages/router/src/operators/activate_routes.ts#L170-L172 Fixes #23162 PR Close #30263
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When creating the router state, the
RouteReuseStrategy#retrieve
shouldonly be called when
RouteReuseStrategy#shouldAttach
returnstrue
.That is, we should only retrieve a stored route when the reuse strategy
indicates that there is one stored and that it should be reattached.
This now matches the behavior in the route activation:
angular/packages/router/src/operators/activate_routes.ts
Lines 170 to 172 in 1d12c50
Fixes #23162