-
-
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
Preserve history state on refresh when SSR is disabled #9868
Comments
This seems like a reasonable change. I'm curious about what sort of |
I am using replaceState to keep the values of the fields and pushState to create a new history entry on form submit, allowing the user to navigate between searches with back and forward. I am not using the snapshots API because the I don't want to be rude but I've checked the PR, and I see that sveltekit is going to save a history index inside the state. but I don't quite understand why all this is needed when we can just directly use the browser API. I mean as long as I keep the sveltekit data with the rest operator, sveltekit is happy because I'm not changing stuff that it added, and I can basically save whatever I want and then retrieve it at any moment. That said, probably I'm missing something, and maybe the Sveltekit way makes everything easier for most of the cases, but I wouldn't add a warning that wraps the history methods because you never know whether for any reason you have to use them and having many "expected" warnings is not the best. |
I'm having the same problem with prerender. |
Describe the bug
At this line svelte kit can pass
state: history.state
.This would prevent history state loss when refreshing the page.
Current workaround:
Save the state in the root
+layout.js
and restore it the root +layout.svelte usinghistory.replaceState(...data.savedState, null, location.href)
Reproduction
https://stackblitz.com/edit/sveltekit-preserve-history-state-bug?file=src/routes/+layout.js
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: