aurelia / router

A powerful client-side router.
MIT License
120 stars 115 forks source link

navigateBack or home #564

Open jonathaneckman opened 6 years ago

jonathaneckman commented 6 years ago

I'm submitting a feature request

Please tell us about your environment:

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.

davismj commented 6 years ago

@jonathaneckman Ready for your next submission? :smile:

jonathaneckman commented 6 years ago

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.

pndewit commented 6 years ago

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.

davismj commented 6 years ago

Nice ideas, @pndewit.