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:
parent
2f9e4908ae
commit
67d7abacd9
1 changed files with 10 additions and 2 deletions
|
@ -19,11 +19,19 @@ import {Button} from "../inputs/Button";
|
||||||
export interface FormProps extends Types.BluelibHTMLProps<HTMLFormElement> {}
|
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")
|
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "form")
|
||||||
|
|
||||||
|
const onSubmitPreventDefault = React.useCallback(
|
||||||
|
event => {
|
||||||
|
if(onSubmit) onSubmit(event)
|
||||||
|
event.preventDefault()
|
||||||
|
},
|
||||||
|
[onSubmit]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseElement kind={"form"} {...props}/>
|
<BaseElement kind={"form"} onSubmit={onSubmitPreventDefault} {...props}/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue