diff --git a/native/account/registration/password-selection.react.js b/native/account/registration/password-selection.react.js --- a/native/account/registration/password-selection.react.js +++ b/native/account/registration/password-selection.react.js @@ -1,7 +1,9 @@ // @flow import * as React from 'react'; -import { View, Text } from 'react-native'; +import { View, Text, Platform } from 'react-native'; + +import sleep from 'lib/utils/sleep.js'; import RegistrationButtonContainer from './registration-button-container.react.js'; import RegistrationButton from './registration-button.react.js'; @@ -75,6 +77,20 @@ confirmPasswordInputRef.current?.focus(); }, []); + /* eslint-disable react-hooks/rules-of-hooks */ + const passwordInputRef = React.useRef(); + if (Platform.OS === 'android') { + // It's okay to call this hook conditionally because + // the condition is guaranteed to never change + React.useEffect(() => { + (async () => { + await sleep(250); + passwordInputRef.current?.focus(); + })(); + }, []); + } + /* eslint-enable react-hooks/rules-of-hooks */ + return ( @@ -83,13 +99,17 @@ value={password} onChangeText={setPassword} placeholder="Password" - autoFocus={true} + autoFocus={Platform.select({ + android: false, + default: true, + })} secureTextEntry={true} textContentType="newPassword" autoComplete="password-new" returnKeyType="next" onSubmitEditing={focusConfirmPasswordInput} onBlur={potentiallyClearErrors} + ref={passwordInputRef} />