Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Issue: from unknown route to known route not recovering #27

Closed
fabien opened this issue Jan 23, 2021 · 4 comments
Closed

Issue: from unknown route to known route not recovering #27

fabien opened this issue Jan 23, 2021 · 4 comments
Assignees
Labels
Will be fixed in next release These bugs will be fixed soon

Comments

@fabien
Copy link

fabien commented Jan 23, 2021

Please check out: https://codesandbox.io/s/svelte-easyroute-simpliest-demo-forked-8vku7

Without enabling the fallback route (currently commented out), there's no way to gracefully recover from an unknown route. If you click on 'Page Unknown' and then try to load 'Page 2' again, it won't work. The nested outlet remains blank (likely because it isn't there anymore, because Layout has been unloaded as well). Going to 'Page 1' first, then to 'Page 2' does work.

While you can work around this (using the fallback route), I believe a valid route should recover itself without any special care from the developer.

@lyohaplotinka lyohaplotinka self-assigned this Jan 23, 2021
@lyohaplotinka lyohaplotinka added the Will be fixed in next release These bugs will be fixed soon label Jan 23, 2021
@lyohaplotinka
Copy link
Collaborator

Hello @fabien!
Thank you for these two issues. I will try to make things work as soon as possible.

@fabien
Copy link
Author

fabien commented Jan 23, 2021

By the way, have you considered having the beforeEnter detect such a function exported from a component module, like so? This is more or less how Sapper and other frameworks tend to solve this.

Preferably, it would run after any router assigned beforeEnter (and beforeEach).

<script context="module">
	export function async beforeEnter(to, from) {
		return false; // stop here
	}
</script>

@lyohaplotinka
Copy link
Collaborator

lyohaplotinka commented Jan 24, 2021

Hello @fabien!

I actually ran into a bug inside RouterOutlet that got fixed. Thank you very much!

However, in your example, I noticed that you are using a wildcard in your parent route path definition. This should not be done because the router will regard this route as suitable for every url.

Remember: routes with wildcards should always go to the very bottom after defining routes without them.

Fork your example with fixes: https://codesandbox.io/s/svelte-easyroute-simpliest-demo-forked-pofoc?file=/router.js

This bug has been fixed in version 3.0.7.

As for finding hooks in component exports - this is not planned.

@fabien
Copy link
Author

fabien commented Jan 24, 2021

Hi @lyohaplotinka! Thanks for clarifying this.

I was a bit puzzled when I saw my example not work with 3.0.7 anymore, but that explains it then!

It would be nice to see some more documented examples of routes (like named views for example).

Regarding the hooks in component modules, it's ok. We can do it using beforeEnter I think.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Will be fixed in next release These bugs will be fixed soon
Projects
None yet
Development

No branches or pull requests

2 participants