-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Layout fallthrough #2440
Comments
What do you want to achieve / what is your expected behavior when you return nothing from a load function in __layout? AFAIK, fall-through routes exist for pages only, not for layouts. |
I want it to behave the same as the page endpoints. If the __layout returns nothing it should fall-through. I understand this issue is part bug and part feature request. I have this routes structure: I don't want to check validity of |
It sounds to me like, if anything should change here, there should be a more explicit error about |
So you have
and you want to fall through to |
Yeah. Fall through either to |
I'd like to work on this issue and will create a PR as soon as I'm done. |
Turns out the solution to this issue is pretty easy. All I had to do was to remove a is_leaf check in the load_node function in the server runtime // if leaf node (i.e. page component) has a load function
// that returns nothing, we fall through to the next one
if (!loaded && is_leaf && !is_error) return; and in the client-side renderer: else if (is_leaf && module.load) {
// if the leaf node has a `load` function
// that returns nothing, fall through
return; However it seems like this behaviour was actively prevented in the past. Was there a reason for that? |
Describe the bug
I am trying to throw an error:
This example works as expected within a page component. However when I put this logic inside
__layout.svelte
it behaves rather oddly.In first case when nothing is returned then application proceeds to the page component. It renders the page contents, however ignores the __layout content. When the page is refreshed and reloaded completelly it thows an error 500 saying "load must return a value except for page fall through"
I want to check path validity for all the child pages within one directory and putting this logic inside every single page is not ideal. Better solution would to be able to check only once, inside the layout component.
I understand this is probably outside of the scope of intended functionality but it might be a mice addition, in my opinion.
Reproduction
https://github.com/lemmon/svelte-kit-layout-error
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: