Skip to content

Commit bcc6373

Browse files
authored
Merge pull request #18 from bholmesdev/fix/prevent-default
Fix accidental form submission
2 parents c524889 + 86034e4 commit bcc6373

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

.changeset/hip-beers-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"simple-stack-form": patch
3+
---
4+
5+
Fix accidental form submission on client validation errors

examples/form/src/components/preact/Form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export function Form({
7676
return formContext.trackAstroSubmitStatus();
7777
}
7878

79+
e.preventDefault();
7980
e.stopPropagation();
8081
formContext.setValidationErrors(parsed.fieldErrors);
8182
}}

examples/form/src/components/react/Form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export function Form({
7878
return formContext.trackAstroSubmitStatus();
7979
}
8080

81+
e.preventDefault();
8182
e.stopPropagation();
8283
formContext.setValidationErrors(parsed.fieldErrors);
8384
}}

packages/form/templates/preact/Form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export function Form({
7474
return formContext.trackAstroSubmitStatus();
7575
}
7676

77+
e.preventDefault();
7778
e.stopPropagation();
7879
formContext.setValidationErrors(parsed.fieldErrors);
7980
}}

packages/form/templates/react/Form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export function Form({
7878
return formContext.trackAstroSubmitStatus();
7979
}
8080

81+
e.preventDefault();
8182
e.stopPropagation();
8283
formContext.setValidationErrors(parsed.fieldErrors);
8384
}}

0 commit comments

Comments
 (0)