router
router copied to clipboard
navigateBack or home
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:
- Navigate directly to a route by typing the URL in the address bar.
- Click a button on the page that calls router.navigateBack()
- 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 Ready for your next submission? :smile:
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.
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.
Nice ideas, @pndewit.