submit action - run with enter

This commit is contained in:
Jan Prochazka
2020-12-05 16:52:57 +01:00
parent a3837083da
commit 10dc7343ae
6 changed files with 57 additions and 20 deletions

View File

@@ -106,7 +106,10 @@ export function FormSelectField({ label, name, children = null, ...other }) {
}
export function FormSubmit({ onClick, value, ...other }) {
const { values } = useForm();
const { values, setSubmitAction } = useForm();
React.useEffect(() => {
setSubmitAction({ action: onClick });
}, [onClick]);
return <FormStyledButton type="submit" value={value} onClick={() => onClick(values)} {...other} />;
}