René's URL Explorer Experiment


Title: Deactivation Guard breaks the routing history · Issue #13586 · angular/angular · GitHub

Open Graph Title: Deactivation Guard breaks the routing history · Issue #13586 · angular/angular

X Title: Deactivation Guard breaks the routing history · Issue #13586 · angular/angular

Description: I'm submitting a ... (check one with "x") [X ] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/a...

Open Graph Description: I'm submitting a ... (check one with "x") [X ] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support reques...

X Description: I'm submitting a ... (check one with "x") [X ] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not s...

Opengraph URL: https://github.com/angular/angular/issues/13586

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Deactivation Guard breaks the routing history","articleBody":"**I'm submitting a ...**  (check one with \"x\")\n```\n[X ] bug report => search github for a similar issue or PR before submitting\n[ ] feature request\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\n```\n\n**Current behavior**\nCurrently, I have a deactivation guard on a route which will return false or true depending on a condition.  To get to this guarded route, the user must pass though 3 navigation step.  Now, once on the guarded route, when using `location.back()`, the guard is called. If it returns `true`, the previous route is loaded. If the guard returns false, the navigation is cancelled.  But if we redo a Location.back() after a failed navigation, the previous route that will be loaded will be 2 steps in the history instead of 1 (user perception).\n\nWorkflow\n```\nMain    -- navigate to     --> Route 1\nRoute 1 -- navigate to     --> Route 2\nRoute 2 -- navigate to     --> Route 3\nRoute 3 -- location.back() --> guard returns true  --> Route 2\nRoute 2 -- navigate to     --> Route 3\nRoute 3 -- location.back() --> guard returns false --> Route 3\nRoute 3 -- location.back() --> guard returns true  --> Route 1  (should be Route 2)\n```\n\n**Expected behavior**\nAn expected behavior for a user would be that navigating back brings back to the previous routed page.\nWorkflow\n```\nMain    -- navigate to     --> Route 1\nRoute 1 -- navigate to     --> Route 2\nRoute 2 -- navigate to     --> Route 3\nRoute 3 -- location.back() --> guard returns true  --> Route 2\nRoute 2 -- navigate to     --> Route 3\nRoute 3 -- location.back() --> guard returns false --> Route 3\nRoute 3 -- location.back() --> guard returns true  --> Route 2  (expected)\n```\n\n**Minimal reproduction of the problem with instructions**\n[Plnkr](https://embed.plnkr.co/k1iX7PzmOre7P6ACtcur/)\n1. Click button Nav to route1\n2. Click button Nav to route2\n3. Click button Nav to route3\n4. Click button Block Nav Back\n5. Click button Nav back\n   - BOGUE: The location.back() routed on Route1 instead of Route2\n\n**Personnal investigation**\nAfter some investigation, I saw that in `routerState$.then` ([router.ts line 752](https://sourcegraph.com/github.com/angular/angular@b5c4bf1c59c56d48b8a536aa61c7bd72d94c99fc/-/blob/modules/@angular/router/src/router.ts#L756))  this logic used when `navigationIsSuccessful == false` is pretty simply but it is the actual cause of this bug.  Basically, when a deactivation guard is hit, the location of the browser is already changed to the previous route.  Which means that when the guard returns false, the `routerState$` runs his logic and calls `resetUrlToCurrentUrlTree()`.  At this point we can see that we replace the state of the current location.  But by doing this, we loose that route in the history which means that in my plunker, if we click the block nav back 3 times and then click the nav back we will actually kill the application.\n\n**What is the motivation / use case for changing the behavior?**\nThis is for me a pretty big bug since a guard that returns false breaks alters the current routing history.  In the case of our application this breaks the workflow and brings wrong business scopes to a user.\n\n**Please tell us about your environment:**\n\u003c!-- Operating system, IDE, package manager, HTTP server, ... -->\nWindows 10, NPM, Nodejs, Visual Studio 2015  (using nodejs for typescript compilation)\n\n* **Angular version:** 2.3.3\n\n* **Browser:** [ all ]\n \n* **Language:** [TypeScript 2.0.10 | ES5]","author":{"url":"https://github.com/patrickracicot","@type":"Person","name":"patrickracicot"},"datePublished":"2016-12-20T15:35:30Z","url":"https://github.com/angular/angular/issues/13586"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:49c73f74-088a-1db3-0437-5b36a3e069de
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB8B2:23CF06:BEA2D3:F68AA3:6B00EC7D
html-safe-noncebc144908b7b25c7bb1d33a591e4947444513c1ffd280c41e71a191930d92d94f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEIyOjIzQ0YwNjpCRUEyRDM6RjY4QUEzOjZCMDBFQzdEIiwidmlzaXRvcl9pZCI6IjU5MTA0NDEwOTQ5NjA3MDQ2MzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2381c5ae0a76bc65e94b68287e7cc4731da2dfbb3f21224e697d5c6614874c2f
hovercard-subject-tagissue:196702796
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/13586/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6c44a65212bbf9928a2debe3aea2277137e5c1cf905a385cfb16ddc770dfa0d9/angular/angular/issues/13586
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6c44a65212bbf9928a2debe3aea2277137e5c1cf905a385cfb16ddc770dfa0d9/angular/angular/issues/13586
og:image:altI'm submitting a ... (check one with "x") [X ] bug report => search github for a similar issue or PR before submitting [ ] feature request [ ] support request => Please do not submit support reques...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepatrickracicot
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/13586#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F13586
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F13586
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/13586
Reloadhttps://github.com/angular/angular/issues/13586
Reloadhttps://github.com/angular/angular/issues/13586
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests140 (140)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/13586
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/13586
Deactivation Guard breaks the routing historyhttps://github.com/angular/angular/issues/13586#top
https://github.com/atscott
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P3%22
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
router: guards/resolvershttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22router%3A%20guards%2Fresolvers%22
state: Needs Designhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20Needs%20Design%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/patrickracicot
patrickracicothttps://github.com/patrickracicot
on Dec 20, 2016https://github.com/angular/angular/issues/13586#issue-196702796
Plnkrhttps://embed.plnkr.co/k1iX7PzmOre7P6ACtcur/
router.ts line 752https://sourcegraph.com/github.com/angular/angular@b5c4bf1c59c56d48b8a536aa61c7bd72d94c99fc/-/blob/modules/@angular/router/src/router.ts#L756
Nexthttps://github.com/angular/angular/issues/13586?timeline_page=1
vicbhttps://github.com/vicb
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
freq1: lowhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
severity3: brokenhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22severity3%3A%20broken%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
on Dec 20, 2016https://github.com/angular/angular/issues/13586#event-900720712
https://github.com/saverett
saveretthttps://github.com/saverett
on Jan 13, 2017https://github.com/angular/angular/issues/13586#issuecomment-272568941
https://github.com/DzmitryShylovich
DzmitryShylovichhttps://github.com/DzmitryShylovich
on Jan 13, 2017https://github.com/angular/angular/issues/13586#issuecomment-272569190
https://github.com/michelherv
michelhervhttps://github.com/michelherv
on Feb 22, 2017https://github.com/angular/angular/issues/13586#issuecomment-281601603
https://github.com/DzmitryShylovich
DzmitryShylovichhttps://github.com/DzmitryShylovich
on Feb 22, 2017https://github.com/angular/angular/issues/13586#issuecomment-281605135
@michelhervhttps://github.com/michelherv
https://github.com/michelherv
michelhervhttps://github.com/michelherv
on Feb 22, 2017https://github.com/angular/angular/issues/13586#issuecomment-281696944
@DzmitryShylovichhttps://github.com/DzmitryShylovich
#14645https://github.com/angular/angular/issues/14645
https://github.com/szh
szhhttps://github.com/szh
on Mar 30, 2017https://github.com/angular/angular/issues/13586#issuecomment-290550529
https://github.com/DzmitryShylovich
DzmitryShylovichhttps://github.com/DzmitryShylovich
on Mar 30, 2017https://github.com/angular/angular/issues/13586#issuecomment-290551064
@szhhttps://github.com/szh
#13922https://github.com/angular/angular/pull/13922
https://github.com/CRodriguez25
CRodriguez25https://github.com/CRodriguez25
on May 16, 2017https://github.com/angular/angular/issues/13586#issuecomment-301637811
https://github.com/arutnik
arutnikhttps://github.com/arutnik
on May 24, 2017https://github.com/angular/angular/issues/13586#issuecomment-303778381
https://github.com/skaiser
skaiserhttps://github.com/skaiser
on May 26, 2017https://github.com/angular/angular/issues/13586#issuecomment-304381246
https://github.com/CRodriguez25
CRodriguez25https://github.com/CRodriguez25
on May 26, 2017https://github.com/angular/angular/issues/13586#issuecomment-304382566
alxhubhttps://github.com/alxhub
on Jun 10, 2021https://github.com/angular/angular/issues/13586#event-4874323539
refactor(router): compute correct history restoration when navigation…https://github.com/angular/angular/commit/013d1cb01066de522c64447986ddea03fa0453eb
013d1cbhttps://github.com/angular/angular/commit/013d1cb01066de522c64447986ddea03fa0453eb
https://github.com/atscott
atscotthttps://github.com/atscott
on Jul 1, 2021https://github.com/angular/angular/issues/13586#issuecomment-872592435
refactor(router): compute correct history restoration when navigation is cancelled #38884https://github.com/angular/angular/pull/38884
refactor(router): compute correct history restoration when navigation is cancelled #38884 (comment)https://github.com/angular/angular/pull/38884#issuecomment-863767152
https://github.com/atscott
atscotthttps://github.com/atscott
on Jul 16, 2021https://github.com/angular/angular/issues/13586#issuecomment-881627456
https://github.com/mduft
mdufthttps://github.com/mduft
on Jul 19, 2021https://github.com/angular/angular/issues/13586#issuecomment-882256700
https://github.com/andrew-landsverk-win
andrew-landsverk-winhttps://github.com/andrew-landsverk-win
on Aug 13, 2021https://github.com/angular/angular/issues/13586#issuecomment-898704702
https://github.com/liamdebeasi
liamdebeasihttps://github.com/liamdebeasi
on Aug 17, 2021https://github.com/angular/angular/issues/13586#issuecomment-900521178
#13586 (comment)https://github.com/angular/angular/issues/13586#issuecomment-872592435
#43181https://github.com/angular/angular/issues/43181
https://github.com/jcn-ithaca
jcn-ithacahttps://github.com/jcn-ithaca
on Aug 18, 2021https://github.com/angular/angular/issues/13586#issuecomment-901243425
atscotthttps://github.com/atscott
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
3c6b653https://github.com/angular/angular/commit/3c6b653089837459809a370ebcaf8911c3bab9ed
on Sep 2, 2021https://github.com/angular/angular/issues/13586#event-5249108223
mdufthttps://github.com/mduft
on Sep 21, 2021https://github.com/angular/angular/issues/13586#event-5335011763
Preview version of navigation fix activated.https://github.com/bdeployteam/bdeploy/commit/b7bc13d8f86282403c7e678d86444373c17bebb7
b7bc13dhttps://github.com/bdeployteam/bdeploy/commit/b7bc13d8f86282403c7e678d86444373c17bebb7
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Oct 3, 2021https://github.com/angular/angular/issues/13586#issuecomment-932979880
automatic conversation locking policyhttps://github.com/angular/angular/blob/8f24bc9443b3872fe095d9f7f77b308a361a13b4/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Oct 3, 2021https://github.com/angular/angular/issues/13586#event-5400010054
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/13586
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/13586
atscotthttps://github.com/atscott
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P3%22
area: routerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20router%22
freq3: highhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq3%3A%20high%22
router: guards/resolvershttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22router%3A%20guards%2Fresolvers%22
state: Needs Designhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20Needs%20Design%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.