adds logic for preventDefault on Button

This commit is contained in:
Jarrod Flesch
2020-03-16 14:18:49 -04:00
parent 3caeba54be
commit 0c9fb098e0
2 changed files with 7 additions and 4 deletions

View File

@@ -19,8 +19,8 @@ const Button = (props) => {
].filter(Boolean).join(' ');
function handleClick(event) {
event.preventDefault();
onClick();
if (type !== 'submit' && onClick) event.preventDefault();
if (onClick) onClick();
}
const buttonProps = {
@@ -53,8 +53,8 @@ const Button = (props) => {
default:
return (
<button
{...buttonProps}
type="button"
{...buttonProps}
>
{children}
</button>

View File

@@ -11,7 +11,10 @@ const FormSubmit = ({ children }) => {
const formContext = useContext(FormContext);
return (
<div className={baseClass}>
<Button disabled={formContext.processing ? 'disabled' : ''}>
<Button
disabled={formContext.processing ? 'disabled' : ''}
type="submit"
>
{children}
</Button>
</div>