-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
bugSomething isn't workingSomething isn't workingformsStuff relating to forms and form actionsStuff relating to forms and form actionsp3-edge-caseSvelteKit cannot be used in an uncommon waySvelteKit cannot be used in an uncommon wayready to implementplease submit PRs for these issues!please submit PRs for these issues!
Milestone
Description
Describe the bug
I am using a form to save some string into the db. When the form loads, the load function supplies the old string from db. After sending the form (with use:enhance) the textarea is empty.
What else:
-> without use:enhance it works as intended
-> the variable holds the correct content
-> an input type=text showed the same behaviour
Reproduction
<script lang="ts">
import { enhance } from '$app/forms';
export let data;
let content = "";
// When setting content directly, each keystroke triggers the content setting. You cannot type. This way, the reactive
// statement does not know about content and thus only triggers with prop change.
function setContent(s:string)
{
content = s
}
$: setContent(data.report?.content || '');
</script>
<form method="POST" use:enhance>
<textarea name="content" cols="100" rows="20" bind:value={content} />
<button type="submit">Absenden</button>
</form>
{JSON.stringify(data.report)} <- shows correct version of saved report
{content} <- is also updated correctlyLogs
No response
System Info
System:
OS: Linux 6.2 Manjaro Linux
CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
Memory: 22.83 GB / 31.27 GB
Container: Yes
Shell: 3.6.0 - /usr/bin/fish
Binaries:
Node: 19.8.1 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 8.19.2 - /usr/bin/npm
Browsers:
Chromium: 111.0.5563.110
Firefox: 111.0.1
npmPackages:
@sveltejs/adapter-node: ^1.0.0 => 1.2.3
@sveltejs/kit: ^1.0.0 => 1.15.1
svelte: ^3.54.0 => 3.58.0
vite: ^4.0.0 => 4.2.1Severity
serious, but I can work around it
Additional Information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingformsStuff relating to forms and form actionsStuff relating to forms and form actionsp3-edge-caseSvelteKit cannot be used in an uncommon waySvelteKit cannot be used in an uncommon wayready to implementplease submit PRs for these issues!please submit PRs for these issues!