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

Returning False from canDeactivate() causes history to be incorrect. #809

Closed
thughes88 opened this issue Jul 26, 2017 · 6 comments
Closed

Comments

@thughes88
Copy link

I'm submitting a bug report

  • Library Version:
    2.1.1

Please tell us about your environment:

  • Operating System:
    Windows 10

  • Node Version:
    4.5.0

  • NPM Version:
    3.10.8
  • Aurelia CLI OR JSPM OR Webpack AND Version
    CLI 0.30.1
  • Browser:
    Chrome 59, Edge

  • Language:
    TypeScript 2.3.0

Current behavior:
Create 5 pages (a, b, c, d). Navigate from a => b => c => d. Page d has a canDeactivate() hook and a boolean to mark as dirty and a back button that calls router.navigateBack(). Then do the following.

  1. Put page d into a dirty state.
  2. Click the back button 3 times. Each time the canDeactivate() returns false and the url remains on page d.
  3. Now clear the dirty state. and click Back button.
  4. User is sent to page a.

Expected/desired behavior:
I would expect the user to be navigated to page c. If the user clicks the back button on page d (when in a dirty state) 5 times, the user is taken to the first page, even thought it was still in a dirty state and should be caught by canDeactivate() and remain on page d.

It appears that even though canDeactivate() returns false, it is doing something to the history that removes the previous route each time, removing the valid history routes. I have attached a sample to show behavior
routes.zip

  • What is the motivation / use case for changing the behavior?
@Krossmaskinen
Copy link

Is this related to #731 maybe?

@thughes88
Copy link
Author

thughes88 commented Aug 11, 2017 via email

@Honorato
Copy link

Honorato commented Sep 1, 2017

Same behavior is happening with me.

@agouveiac
Copy link

I am experiencing the same behavior.

@gama410
Copy link

gama410 commented Jan 5, 2018

I have the same problem too.
It seems like a duplicate of aurelia/router#528 which has been assigned to @davismj

@davismj
Copy link
Member

davismj commented Jan 11, 2018

@EisenbergEffect can be closed as dupe

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

No branches or pull requests

7 participants