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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular 7 Router Bug - skipLocationChange still shows url in browser #29871
Comments
Thanks for the issue. I understand what you're saying on the discussion, but a reproduction would also help quite a bit. It's hard to test what you're saying without having a reproduction, or see if it's due to something in your code or in the Angular code. I think requiring the |
@tgfactor any luck coming up with a repro ? |
this can be reproducible if you navigate to the same route with router.navigate() function. |
Here is the code if you would like |
Thanks for reporting this issue. However, you didn't provide sufficient information for us to understand and reproduce the problem. Like Jason, I understand the description of the issue but was unable to reproduce the problem in a new CLI project. Please check out our submission guidelines to understand why we can't act on issues that are lacking important information. If the problem still exists in your application, please open a new issue and follow the instructions in the issue template, including a reproduction in either stackblitz or a github project. |
I have the same issue, but it works if my authguard returns true after the navigate call, even if the user is not authenticated. Here is your code with the return true. (I also need the setTimeout call).
|
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. |
馃悶 bug report
Affected Package
@angular-router
Is this a regression?
No
Description
I have a requirement for my angular application that the url address bar at the top of my browser cannot be updated with any path change. So far, I have been successful by adding the "skipLocationChange: true" navigationExtra to all my navigate calls, but when I use the router.navigate or router.navigateByUrl calls in interceptors and (more problematically) guards, the url address bar changes to the path I was originally going to before I was redirected.
One temporary solution I came up with for the interceptors was placing the navigate call inside a setTimeout(). I don't know if that is the correct way of handling interceptor redirection, but it stopped posting the previous path in the browser address bar. However, when I use canActivate guards that redirect for invalid access, it always produces the path prior to redirection in the browser address bar, with or without the setTimeout. This has been an issue for 7.2 in general since I started the project.
馃敩 Minimal Reproduction
Easier to discuss rather than produce on stackblitz.
Application moves to a new screen:
Application navigates to the screen component, which then makes an API call:
Unbeknownst to the application, the authentication token for the user has expired. So when the call gets made through my token interceptor, an HttpErrorResponse object gets sent back to the application, and gets caught in the catchError section of my interceptor.
If I do not have this setTimeout call here, the browser address bar changes to localhost:4200/newscreen/screen_2, when it should actually stay at localhost:4200 only.
In addition, I tried using a canActivate AuthGuard for accessing a component. In the code, right after my authentication expired, I clicked a button that would send me to root of the application.
In my routing, I have the '' path redirecting to my HomeComponent, which has the canActivate AuthGuard, containing the following code:
The guard catches the lost authentication, and redirects the user to the not-authenticated page. However, in the browser address bar, if '/newscreen/screen_3' was my last path/page I was on, it would NOT be localhost:4200; it would be localhost:4200/newscreen/screen_3.
This happens everytime I use guards or resolves, and I don't know if this is the normal use of angular routing, or if this is a bug that needs to be fixed.
馃敟 Exception or Error
馃實 Your Environment
Angular Version:
Anything else relevant?
The text was updated successfully, but these errors were encountered: