Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(router): eagerly update internal state on browser-triggered navigations #43102

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

Closed
wants to merge 2 commits into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Aug 10, 2021

The management of browserUrlTree currently has several problems with
correctly tracking the actual state of the browser.

This change makes the Router eagerly update the browserUrlTree when
handling navigations triggered by browser events (i.e., not 'imperative'). This
is because with those types of navigations, the browser URL bar is
already updated. If we do not update the internal tracking of the
browserUrlTree, we will be out of sync with the real URL if the
navigation is rejected.

It would be best if we could remove browserUrlTree completely, but doing that
would require a lot more investigation and is blocked by #27059 because
the SpyLocation used in tests does not emulate real browser behavior.

fixes #43101

@atscott atscott added area: router target: patch This PR is targeted for the next patch release labels Aug 10, 2021
@ngbot ngbot bot added this to the Backlog milestone Aug 10, 2021
@google-cla google-cla bot added the cla: yes label Aug 10, 2021
…ations

The management of `browserUrlTree` currently has several problems with
correctly tracking the actual state of the browser.

This change makes the Router eagerly update the `browserUrlTree` when
handling navigations triggered by browser events (i.e., not 'imperative'). This
is because with those types of navigations, the browser URL bar is
_already_ updated. If we do not update the internal tracking of the
`browserUrlTree`, we will be out of sync with the real URL if the
navigation is rejected.

It would be best if we could remove `browserUrlTree` completely, but doing that
would require a lot more investigation and is blocked by angular#27059 because
the SpyLocation used in tests does not emulate real browser behavior.

fixes angular#43101
@atscott atscott force-pushed the updatesFromBrowser branch from 35d219e to ff32c85 Compare August 10, 2021 17:22
@atscott
Copy link
Contributor Author

atscott commented Aug 10, 2021

global presubmit started

@atscott
Copy link
Contributor Author

atscott commented Aug 11, 2021

global presubmit with reruns shows no failures due to this change.

@atscott atscott requested a review from AndrewKushnir August 11, 2021 17:37
@atscott atscott marked this pull request as ready for review August 11, 2021 17:37
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

packages/router/src/router.ts Outdated Show resolved Hide resolved
@atscott atscott added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Aug 11, 2021
@atscott
Copy link
Contributor Author

atscott commented Aug 11, 2021

merge assistance: while global presubmit ran and was green, this CL should still be merged and synced on its own to be safe.

@AndrewKushnir AndrewKushnir added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Aug 11, 2021
@AndrewKushnir
Copy link
Contributor

@atscott FYI there are some CI failures which look legit, could you please have a look? (adding the "cleanup" label for now)

@atscott atscott force-pushed the updatesFromBrowser branch from 2356261 to 0aa0e9a Compare August 11, 2021 23:46
@atscott atscott removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Aug 11, 2021
@dylhunn
Copy link
Contributor

dylhunn commented Aug 12, 2021

If this must go in on its own, I will wait until tomorrow and do a second merge and sync.

dylhunn pushed a commit that referenced this pull request Aug 16, 2021
…ations (#43102)

The management of `browserUrlTree` currently has several problems with
correctly tracking the actual state of the browser.

This change makes the Router eagerly update the `browserUrlTree` when
handling navigations triggered by browser events (i.e., not 'imperative'). This
is because with those types of navigations, the browser URL bar is
_already_ updated. If we do not update the internal tracking of the
`browserUrlTree`, we will be out of sync with the real URL if the
navigation is rejected.

It would be best if we could remove `browserUrlTree` completely, but doing that
would require a lot more investigation and is blocked by #27059 because
the SpyLocation used in tests does not emulate real browser behavior.

fixes #43101

PR Close #43102
@dylhunn dylhunn closed this in 286b280 Aug 16, 2021
atscott added a commit to atscott/angular that referenced this pull request Sep 14, 2021
PR angular#43102 broke some use-cases. These tests document expected behavior
and would have prevented angular#43446 and angular#43447. Recent changes have already
addressed these issues, but it would still be a good idea to cover these
use-cases in tests as well.
AndrewKushnir pushed a commit that referenced this pull request Sep 14, 2021
PR #43102 broke some use-cases. These tests document expected behavior
and would have prevented #43446 and #43447. Recent changes have already
addressed these issues, but it would still be a good idea to cover these
use-cases in tests as well.

PR Close #43449
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: router cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Returning UrlTree from CanActivate guard breaks browser's history and leads to an inconsistent state
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.