Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix going back from magic code page after refresh doesn't show the submitted email #30228

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/pages/signin/LoginForm/BaseLoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const propTypes = {
success: PropTypes.string,
}),

/** The credentials of the logged in person */
credentials: PropTypes.shape({
/** The email the user logged in with */
login: PropTypes.string,
}),

/** Props to detect online status */
network: networkPropTypes.isRequired,

Expand All @@ -78,6 +84,7 @@ const propTypes = {

const defaultProps = {
account: {},
credentials: {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
credentials: {},
credentials: {
login: '',
},

NAB: We can set login default value to be empty string.

closeAccount: {},
blurOnSubmit: false,
innerRef: () => {},
Expand All @@ -86,7 +93,10 @@ const defaultProps = {

function LoginForm(props) {
const input = useRef();
const [login, setLogin] = useState('');
const [login, setLogin] = useState(() => {
const userLogin = Str.removeSMSDomain(props.credentials.login || '');
return userLogin;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [login, setLogin] = useState(() => {
const userLogin = Str.removeSMSDomain(props.credentials.login || '');
return userLogin;
});
const [login, setLogin] = useState(() => Str.removeSMSDomain(props.credentials.login));

NAB: Can be simplified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! updated the code!

const [formError, setFormError] = useState(false);
const prevIsVisible = usePrevious(props.isVisible);

Expand Down Expand Up @@ -289,6 +299,7 @@ export default compose(
withNavigationFocus,
withOnyx({
account: {key: ONYXKEYS.ACCOUNT},
credentials: {key: ONYXKEYS.CREDENTIALS},
closeAccount: {key: ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM},
}),
withWindowDimensions,
Expand Down
Loading