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(router): fix navigation ignoring logic to compare to the browser url #37716

Closed
wants to merge 1 commit into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Jun 24, 2020

This PR changes the logic for determining when to skip route processing from
using the URL of the last attempted navigation to the actual resulting URL after
that transition.

Because guards may prevent navigation and reset the browser URL, the raw
URL of the previous transition may not match the actual URL of the
browser at the end of the navigation process. For that reason, we need to use
urlAfterRedirects if the previous navigation failed.

Note that this is a resubmit of d3a8175 which caused a failure in Google. I've verified that this change does not result in the same failure but this PR should still be merged and synced separately.

@atscott atscott added area: router target: major This PR is targeted for the next major release risk: high router: guards/resolvers router: navigation pipe events/scheduleNavigation/transitions observable labels Jun 24, 2020
@ngbot ngbot bot modified the milestone: needsTriage Jun 24, 2020
@atscott atscott force-pushed the imperativenavtest-resubmit branch from a72e895 to 2368c37 Compare June 24, 2020 21:54
@atscott atscott marked this pull request as ready for review June 29, 2020 18:27
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.

Thanks for the fix @atscott, I've left a few minor comments. Please have a look when you get a chance.

packages/router/src/router.ts Outdated Show resolved Hide resolved
packages/router/src/router.ts Outdated Show resolved Hide resolved
packages/router/src/router.ts Show resolved Hide resolved
packages/router/src/router.ts Outdated Show resolved Hide resolved
packages/router/test/integration.spec.ts Show resolved Hide resolved
@atscott atscott force-pushed the imperativenavtest-resubmit branch from 2368c37 to e0dfb84 Compare June 30, 2020 17:02
This PR changes the logic for determining when to skip route processing from
using the URL of the last attempted navigation to the actual resulting URL after
that transition.

Because guards may prevent navigation and reset the browser URL, the raw
URL of the previous transition may not match the actual URL of the
browser at the end of the navigation process. For that reason, we need to use
`urlAfterRedirects` instead.

Other notes:
These checks in scheduleNavigation were added in angular@eb2ceff
The test still passes and, more surprisingly, passes if the checks are removed
completely. There have likely been changes to the navigation handling that
handle the test in a different way. That said, it still appears to be important
to keep the checks there in some capacity because it does affect how many
navigation events occur. This addresses an issue that came up in angular#16710: angular#16710 (comment)
This also partially addresses angular#13586 in fixing history for imperative
navigations that are cancelled by guards.
@atscott atscott force-pushed the imperativenavtest-resubmit branch from e0dfb84 to 2d4d32d Compare June 30, 2020 17:04
@atscott
Copy link
Contributor Author

atscott commented Jun 30, 2020

@AndrewKushnir - Thanks for the review! I've addressed your comments - PTAL.

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.

LGTM 👍 Thanks @atscott.

@atscott
Copy link
Contributor Author

atscott commented Jul 1, 2020

[global presubmit(https://test.corp.google.com/ui#id=OCL:318866503:BASE:319047837:1593570501085:2a82c23f) showing no failures.

caretaker note: please merge and sync this one separately - it's a resubmit (with a fix) of a previous commit that caused a failure in g3 and had to be rolled back.

@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Jul 1, 2020
@alxhub alxhub closed this in a5ffca0 Jul 6, 2020
@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 Aug 6, 2020
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…url (angular#37716)

This PR changes the logic for determining when to skip route processing from
using the URL of the last attempted navigation to the actual resulting URL after
that transition.

Because guards may prevent navigation and reset the browser URL, the raw
URL of the previous transition may not match the actual URL of the
browser at the end of the navigation process. For that reason, we need to use
`urlAfterRedirects` instead.

Other notes:
These checks in scheduleNavigation were added in angular@eb2ceff
The test still passes and, more surprisingly, passes if the checks are removed
completely. There have likely been changes to the navigation handling that
handle the test in a different way. That said, it still appears to be important
to keep the checks there in some capacity because it does affect how many
navigation events occur. This addresses an issue that came up in angular#16710: angular#16710 (comment)
This also partially addresses angular#13586 in fixing history for imperative
navigations that are cancelled by guards.

PR Close angular#37716
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 risk: high router: guards/resolvers router: navigation pipe events/scheduleNavigation/transitions observable target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NavigationStart event doesn't fire when browser back/forward button is used
3 participants