Skip to content

Commit

Permalink
Merge pull request #18 from bholmesdev/fix/prevent-default
Browse files Browse the repository at this point in the history
Fix accidental form submission
  • Loading branch information
bholmesdev authored Jan 1, 2024
2 parents c524889 + 86034e4 commit bcc6373
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-beers-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"simple-stack-form": patch
---

Fix accidental form submission on client validation errors
1 change: 1 addition & 0 deletions examples/form/src/components/preact/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function Form({
return formContext.trackAstroSubmitStatus();
}

e.preventDefault();
e.stopPropagation();
formContext.setValidationErrors(parsed.fieldErrors);
}}
Expand Down
1 change: 1 addition & 0 deletions examples/form/src/components/react/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function Form({
return formContext.trackAstroSubmitStatus();
}

e.preventDefault();
e.stopPropagation();
formContext.setValidationErrors(parsed.fieldErrors);
}}
Expand Down
1 change: 1 addition & 0 deletions packages/form/templates/preact/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function Form({
return formContext.trackAstroSubmitStatus();
}

e.preventDefault();
e.stopPropagation();
formContext.setValidationErrors(parsed.fieldErrors);
}}
Expand Down
1 change: 1 addition & 0 deletions packages/form/templates/react/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function Form({
return formContext.trackAstroSubmitStatus();
}

e.preventDefault();
e.stopPropagation();
formContext.setValidationErrors(parsed.fieldErrors);
}}
Expand Down

0 comments on commit bcc6373

Please sign in to comment.