Skip to content

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Jun 30, 2022

When a navigation in the router fails, we reset the internal state and
browser URL to the last successful navigation. For the initial
navigation, this does not exist, so ''/'/' is used. Prior to this
commit, the state reset was not also accompanied by a navigation to the
root of the application. This results in a "blank" screen (or rather, it
only shows content that is outside the router-outlet such as the
static app header).

With this commit, the router initializer, which includes an initialNavigation
call, now tracks whether the initial navigation succeeded (including
redirects). If the navigation did not succeed, a navigation to the root
of the application is triggered ('/'). Again, this is in addition to
what the router already does for this failed navigation: setting its internal
state and browser URL to the root.

Fixes #16211

@ngbot ngbot bot added this to the Backlog milestone Jun 30, 2022
@atscott
Copy link
Contributor Author

atscott commented Jun 30, 2022

TGP

Edit: Just one failure that is a screenshot test showing the new correct behavior. The old screenshot showed just a blank screen (plus the app header) with an error popup.

@atscott atscott added the action: global presubmit The PR is in need of a google3 global presubmit label Jun 30, 2022
@atscott atscott force-pushed the blankscreen branch 3 times, most recently from 43522ab to 94ffa50 Compare June 30, 2022 21:15
@atscott atscott modified the milestones: Backlog, Fixit H1'2022 Jul 1, 2022
@atscott atscott marked this pull request as ready for review July 1, 2022 16:57
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.

@atscott looks great, just a couple comments on potential DX improvement and a corner case when navigation to / also fails.

atscott added 2 commits July 6, 2022 16:53
When a navigation in the router fails, we reset the internal state and
browser URL to the last successful navigation. For the initial
navigation, this does not exist, so `''`/`'/'` is used. Prior to this
commit, the state reset was not also accompanied by a navigation to the
root of the application. This results in a "blank" screen (or rather, it
only shows content that is outside the `router-outlet` such as the
static app header).

With this commit, the router initializer, which includes an `initialNavigation`
call, now tracks whether the initial navigation succeeded (including
redirects). If the navigation did not succeed, a navigation to the root
of the application is triggered (`'/'`). Again, this is in addition to
what the router already does for this failed navigation: setting its internal
state and browser URL to the root.

Fixes angular#16211
@atscott atscott removed the action: global presubmit The PR is in need of a google3 global presubmit label Jul 7, 2022
@jessicajaniuk jessicajaniuk added the action: merge The PR is ready for merge by the caretaker label Jul 11, 2022
@atscott atscott added state: blocked and removed action: merge The PR is ready for merge by the caretaker labels Jul 11, 2022
@atscott atscott marked this pull request as draft December 9, 2022 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

canActivate=>false can result in blank screen/dead link
4 participants