From 67d7abacd92d404daed70a221d9c6f8610d716ca Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 31 Aug 2021 17:13:09 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Tentative=20fix=20for=20the=20on?= =?UTF-8?q?Submit=20refresh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by @LBindustries --- src/components/forms/Form.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/forms/Form.tsx b/src/components/forms/Form.tsx index 4a833b2..9c85e8c 100644 --- a/src/components/forms/Form.tsx +++ b/src/components/forms/Form.tsx @@ -19,11 +19,19 @@ import {Button} from "../inputs/Button"; export interface FormProps extends Types.BluelibHTMLProps {} -export function Form({...props}: FormProps): JSX.Element { +export function Form({onSubmit, ...props}: FormProps): JSX.Element { props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "form") + const onSubmitPreventDefault = React.useCallback( + event => { + if(onSubmit) onSubmit(event) + event.preventDefault() + }, + [onSubmit] + ) + return ( - + ) }