Skip to content
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

ActivatedRoute is wrong after rejecting a CanDeactivate #12776

Closed
pieterhendrickx opened this issue Nov 9, 2016 · 3 comments
Closed

ActivatedRoute is wrong after rejecting a CanDeactivate #12776

pieterhendrickx opened this issue Nov 9, 2016 · 3 comments

Comments

@pieterhendrickx
Copy link

pieterhendrickx commented Nov 9, 2016

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/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
Given a navigation using 'router.navigate(...)' from an activated route for which a CanDeactivate routeguard is defined.

And when the CanDeactivate guard returns a Promise which is resolved with false (i.e. the route can not be deactivated)

Then the ActivatedRoute.firstChild injectable of the parent route points to the route that was navigated to, rather than the route that could not be deactivated.

Expected behavior
It would be better to only update the ActivatedRoute when the current route can be deactivated, and remain to be the current route if any CanDeactivate route guards fail.

Minimal reproduction of the problem with instructions
http://plnkr.co/edit/pLf5VTvq3Lh0H2N5g1Tl?p=preview

  • Component2 cannot deactivate due to a routeGuard
  • Click button twice... and look at the difference between the activatedRoute.firstChild of the main component and the activatedRoute of the childComponent

What is the motivation / use case for changing the behavior?
I feel the current value of the ActivatedRoute can not be

Please tell us about your environment:
MacOS, Webstorm, webpack,...

  • Angular version: 2.0.X
    Angular 2.1.1
    Router 3.1.2

  • Browser:
    all

  • Language:
    all

  • Node (for AoT issues): node --version = v6.2.1

@DzmitryShylovich
Copy link
Contributor

Pls add a repro in plunkr.

@pieterhendrickx
Copy link
Author

link added in original post

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants