router icon indicating copy to clipboard operation
router copied to clipboard

navigateBack or home

Open jonathaneckman opened this issue 7 years ago • 4 comments

I'm submitting a feature request

  • Library Version: 1.2.1

Please tell us about your environment:

  • Operating System: Windows 10

  • Browser: Chrome

  • Language: TypeScript 2.2

Current behavior:

  1. Navigate directly to a route by typing the URL in the address bar.
  2. Click a button on the page that calls router.navigateBack()
  3. The router navigates away from the Aurelia application and to the website they were at previously.

Expected/desired behavior: Do not leave the page. If the route we are going back to is not within the application, navigate back to the default route. Perhaps something like router.navigateBackOrHome(). Alternatively, provide a lifecycle hook where I can handle this myself. Custom navigation steps are not touched in this scenario.

jonathaneckman avatar Dec 28 '17 21:12 jonathaneckman

@jonathaneckman Ready for your next submission? :smile:

davismj avatar Jan 15 '18 07:01 davismj

Haha yes I am! Good thing I have an excellent blog post to guide me.

I'd be happy to put my name on this once I understand a little more about the solution. I'd need to read the router code to understand the effort required, if the change is a good design, if it causes a breaking change, etc. Other priorities have filled my after hours time in January, so I cant commit to anything yet.

jonathaneckman avatar Jan 15 '18 22:01 jonathaneckman

Alternatively this could be done by a (optional) router config setting (defaulting to current behaviour)? Would prevent it from being a breaking change, would allow users to decide for themselves whether this is preferable or not, etc. 👍

Might be wrong, but this could also maybe allow users to let a child router route back to the child router's "home" state and not navigate back to a parent router.

pndewit avatar Feb 20 '18 12:02 pndewit

Nice ideas, @pndewit.

davismj avatar Mar 21 '18 07:03 davismj