form
only populating after second submission
#12383
Unanswered
Creative-Difficulty
asked this question in
Q&A
Replies: 1 comment
-
You need to call
https://kit.svelte.dev/docs/form-actions#progressive-enhancement-customising-use-enhance |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
The exact line: https://github.com/Creative-Difficulty/marc-plan/blob/8c0ca475d086740cae206aa608d58022429871d5/src/routes/signup/%2Bpage.svelte#L122
After the first form submission, the actions runs as normal, but the export let form: ActionData doesn't populate and stays (or becomes?) null. You can check this, by logging the form variable after submit and before the await update(...) function is called, as marked in the link above. This means, that errors get returned from the action (this can be confirmed by replacing the console.log in the code with console.log(result) and seeing the data.message equals the message returned from the server), but the form variable doesn't get populated. I think this only affects the signup route, but i haven't checked yet.
Another question: If i call the toast.error(...) after the await update(...), it doesn't run, but if i call it before, everything works as normal.
My theory: update(...) populates form , so when logging it before calling update(...), it still has the "old" state (from the previous submission) which in case of the first submission would be null. Is this true? Is this documented anywhere? Any help is appreciated!
I might also be using progressive enhancement wrong in general.
Reproduction
GitHub repo: https://github.com/Creative-Difficulty/marc-plan/
A turso database has to be created for full reproduction.
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions