From 7d3089270a4fe6bc77afb65f9380455e1dc096e4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 23 Apr 2020 15:13:05 -0500 Subject: [PATCH] SimpleForm e.preventDefault() always --- app/gabsocial/features/forms/index.js | 34 +++++++++++++------ .../components/registration_form.js | 1 - 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/gabsocial/features/forms/index.js b/app/gabsocial/features/forms/index.js index 7cb91cc36..fed8deb8e 100644 --- a/app/gabsocial/features/forms/index.js +++ b/app/gabsocial/features/forms/index.js @@ -79,18 +79,32 @@ export class SimpleInput extends ImmutablePureComponent { } -export const SimpleForm = ({ children, ...props }) => ( -
{children}
-); +export class SimpleForm extends ImmutablePureComponent { -SimpleForm.propTypes = { - children: PropTypes.node, -}; + static propTypes = { + children: PropTypes.node, + }; -SimpleForm.defaultProps = { - acceptCharset: 'UTF-8', - onSubmit: e => e.preventDefault(), -}; + static defaultProps = { + acceptCharset: 'UTF-8', + onSubmit: e => {}, + }; + + onSubmit = e => { + this.props.onSubmit(e); + e.preventDefault(); + } + + render() { + const { children, onSubmit, ...props } = this.props; + return ( +
+ {children} +
+ ); + } + +} export const FieldsGroup = ({ children }) => (
{children}
diff --git a/app/gabsocial/features/landing_page/components/registration_form.js b/app/gabsocial/features/landing_page/components/registration_form.js index 21eba9750..c50abecfc 100644 --- a/app/gabsocial/features/landing_page/components/registration_form.js +++ b/app/gabsocial/features/landing_page/components/registration_form.js @@ -23,7 +23,6 @@ class RegistrationForm extends ImmutablePureComponent { onSubmit = e => { // TODO: Dispatch action - e.preventDefault(); } render() {