using input onSubmit instead of form onSubmit

This commit is contained in:
NikolaBorislavovHristov 2019-02-04 14:26:58 +02:00
parent 86409d6ade
commit 96a8cf78d0
2 changed files with 11 additions and 11 deletions

View file

@ -22,8 +22,14 @@ class Input extends PureComponent {
this.props.onKeyUp(event);
}
if (!event.defaultPrevented && BUTTON_INPUT_TYPES.includes(this.props.type) && event.which === ENTER_KEY_CODE) {
event.currentTarget.click();
if (!event.defaultPrevented && event.which === ENTER_KEY_CODE) {
if (BUTTON_INPUT_TYPES.includes(this.props.type)) {
event.currentTarget.click();
} else if (TEXT_INPUT_TYPES.includes(this.props.type)) {
if (typeof this.props.onSubmit === 'function') {
this.props.onSubmit(event);
}
}
}
}

View file

@ -189,20 +189,14 @@ class Intro extends Component {
<div className={styles['label']}>Login with Facebook</div>
</Input>
<div className={styles['facebook-statement']}>We won't post anything on your behalf</div>
<form onSubmit={this.emailOnSubmit}>
<Input ref={this.emailRef} className={styles['text-input']} type={'email'} placeholder={'Email'} value={this.state.email} onChange={this.emailOnChange} />
</form>
<form onSubmit={this.passwordOnSubmit}>
<Input ref={this.passwordRef} className={styles['text-input']} type={'password'} placeholder={'Password'} value={this.state.password} onChange={this.passwordOnChange} />
</form>
<Input ref={this.emailRef} className={styles['text-input']} type={'email'} placeholder={'Email'} value={this.state.email} onChange={this.emailOnChange} onSubmit={this.emailOnSubmit} />
<Input ref={this.passwordRef} className={styles['text-input']} type={'password'} placeholder={'Password'} value={this.state.password} onChange={this.passwordOnChange} onSubmit={this.passwordOnSubmit} />
{
this.state.selectedForm === FORMS.LOGIN ?
<Input className={styles['forgot-password-link']} type={'link'} href={'https://www.strem.io/reset-password/'} target={'_blank'}>Forgot password?</Input>
:
<Fragment>
<form onSubmit={this.confirmPasswordOnSubmit}>
<Input ref={this.confirmPasswordRef} className={styles['text-input']} type={'password'} placeholder={'Confirm Password'} value={this.state.confirmPassword} onChange={this.confirmPasswordOnChange} />
</form>
<Input ref={this.confirmPasswordRef} className={styles['text-input']} type={'password'} placeholder={'Confirm Password'} value={this.state.confirmPassword} onChange={this.confirmPasswordOnChange} onSubmit={this.confirmPasswordOnSubmit} />
<ConsentCheckbox ref={this.termsRef} className={styles['consent-checkbox']} label={'I have read and agree with the Stremio'} link={'Terms and conditions'} href={'https://www.stremio.com/tos'} checked={this.state.termsAccepted} onClick={this.toggleTerms} />
<ConsentCheckbox ref={this.privacyPolicyRef} className={styles['consent-checkbox']} label={'I have read and agree with the Stremio'} link={'Privacy Policy'} href={'https://www.stremio.com/privacy'} checked={this.state.privacyPolicyAccepted} onClick={this.togglePrivacyPolicy} />
<ConsentCheckbox ref={this.marketingRef} className={styles['consent-checkbox']} label={'I agree to receive marketing communications from Stremio'} checked={this.state.marketingAccepted} onClick={this.toggleMarketing} />