tttstudios / react-native-otp-input

Tiny Javascript library which provides an elegant UI for user to input one time passcode.
MIT License
542 stars 243 forks source link

autoFocusOnLoad not automatically bringing up keyboard on iOS #92

Closed sonianigam closed 4 years ago

sonianigam commented 4 years ago

Describe the bug I am implementing a standard phone authentication flow. First I render a TextInput component to collect the phone number, and then I render an OTPInputView to collect the code. The standard TextInput autofocuses, but the OTPInputView does not. I have autoFocusOnLoad in my OTPInputView. I have also tried manually setting a ref and calling focusField(0).

Code

<CodeInput
  ref={this.textInput}
  pinCount={6}
  autoFocusOnLoad
  keyboardType={"phone-pad"}
  codeInputFieldStyle={{
    width: 40,
    height: 40,
    borderWidth: 1,
    borderRadius: 20,
    padding: 0,
    margin: 0,
  }}
  codeInputHighlightStyle={{
    width: 40,
    height: 40,
    borderWidth: 4,
    borderRadius: 20,
    padding: 0,
    margin: 0,
  }}
  onCodeFilled={(code) => {
    this.confirmCode(code);
  }}
/>

To Reproduce Steps to reproduce the behavior:

  1. Enter phone number into TextInput
  2. Click on next arrow
  3. OTPInputView appears but does not autofocus

Expected behavior I expected the OTPInputView to autofocus.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

IMG_3527 IMG_3528

alex-mironov commented 4 years ago

Can someone pls help with this? facing the same issue on iOS

alex-mironov commented 4 years ago

in my case I had to use Keyboard.dismiss()

chengsam commented 3 years ago

In my case I have to dismiss the keyboard on phone number input page then wait for 1 second before going to otp page

Keyboard.dismiss(); setTimeout(() => { navigation.navigate('nextPage'); }, 1000);