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
Navigate to home after login does not work with Angular 11 #576
Comments
I've just run into this issue as well. Forgive me if I'm wrong, but the change documented on https://update.angular.io/?l=3&v=10.0-11.0 seems to suggest that we should be able to solve this problem by changing shouldReuseRoute to: public shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
return future.routeConfig === curr.routeConfig || curr.data.reuse;
} Notice that Quote for reference:
|
This does not work, because the arguments are not always swapped, but only for child routes. public shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
return future.routeConfig === curr.routeConfig || (curr.url.length > 0 ? curr.data.reuse : future.data.reuse);
} But this looks like a hack, there should be a better way. |
@csname1910 Yes, you're right. I've worked with your fix and it seems to break for me in cases where we navigate from a child route with a reusable component (i.e. shell) to a route with non-reused components (e.g. from home to login). For now I've simplified to the following, which fixes navigation but likely breaks component reuse: return future.routeConfig === curr.routeConfig; |
Yes, this breaks component reuse, so the ShellComponent is always recreated. This is bad, because if you use a MatSidenav in ShellComponent it is always closed if you switch to another route. I could not reproduce your problem with navigating from home to login with my fix. |
For reference, this is the original issue: angular/angular#18374 @csname1910 Does atscott's solution work for you? https://stackblitz.com/edit/angular-ivy-ksf9cm // Reuse the route if the RouteConfig is the same, or if both routes use the
// same component, because the latter can have different RouteConfigs.
return future.routeConfig === curr.routeConfig ||
(!!future.routeConfig?.component &&
future.routeConfig?.component === curr.routeConfig?.component); |
@athisun This does work for me, thank you! |
# [9.2.0](9.1.0...9.2.0) (2021-01-14) ### Bug Fixes * app not loading with Electron v11 ([1444bf0](1444bf0)) * incorrect hads version ([ba20ff1](ba20ff1)) * rename env script to fix execution in some environments (closes [#575](#575)) ([ec93fdb](ec93fdb)) * update electron templates ([3433465](3433465)) * update generator dependencies ([bda29d9](bda29d9)) * update jest config ([4b4a357](4b4a357)) * update packages and fix peer dependencies ([64098dc](64098dc)) * update RouteReusableStrategy for Angular 11 ([#576](#576)) ([3077f5b](3077f5b)) ### Features * add brazilian portuguese language ([1a6d728](1a6d728)) * enable webpack 5 ([8592a71](8592a71)) * migrate to @ngneat/until-destroy (fix [#577](#577)) ([3a77fcb](3a77fcb)) * update editorconfig (fixes [#580](#580)) ([9f036b3](9f036b3))
I'm submitting a...
Current behavior
After upgrade to Angular 11 the login button does not work anymore.
URL in Chrome is updated to 'home', but it stays on the login screen.
You have to hit F5 for refresh to get to the home screen.
Expected behavior
After pressing login button the home screen should appear.
Minimal reproduction of the problem with instructions
ngx new
ng update @angular/cli @angular/core
npm start
The problem seems to be a change in shouldReuseRoute, see here:
https://update.angular.io/?l=3&v=10.0-11.0
The bug can be fixed by changing shouldReuseRoute to:
But this is probably not a good way to fix it.
Environment
Others:
The text was updated successfully, but these errors were encountered: