Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/kind-emus-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: wait a tick before collecting form data for validation
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,20 @@ export function form(id) {

const id = ++validate_id;

// wait a tick in case the user is calling validate() right after set() which takes time to propagate
await tick();

const form_data = new FormData(element, submitter);

/** @type {readonly StandardSchemaV1.Issue[]} */
let array = [];

const validated = await preflight_schema?.['~standard'].validate(convert(form_data));

if (validate_id !== id) {
return;
}

if (validated?.issues) {
array = validated.issues;
} else {
Expand Down
Loading