diff --git a/src/register/RegistrationFailure.jsx b/src/register/RegistrationFailure.jsx index daf10c3c..88710572 100644 --- a/src/register/RegistrationFailure.jsx +++ b/src/register/RegistrationFailure.jsx @@ -10,11 +10,13 @@ import messages from './messages'; import { windowScrollTo } from '../data/utils'; const RegistrationFailureMessage = (props) => { - const { context, errorCode, intl } = props; + const { + context, errorCode, failureCount, intl, + } = props; useEffect(() => { windowScrollTo({ left: 0, top: 0, behavior: 'smooth' }); - }, [errorCode]); + }, [errorCode, failureCount]); let errorMessage; switch (errorCode) { @@ -50,6 +52,7 @@ RegistrationFailureMessage.propTypes = { provider: PropTypes.string, }), errorCode: PropTypes.string.isRequired, + failureCount: PropTypes.number.isRequired, intl: intlShape.isRequired, }; diff --git a/src/register/RegistrationPage.jsx b/src/register/RegistrationPage.jsx index cdc14a8c..332e5d9a 100644 --- a/src/register/RegistrationPage.jsx +++ b/src/register/RegistrationPage.jsx @@ -67,6 +67,7 @@ class RegistrationPage extends React.Component { country: '', }, errorCode: null, + failureCount: 0, institutionLogin: false, optionalFields, optionalFieldsState: {}, @@ -179,7 +180,10 @@ class RegistrationPage extends React.Component { }); if (!this.isFormValid(errors)) { - this.setState({ errorCode: FORM_SUBMISSION_ERROR }); + this.setState(prevState => ({ + errorCode: FORM_SUBMISSION_ERROR, + failureCount: prevState.failureCount + 1, + })); return; } @@ -378,7 +382,11 @@ class RegistrationPage extends React.Component { />