From 990d6655fe011440dd94366546620b3ea3523dc9 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Tue, 22 Jun 2021 10:09:50 -0700 Subject: [PATCH 1/3] Don't focus input until screen transition has ended --- src/pages/settings/AddSecondaryLoginPage.js | 138 +++++++++++--------- 1 file changed, 77 insertions(+), 61 deletions(-) diff --git a/src/pages/settings/AddSecondaryLoginPage.js b/src/pages/settings/AddSecondaryLoginPage.js index 2e0bf3a35a11..ba3bf3e301fe 100755 --- a/src/pages/settings/AddSecondaryLoginPage.js +++ b/src/pages/settings/AddSecondaryLoginPage.js @@ -68,10 +68,19 @@ class AddSecondaryLoginPage extends Component { this.state = { login: '', password: '', + didScreenTransitionEnd: false, }; this.formType = props.route.params.type; this.submitForm = this.submitForm.bind(this); this.validateForm = this.validateForm.bind(this); + + this.phoneNumberInputRef = null; + } + + componentDidUpdate(prevProps, prevState) { + if (!prevState.didScreenTransitionEnd && this.state.didScreenTransitionEnd) { + this.phoneNumberInputRef.focus(); + } } componentWillUnmount() { @@ -103,68 +112,75 @@ class AddSecondaryLoginPage extends Component { render() { return ( - - Navigation.navigate(ROUTES.SETTINGS_PROFILE)} - onCloseButtonPress={() => Navigation.dismissModal()} - /> - - - {this.props.translate(this.formType === CONST.LOGIN_TYPE.PHONE - ? 'addSecondaryLoginPage.enterPreferredPhoneNumberToSendValidationLink' - : 'addSecondaryLoginPage.enterPreferredEmailToSendValidationLink')} - - - - {this.props.translate(this.formType === CONST.LOGIN_TYPE.PHONE - ? 'common.phoneNumber' - : 'profilePage.emailAddress')} - - this.setState({login})} - autoFocus - keyboardType={this.formType === CONST.LOGIN_TYPE.PHONE - ? CONST.KEYBOARD_TYPE.PHONE_PAD : undefined} - returnKeyType="done" - /> - - - - {this.props.translate('common.password')} - - this.setState({password})} - secureTextEntry - autoCompleteType="password" - textContentType="password" - onSubmitEditing={this.submitForm} + {({didScreenTransitionEnd}) => { + if (didScreenTransitionEnd && !this.state.didScreenTransitionEnd) { + this.setState({didScreenTransitionEnd}); + } + return ( + + Navigation.navigate(ROUTES.SETTINGS_PROFILE)} + onCloseButtonPress={() => Navigation.dismissModal()} /> - - {!_.isEmpty(this.props.user.error) && ( - - {this.props.user.error} - - )} - - -