From b1d88fdc789acc8e02e5bea46229bca7849b90fb Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 1 Jan 2024 16:37:48 -0500 Subject: [PATCH] fix: preventDefault() on error --- examples/form/src/components/preact/Form.tsx | 1 + examples/form/src/components/react/Form.tsx | 1 + packages/form/templates/preact/Form.tsx | 1 + packages/form/templates/react/Form.tsx | 1 + 4 files changed, 4 insertions(+) diff --git a/examples/form/src/components/preact/Form.tsx b/examples/form/src/components/preact/Form.tsx index 788f2d6..5691635 100644 --- a/examples/form/src/components/preact/Form.tsx +++ b/examples/form/src/components/preact/Form.tsx @@ -76,6 +76,7 @@ export function Form({ return formContext.trackAstroSubmitStatus(); } + e.preventDefault(); e.stopPropagation(); formContext.setValidationErrors(parsed.fieldErrors); }} diff --git a/examples/form/src/components/react/Form.tsx b/examples/form/src/components/react/Form.tsx index 0a071d1..5c5e337 100644 --- a/examples/form/src/components/react/Form.tsx +++ b/examples/form/src/components/react/Form.tsx @@ -78,6 +78,7 @@ export function Form({ return formContext.trackAstroSubmitStatus(); } + e.preventDefault(); e.stopPropagation(); formContext.setValidationErrors(parsed.fieldErrors); }} diff --git a/packages/form/templates/preact/Form.tsx b/packages/form/templates/preact/Form.tsx index 821e1a3..50f3a49 100644 --- a/packages/form/templates/preact/Form.tsx +++ b/packages/form/templates/preact/Form.tsx @@ -74,6 +74,7 @@ export function Form({ return formContext.trackAstroSubmitStatus(); } + e.preventDefault(); e.stopPropagation(); formContext.setValidationErrors(parsed.fieldErrors); }} diff --git a/packages/form/templates/react/Form.tsx b/packages/form/templates/react/Form.tsx index 383844b..2aa8ced 100644 --- a/packages/form/templates/react/Form.tsx +++ b/packages/form/templates/react/Form.tsx @@ -78,6 +78,7 @@ export function Form({ return formContext.trackAstroSubmitStatus(); } + e.preventDefault(); e.stopPropagation(); formContext.setValidationErrors(parsed.fieldErrors); }}