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

When navigating by UPDATE_LOCATION guards are ignored #99

Open
3 of 9 tasks
Swabo opened this issue Jul 15, 2019 · 1 comment
Open
3 of 9 tasks

When navigating by UPDATE_LOCATION guards are ignored #99

Swabo opened this issue Jul 15, 2019 · 1 comment

Comments

@Swabo
Copy link

Swabo commented Jul 15, 2019

This is a...

  • feature request
  • bug report
  • usage question

What toolchain are you using for transpilation/bundling?

  • @angular/cli
  • Custom @ngTools/webpack
  • Raw ngc
  • SystemJS
  • Rollup
  • Other

Environment

NodeJS Version: 10.16.0
Typescript Version: 3.2.4
Angular Version: 7.2.1
@angular-redux/store version: 10.0.0
@angular/cli version: (if applicable): 7.2.2
OS: Win 10 x64

Link to repo showing the issus

example-app

Expected Behaviour:

When I navigate by dispatching the UPDATE_LOCATION - Action the router-State should only change if the navigation succeeds. If the navigation is canceled, e.g. by a guard, the current router-State should not update to the intented target location.

Actual Behaviour:

When I navigate by dispatching the UPDATE_LOCATION - Action the router-State is updated to the target location, whether the target is reached or not. This leads to an inconsistent state.

Stack Trace/Error Message:

Additional Notes:

The behaviour can be easily reproduced in the example-app:

  1. Create an Action that navigates the user to /lions:
  @dispatch()
  goToLions() {
    return {
      type: UPDATE_LOCATION,
      payload: '/lions'
    }
  }
  1. Protect the lions-Route with a guard:
{ path: 'lions', component: LionPageComponent, canActivate: [LionsGuard] },

...

export class LionsGuard implements CanActivate {

  canActivate(): any {

    console.warn('hit guard');
    return false;
  }

}
  1. Running goToLions() will update the router-State to /lions, even if the guard keeps me on /elephants

I navigate a lot by returning the UPDATE_LOCATION Action in Epics. Any ideas how to fix or workaround this behaviour?

@Swabo
Copy link
Author

Swabo commented Jul 23, 2019

any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant