svecosystem/formsnap

Issues with setValue() when redirecting to the same URL

n00ki opened this issue · 0 comments

n00ki commented

Hi ✋

I'm battling an issue with formsnap’s field setValue prop when redirecting to the same URL after a valid form submission.
After reaching out on Discord to ensure I'm not doing anything fundamentally wrong, I believe it might be a possible bug.

The Issue:
I have a hidden form input field that is dynamically populated on the client with data returned from a load function.
for some reason, when the form is submitted and the page is redirected back to the same URL pathname - the browser tab gets completely stuck and the page doesn’t get rerendered as expected.
When redirecting to any other page - everything works as expected.

It took me some time to figure out the cause for this behavior, but after cleaning up any suspected causes and comparing the same exact flow with a Superforms form with bind:value (works as expected) - I found that passing a static value to setValue() solves the issue.

Reproductions:
Here's a StackBlitz isolated reproduction project:
https://stackblitz.com/edit/sveltejs-kit-template-default-tbebau

And here’s a gist of both +page.svelte & +page.server.ts
https://gist.github.com/n00ki/c563a5a24d21fd827f63452f1d8ef73b

Could this potentially be a true bug? 🤷‍♂️
Thanks a lot in advance!