-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
SvelteKit 2: load url.searchParams bug #11503
Comments
I'm sorry severity is not annoyance, but this is a critical issue, as this one bug blocks us to upgrade to sveltekit 2.0 |
The console shows the issue and solution:
With that change, it works as expected. |
This was changed in #11307 - @Rich-Harris could you elaborate on why the change to use That said, @martonx why aren't you using |
I thought it did last night, but stackblitz isn't working for me this morning to confirm, I may have been mistaken. |
@dummdidumm I don't use goto because of I don't want to navigate in real. I just want to change the url, and fetch some fresh data. Actually this is a deep linked filtering in an interactive page. When you are changing the filters, I'm doing the filtering in the load method (this is why I use invalidate), and I'm keeping in sync the url query string params. I tried goto now. The issue with goto it overwrites the current page state for example scroll position. window.history.pushState(null, '', to: goto( The filtering is working, but the page is scrolling to the top, I don't know why. This is not visible in the repro code, but very frustrating in my real code, where the filters, and the filter results are not on the top of the page. |
I changed this line: window.history.pushState(null, '', to pushState( nothing changed, nothing fixed. |
It looks similar to the issue I opened 2 weeks ago (#11465). It seems that |
I think what you want is Or better yet, use a GET action form that does this for you with progressive enhancement The real issue is that after using |
I also ran into this problem, and its very annoying. For now I can work around it with this: window.history.replaceState(history.state, '', url); |
I'm not sure how to fix this without updating the internal Some notes on shallow routing with
|
Describe the bug
When we changed searchParams, and force to reload sveltekit data, url.searchParams remain the same value as before the change.
Reproduction
Reproduction:
https://stackblitz.com/edit/sveltejs-kit-template-default-xeika8?file=src%2Froutes%2F%2Bpage.svelte
click on the change url button. This will do a window.history.pushState with new searchParams then invalidate data, so it'll trigger the page.js load function.
In load function check url.searchParams (consol.log writes it).
The reproduction is a bit bad as this sandbox environment doesn't visibly change the url, but the reproduction is working locally or from any kind of hosting method.
This worked with SvelteKit 1.30.x. It is broken just after the SvelteKit 2.0 update. You can reproduce it with old and current SvelteKit.
Logs
No response
System Info
Severity
critical
Additional Information
No response
The text was updated successfully, but these errors were encountered: