From e8c7ea89d1cdbd5100b6c9fee6c1b3df86927fb6 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Thu, 20 Oct 2022 16:10:54 +0200 Subject: [PATCH 1/2] [feat] add reset option to update method of enhance It's not uncommon to want the form values be preserved, so it makes sense to have this configurable --- .changeset/nervous-students-march.md | 6 ++++++ documentation/docs/06-form-actions.md | 2 +- .../templates/default/src/routes/sverdle/+page.svelte | 10 +++------- packages/kit/src/runtime/app/forms.js | 9 ++++++--- packages/kit/types/ambient.d.ts | 8 ++++++-- 5 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 .changeset/nervous-students-march.md diff --git a/.changeset/nervous-students-march.md b/.changeset/nervous-students-march.md new file mode 100644 index 000000000000..8efe61cff274 --- /dev/null +++ b/.changeset/nervous-students-march.md @@ -0,0 +1,6 @@ +--- +'default-template': patch +'@sveltejs/kit': patch +--- + +[feat] add reset option to update method of enhance diff --git a/documentation/docs/06-form-actions.md b/documentation/docs/06-form-actions.md index 401e09f14ca3..05dcde8467e3 100644 --- a/documentation/docs/06-form-actions.md +++ b/documentation/docs/06-form-actions.md @@ -250,7 +250,7 @@ The easiest way to progressively enhance a form is to add the `use:enhance` acti Without an argument, `use:enhance` will emulate the browser-native behaviour, just without the full-page reloads. It will: - update the `form` property, `$page.form` and `$page.status` on a successful or invalid response, but only if the action is on the same page you're submitting from. So for example if your form looks like `
`, `form` and `$page` will _not_ be updated. This is because in the native form submission case you would be redirected to the page the action is on. -- invalidate all data using `invalidateAll` on a successful response +- reset the `` element and invalidate all data using `invalidateAll` on a successful response - call `goto` on a redirect response - render the nearest `+error` boundary if an error occurs diff --git a/packages/create-svelte/templates/default/src/routes/sverdle/+page.svelte b/packages/create-svelte/templates/default/src/routes/sverdle/+page.svelte index 6f3352278dea..894afab18ff7 100644 --- a/packages/create-svelte/templates/default/src/routes/sverdle/+page.svelte +++ b/packages/create-svelte/templates/default/src/routes/sverdle/+page.svelte @@ -1,8 +1,7 @@