-
-
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
History state is overwritten to {}
during navigation since next.208
#3236
Comments
@gustavopch thanks for the investigation! care to send a PR? |
@benmccann This would fix the problem, but I'm not sure if it might break some other behavior. What do you think? - history.replaceState({}, '', info.url);
+ history.replaceState(history.state, '', info.url); |
This won't be needed once #3241 is merged |
Rich sent #3312 to remove this feature, which would in effect close this issue. Regarding the severity of "blocking all usage of SvelteKit" - I don't think there's anything you could do with this API that you couldn't do with local storage? But if there's a usercase you have for this feature, you may want to chime in on #1641 to help make it clearer what it's being used for |
@benmccann Local storage, session storage, and history state are not interchangeable. They have different lifecycles and serve different needs.
Whenever you have data that only makes sense for a specific route, history state is the way to go. Actual use case: history-controlled modals<script>
import { goto } from '$app/navigation'
import { historyState } from './store'
</script>
<button on:click={() => goto('', { state: { modal: 'first' } })}>Open first modal</button>
<Modal open={$historyState.modal === 'first'}>
<button on:click={() => goto('', { state: { modal: 'second' } })}>Open second modal</button>
</Modal>
<Modal open={$historyState.modal === 'second'}>
<button on:click={() => history.go(-2)}>Close</button>
</Modal> I have That said, I think there would be no problem if I had to call |
I'm closing since it was fixed in e3cb69b. |
Describe the bug
Since
@sveltejs/kit@1.0.0-next.208
,goto()
'sstate
parameter stopped working. This line is overwriting the state to{}
whenever navigation occurs:kit/packages/kit/src/runtime/client/router.js
Line 281 in 1a6adc8
This is the commit that introduced the bug: d17f459.
Reproduction
goto()
.Logs
No response
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response
The text was updated successfully, but these errors were encountered: