Skip to content

Cancel navigateBack from canDeactivate #528

@TonyLugg

Description

@TonyLugg

I'm submitting a bug report

  • Library Version:
    aurelia-router: 1.3.0

  • Operating System:
    Windows 10

  • Node Version:
    6.11.3

  • NPM Version:
    5.3.0

  • JSPM OR Webpack AND Version
    Webpack 3.5.5 (using CLI)

  • Browser:
    all

  • Language:
    TypeScript 2.5.2

Current behavior:
I load the app, which loads "home" route/view. Press a button and use router.navigate("second") to go to second page. Enter some data and press back button (on page) which executes router.navigateBack(). Because data has changed, display a message box (Aurelia dialog) from canDeactivate() to ask for user confirmation (same behavior with window.confirm()), and return false from canDeactivate(). Navigation stops. Repeat from pressing back button (on page), backward navigation continues and navigates right out of the app as if it has navigated back twice.

https://gist.github.com/TonyLugg/f4a7fa39c9d82f5de0af3b0bc8e01850

Expected/desired behavior:
Each time false is returned from canDeactivate, navigateBack() should be stopped.

If I press a different button and perform navigate("someOtherRoute") and return false from canDeactivate it works correctly with multiple navigation attempts.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions