-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Breaks superforms internal sate restore on soft-reload, and on hard-reload with snapshots enabled #205
Comments
let formState: ReturnType<typeof capture> | null = null;
function do_capture() {
formState = capture();
}
function do_restore() {
if (formState != null) {
restore(formState);
}
} <button onclick={do_capture}>capture</button>
<button onclick={do_restore}>restore</button> This works, so I guess it is on initial initialisation |
Would you mind pushing your code to GitHub and dropping a repo link so I can debug? |
https://github.com/Mardoxx/formsnap-issue/
https://github.com/Mardoxx/formsnap-issue/blob/main/src/routes/%2Bpage.svelte#L16 |
or
When SuperDebug reports that the form is in an invalid state, dumping it shows the data to be correct. This might suggest an issue with SuperDebug component, although I think it is still worth investigating why this behavior has changed. This library is a wrapper around superforms which should cause no side effects on its functionality, this discrepancy is unexpected. It’s also possible that this issue could lead to bugs in more advanced use cases involving superforms. Investigating it now might help prevent potential problems down the line. |
I wonder if it has something to do with this? https://svelte.dev/docs/svelte/bind#input-bind:value Can you reproduce it without using formsnap at all? If so then this is an issue for sveltekit-superforms rather than formsnap. |
Without formsnap it works correctly. It is when the input element is
wrapped with formsnap components that this behaviour breaks.
…On Sun, 15 Dec 2024 at 16:35, Hunter Johnston ***@***.***> wrote:
I wonder if it has something to do with this?
https://svelte.dev/docs/svelte/bind#input-bind:value
Can you reproduce it without using formsnap at all? If so then this is an
issue for sveltekit-superforms rather than formsnap.
—
Reply to this email directly, view it on GitHub
<#205 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB2QMLRB3FKLCRGIBFODVT2FWVWTAVCNFSM6AAAAABTTYNKQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBTHE2DAMJZGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
CleanShot.2024-12-15.at.11.44.38.mp4I apologize, I'm having a difficult time following what is and isn't working as expected. This is the behavior I get when putting the component in runes mode (replace Is this not the expected behavior? |
Interesting.. strange, this is after putting it in rune modes |
Ah.. it's a firefox bug. Version 133.0.3 |
Here it is without formsnap (still in firefox), and it works correctly https://www.loom.com/share/2e7f6cdf4aae41e6a3600f6b772f3fc8 <script lang="ts">
import SuperDebug, { superForm } from 'sveltekit-superforms';
import { valibot } from 'sveltekit-superforms/adapters';
import { schema } from './schema';
let { data } = $props();
const form = superForm(data.form, {
validators: valibot(schema)
});
const { form: formData, message, enhance, capture, restore } = form;
export const snapshot = { capture, restore };
</script>
{#if $message}<h3>{$message}</h3>{/if}
<form method="POST" use:enhance>
<input type="text" bind:value={$formData.name} />
<input type="text" bind:value={$formData.email} />
<div><button>Submit</button></div>
</form>
<hr />
<p>
💥 <a target="_blank" href="https://superforms.rocks">Created with Superforms for SvelteKit</a> 💥
</p>
<SuperDebug data={$formData} />
<style>
.invalid {
color: red;
}
</style> |
Interesting... I'll take a closer look at this with firefox as soon as I get the chance! |
Describe the bug
Superforms internal state is not being restored when using
snapshots
, and also not restored on soft refresh.Superforms state not restored when soft refreshing.
snapshots
Superforms state not restored when soft or hard refreshing.
snapshots
Existing behaviour:
clone https://github.com/ciscoheat/superforms-examples/tree/tutorial-valibot (currently at 2414332)
Add
<SuperDebug data={$formData} />
to the bottom of the pagepnpm upgrade (or whatever package manager)
Run the project
Enter something in the email field
Soft refresh with cmd+r
Data is restored in superforms state
Hard refresh (cmd+shift+r)
State is (correctly) reset
Enable snapshots
export const snapshot = { capture, restore };
Do the same with hard refresh, state is restored.
Reproduction
Install
formsnap
pnpm upgrade
or whatever to get version numbers in line with my environment belowRun the project
Enter something in the email field
Soft refresh with cmd+r
Data is not restored in superforms state <---- problem
Hard refresh (cmd+shift+r)
State is (correctly) reset
un-comment out snapshot
hard refresh
state is not restored <---- major problem
Logs
No response
System Info
Severity
blocking all usage of Formsnap
The text was updated successfully, but these errors were encountered: