I have a home page and two subpages. I'm guarding user navigating away from subpage1 using Angular guards. I followed the guidelines here, and I added some logic to separately handle clicking on a link and using the browser back button. I reproduced the basic logic on stackblitz.
This specific sequence doesn't work:
- on the home page click on Comp1
- try to navigate away clicking on Home, cancel
- try to navigate away with back button (if in stackblitz editor and not the app, you need to explicitly type history.back() in the console)
You'll see the location bar change, but no confirmation dialog and no actual page change.
It works ok if I use the back button directly, or if at point 2 I try to nav away to Comp2 instead of Home. It looks like the angular routing is recording the attempt to nav to Home even if it gets cancelled, and when the back button is invoked no action takes place because the location url string has not changed. This is invisible to the user because the browser history looks all right.
I'm on Angular 7. Any idea? Is this a bug?