Skip to content
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

Shadow endpoints navigation within same route #3727

Closed
livehtml opened this issue Feb 4, 2022 · 5 comments · Fixed by #3925
Closed

Shadow endpoints navigation within same route #3727

livehtml opened this issue Feb 4, 2022 · 5 comments · Fixed by #3925
Labels
bug Something isn't working
Milestone

Comments

@livehtml
Copy link

livehtml commented Feb 4, 2022

Describe the bug

How can we navigate if route component and endpoint won't change?
Currently its not work as expected.
If we have say:
/example/[...rest].js
/example/[...rest].svelte

And try to use links on page like:
href="/example", href="/example/1", href="example/2" — navigation between them won't work (page not updates, only address bar changes)

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-x92deg?devtoolsheight=33&file=src/routes/example/[...rest].js

Logs

No response

System Info

kit next 260

Severity

serious, but I can work around it

Additional Information

No response

@Conduitry Conduitry added the bug Something isn't working label Feb 4, 2022
@thenbe
Copy link
Contributor

thenbe commented Feb 5, 2022

but I can work around it

@livehtml I've run into the same issue. Would you mind sharing your workaround?

@livehtml
Copy link
Author

livehtml commented Feb 5, 2022

@ambiguous48 sure:

export const load = async ({ params, props }) => {
    if (params.rest) '';
    return { props }
};

Just highlight needed params to watch it in the load function and it works as expected.
But I think it's more like a 'hack' other than right way.

@thenbe
Copy link
Contributor

thenbe commented Feb 5, 2022

I've tried your workaround and it doesn't work for searchParams as far as I can tell.

In my case I'm using url.searchParams (not params) and I can't seem to get the shadow endpoint to pick up changes in the url.searchParams after navigating with goto.

After a manual refresh, the first time calling goto works as expected. Then, the url continues to change as expected, the load function is able to pick up the changes, but not the shadow endpoint.

@tmarnet
Copy link
Contributor

tmarnet commented Feb 8, 2022

Noticed the same issue with both:

  • search params, e.g. navigating from /movies to /movies?q=foo using goto(), the shadow endpoint doesn't receive the q search param
  • dynamic params, e.g. navigating from /movies/1 to /movies/2 (assuming we have a /movies/[id] route) using a regular link, the shadow endpoint doesn't seem to be called with the new id param

@PH4NTOMiki
Copy link
Contributor

I was testing this and as it turns out prefetching works for those routes without any issue, but the actual navigation doesn't, @benmccann @bluwy as far as I can see, it looks like the code that checks is the route the same as previous is causing this, I'm trying to fix it, but I didn't succeeded yet. if I do, I'll push PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
6 participants