1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-22 19:44:21 +00:00

🐛 Tentative fix for the onSubmit refresh

Reported by @LBindustries
This commit is contained in:
Steffo 2021-08-31 17:13:09 +02:00
parent 2f9e4908ae
commit 67d7abacd9
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -19,11 +19,19 @@ import {Button} from "../inputs/Button";
export interface FormProps extends Types.BluelibHTMLProps<HTMLFormElement> {}
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 (
<BaseElement kind={"form"} {...props}/>
<BaseElement kind={"form"} onSubmit={onSubmitPreventDefault} {...props}/>
)
}