fix: Saved user credentials not filling [VAN-1027] (#610)

This commit is contained in:
Syed Sajjad Hussain Shah
2022-08-12 16:13:10 +05:00
committed by GitHub
parent 0af61b1387
commit fce5b23763
4 changed files with 26 additions and 18 deletions

View File

@@ -100,7 +100,7 @@ const ForgotPasswordPage = (props) => {
validateOnChange={false}
validate={(values) => {
const validationMessage = getValidationMessage(values.email);
props.setForgotPasswordFormData({ emailValidationError: validationMessage });
if (validationMessage !== '') {
windowScrollTo({ left: 0, top: 0, behavior: 'smooth' });
return { email: validationMessage };

View File

@@ -40,7 +40,7 @@ initialize({
INFO_EMAIL: process.env.INFO_EMAIL || '',
REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME || null,
ENABLE_PROGRESSIVE_PROFILING: process.env.ENABLE_PROGRESSIVE_PROFILING || false,
MARKETING_EMAILS_OPT_IN: process.env.MARKETING_EMAILS_OPT_IN || true,
MARKETING_EMAILS_OPT_IN: process.env.MARKETING_EMAILS_OPT_IN || '',
ENABLE_COPPA_COMPLIANCE: process.env.ENABLE_COPPA_COMPLIANCE || '',
SHOW_DYNAMIC_PROFILING_PAGE: process.env.SHOW_DYNAMIC_PROFILING_PAGE || false,
ENABLE_DYNAMIC_REGISTRATION_FIELDS: process.env.ENABLE_DYNAMIC_REGISTRATION_FIELDS || false,

View File

@@ -70,13 +70,17 @@ class LoginPage extends React.Component {
}
shouldComponentUpdate(nextProps) {
if (this.props.loginFormData !== nextProps.loginFormData) {
if (nextProps.loginFormData) {
this.setState({
...nextProps.loginFormData,
});
return false;
}
if (nextProps.loginFormData && this.props.loginFormData !== nextProps.loginFormData) {
// Ensuring browser's autofill user credentials get filled and their state persists in the redux store.
const nextState = {
emailOrUsername: nextProps.loginFormData.emailOrUsername || this.state.emailOrUsername,
password: nextProps.loginFormData.password || this.state.password,
};
this.setState({
...nextProps.loginFormData,
...nextState,
});
return false;
}
return true;
}

View File

@@ -120,15 +120,19 @@ class RegistrationPage extends React.Component {
}
shouldComponentUpdate(nextProps) {
if (this.props.registrationFormData !== nextProps.registrationFormData) {
if (nextProps.registrationFormData) {
// do not set focused field's value from redux store to retain entered data in focused field
const { focusedField } = this.state;
const { [focusedField]: _, ...registrationData } = nextProps.registrationFormData;
this.setState({
...registrationData,
});
}
if (nextProps.registrationFormData && this.props.registrationFormData !== nextProps.registrationFormData) {
// Ensuring browser's autofill user credentials get filled and their state persists in the redux store.
const nextState = {
username: nextProps.registrationFormData.username || this.state.username,
password: nextProps.registrationFormData.password || this.state.password,
};
// do not set focused field's value from redux store to retain entered data in focused field\
const { focusedField } = this.state;
const { [focusedField]: _, ...registrationData } = { ...nextProps.registrationFormData, ...nextState };
this.setState({
...registrationData,
});
}
if (this.props.usernameSuggestions.length > 0 && this.state.username === '') {