You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Same-URL remote form() edit page, backed by a query(). After a successful Save the query already has the new values, but radios / select / checkbox selection and fields.value() don't stay in sync. Calling query().refresh() in the handler doesn't help.
Default {...form} enhance runs element.reset() after success (client form). On the server, success stores a submission withoutinput, and fields.set(...) returns early (don't override a submission) (server form).
.as('radio', option) can't. The second arg is the option identity, not "current selection", so once input is emptied nothing stays checked.
checkbox has no second arg at all.
select is passed the current value (.as('select', queryValue), same as text) but still breaks with JS: after reset() + the submission lock it falls back to the first option.
Text is the only control that comes back correctly.
redirect(303) only works around this when it actually navigates. Without JS the browser does a real 303 then GET; fresh page, fields match. With JS, a redirect to the same URL is handled as a client invalidateAll (no navigation, no remount), so you get the same stay-on-page bug. It only helps when the target URL is different.
Docs point edits at stay-on-page + .as(type, value), and mostly show redirect for create → new URL. Always-redirect doesn't look like the prescribed path. Reset-on-success (#14322) and ignoring set after submission (#15465) do look intentional.
It would be nice if this could "just work" like the text input already does.
The no-js routes throw a 500 on StackBlitz/WebContainer. They work on a real Node runtime; run the repo locally for those. This is reported in issue #16818.
Open /default (default enhance, JS on). Change visibility / frequency / marketing / title, Save.
Query dump shows the new values, but the controls revert to their defaults (radios → default option, select → first option) and fields.value() is stale. Only the title text input stays correct. A plain reload fixes it (clean GET).
Open /default/no-js via the no-JS page link (data-sveltekit-reload + csr = false). Same broken end-state after Save: you land on the ?/remote=… action URL. A plain reload re-runs the submission and stays broken. Navigate away and back (clean GET) to fix it.
/custom-enhance: with JS, skipping reset() keeps both the DOM selection and fields.value() correct across repeated saves (workaround). /custom-enhance/no-js stays broken since there is no enhance without JS.
/redirect: with JS this is broken like /default, because returnTo is the same URL and the client handles the redirect as invalidateAll (no navigation or remount). /redirect/no-js works: a real 303 then GET lands on a fresh page whose fields match the query.
Describe the bug
Same-URL remote
form()edit page, backed by aquery(). After a successful Save the query already has the new values, but radios / select / checkbox selection andfields.value()don't stay in sync. Callingquery().refresh()in the handler doesn't help.Default
{...form}enhance runselement.reset()after success (client form). On the server, success stores a submission withoutinput, andfields.set(...)returns early (don't override a submission) (server form).How that lands per control:
.as('text', queryValue)from feat: allow second value for all types of fields #15577 can still look fine (get_value() ?? secondArg)..as('radio', option)can't. The second arg is the option identity, not "current selection", so onceinputis emptied nothing stays checked.checkboxhas no second arg at all.selectis passed the current value (.as('select', queryValue), same as text) but still breaks with JS: afterreset()+ the submission lock it falls back to the first option.Text is the only control that comes back correctly.
redirect(303)only works around this when it actually navigates. Without JS the browser does a real303thenGET; fresh page, fields match. With JS, a redirect to the same URL is handled as a clientinvalidateAll(no navigation, no remount), so you get the same stay-on-page bug. It only helps when the target URL is different.Docs point edits at stay-on-page +
.as(type, value), and mostly showredirectfor create → new URL. Always-redirect doesn't look like the prescribed path. Reset-on-success (#14322) and ignoringsetafter submission (#15465) do look intentional.It would be nice if this could "just work" like the text input already does.
Reproduction
https://stackblitz.com/github/janekprange/sveltekit-remote-form-post-success-rehydrate
Repo: https://github.com/janekprange/sveltekit-remote-form-post-success-rehydrate
fields.value()is stale. Only thetitletext input stays correct. A plain reload fixes it (cleanGET).data-sveltekit-reload+csr = false). Same broken end-state after Save: you land on the?/remote=…action URL. A plain reload re-runs the submission and stays broken. Navigate away and back (cleanGET) to fix it.reset()keeps both the DOM selection andfields.value()correct across repeated saves (workaround). /custom-enhance/no-js stays broken since there is no enhance without JS.returnTois the same URL and the client handles the redirect asinvalidateAll(no navigation or remount). /redirect/no-js works: a real303thenGETlands on a fresh page whose fields match the query.Logs
System Info
Severity
annoyance
Additional Information
App-side workaround I use today: custom
.enhance()withoutreset()for JS, plusredirect(303)when!getRequestEvent().isRemoteRequestfor no-JS.Related:
setafter submission ignored on purpose;.assecond arg helps text-like fieldsreset()after enhanced success is intentional_gototiming