Skip to content

Commit f8a8428

Browse files
authored
[fix] reset form in use:enhance after successful submit (#7207)
Fixes #7163
1 parent 2549375 commit f8a8428

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

.changeset/rotten-trees-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[fix] reset form in use:enhance after successful submit

packages/kit/src/runtime/app/forms.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function enhance(form, submit = () => {}) {
2525
*/
2626
const fallback_callback = async ({ action, result }) => {
2727
if (result.type === 'success') {
28+
form.reset();
2829
await invalidateAll();
2930
}
3031

packages/kit/test/apps/basics/test/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,7 @@ test.describe('Actions', () => {
18731873

18741874
await expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ result: 'foo' }));
18751875
await expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ result: 'foo' }));
1876+
await expect(page.locator('input[name=username]')).toHaveValue('');
18761877
});
18771878

18781879
test('use:enhance abort controller', async ({ page, javaScriptEnabled }) => {

0 commit comments

Comments
 (0)