From ed62660e96528920b0ecb8c755265c6c8d2756c4 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 31 Jul 2017 12:55:49 -0400 Subject: PLT-7185: Double clicking Create Account attempts to create an account twice (#7025) * PLT-7185: Disabled submit button after it is clicked for the first time, unless an error occurs * PLT-7140: Removed all static function decorators that I previously added to jsx files. These were suggested by eslint, but can cause issues for functions that override parent functionality. still can't reproduce the errors seen on spinmint locally, so I'm guessing at this point (cherry picked from commit 34b87fe88a7e1c05ce97324861124e531a8a840b) --- webapp/components/signup/components/signup_email.jsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'webapp') diff --git a/webapp/components/signup/components/signup_email.jsx b/webapp/components/signup/components/signup_email.jsx index 872439eda..bcf47b825 100644 --- a/webapp/components/signup/components/signup_email.jsx +++ b/webapp/components/signup/components/signup_email.jsx @@ -138,7 +138,10 @@ export default class SignupEmail extends React.Component { if (err.id === 'api.user.login.not_verified.app_error') { browserHistory.push('/should_verify_email?email=' + encodeURIComponent(user.email) + '&teamname=' + encodeURIComponent(this.state.teamName)); } else { - this.setState({serverError: err.message}); + this.setState({ + serverError: err.message, + isSubmitting: false + }); } } ); @@ -222,12 +225,18 @@ export default class SignupEmail extends React.Component { handleSubmit(e) { e.preventDefault(); + // bail out if a submission is already in progress + if (this.state.isSubmitting) { + return; + } + if (this.isUserValid()) { this.setState({ nameError: '', emailError: '', passwordError: '', - serverError: '' + serverError: '', + isSubmitting: true }); const user = { @@ -243,7 +252,10 @@ export default class SignupEmail extends React.Component { this.state.inviteId, this.handleSignupSuccess.bind(this, user), (err) => { - this.setState({serverError: err.message}); + this.setState({ + serverError: err.message, + isSubmitting: false + }); } ); } @@ -388,6 +400,7 @@ export default class SignupEmail extends React.Component { type='submit' onClick={this.handleSubmit} className='btn-primary btn' + disabled={this.state.isSubmitting} >