Title: bug: canActivate does not cancel navigation when using browser back button · Issue #43181 · angular/angular · GitHub
Open Graph Title: bug: canActivate does not cancel navigation when using browser back button · Issue #43181 · angular/angular
X Title: bug: canActivate does not cancel navigation when using browser back button · Issue #43181 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description When using the browser back button to go back to a page with a canActivate guard, navigation is not correctly prevented if the guard retur...
Open Graph Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description When using the browser back button to go back to a page with a canActivate guard, navigation is no...
X Description: Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description When using the browser back button to go back to a page with a canActivate guard, navigation is no...
Opengraph URL: https://github.com/angular/angular/issues/43181
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: canActivate does not cancel navigation when using browser back button","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nrouter\n\n### Is this a regression?\n\nNo\n\n### Description\n\nWhen using the browser back button to go back to a page with a `canActivate` guard, navigation is not correctly prevented if the guard returns `false` and the back button is pressed multiple times.\r\n\r\nSteps to reproduce:\r\n\r\n1. Clone attached reproduction, run `npm install`, and then run `npm run start`.\r\n2. In the browser, you should start on `/page1`.\r\n3. Click \"Go to Page 2\". Observe you are on `/page2`.\r\n4. Click \"Go to Page 3\". Observe you are on `/page3`.\r\n5. Click \"Disable going back to page 2\". This will set a flag that causes the `canActivate` guard on `/page2` to return `false`.\r\n6. Click the browser back button. Observe that the `canActivate` guard returns `false` and navigation is correctly cancelled. You should remain on `/page3`.\r\n7. Click the browser back button again. Observe that the `canActivate` guard is not called and navigation is not cancelled. You should now be on `/page1`.\n\n### Please provide a link to a minimal reproduction of the bug\n\nhttps://github.com/liamdebeasi/ng-guard-repro\n\n### Please provide the exception or error you saw\n\n```true\nI would expect that pressing the browser back button would attempt to navigate back to `/page2`, causing the `canActivate` guard to return `false` again.\n```\n\n\n### Please provide the environment you discovered this bug in\n\n```true\nAngular CLI: 12.2.1\r\nNode: 15.9.0 (Unsupported)\r\nPackage Manager: npm 7.5.3\r\nOS: darwin x64\r\n\r\nAngular: 12.2.1\r\n... cli, common, compiler, compiler-cli, core, forms\r\n... language-service, platform-browser, platform-browser-dynamic\r\n... router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1202.1\r\n@angular-devkit/build-angular 12.2.1\r\n@angular-devkit/core 12.2.1\r\n@angular-devkit/schematics 12.2.1\r\n@schematics/angular 12.2.1\r\nrxjs 6.6.7\r\ntypescript 4.2.4\n```\n\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/liamdebeasi","@type":"Person","name":"liamdebeasi"},"datePublished":"2021-08-16T19:23:58Z","url":"https://github.com/angular/angular/issues/43181"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5987cefa-b83f-a68f-507a-9e9b4e230c23 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2FE:DA744:A06C50:D8B415:6B00F004 |
| html-safe-nonce | ddfa8d6ddd924b9e8b4d89d4959f6d98b3874beb0b7f60bf9875954e35d5516e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkZFOkRBNzQ0OkEwNkM1MDpEOEI0MTU6NkIwMEYwMDQiLCJ2aXNpdG9yX2lkIjoiMzcyNTAwMzMzNTMzOTE3MTg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4a8efdbb62c8c17e061f2a92cd3cb8c6d44061856f77ef0b6ffab3d61e2b5133 |
| hovercard-subject-tag | issue:972033537 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/43181/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0481fa080c72c721367daa031ed25def00b10c095afad5cdcf8e02849877fc96/angular/angular/issues/43181 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0481fa080c72c721367daa031ed25def00b10c095afad5cdcf8e02849877fc96/angular/angular/issues/43181 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? router Is this a regression? No Description When using the browser back button to go back to a page with a canActivate guard, navigation is no... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | liamdebeasi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width