Search code examples
androidreact-nativekeyboardautofocus

Keyboard is not opening automatically though autoFocus={true}


I have a TextInput inside a Modal with autoFocus={true}. As soon as Modal is opened TextInput is focused automatically but keyboard is not opening automatically.And surprisingly this is happening randomly. sometimes keyboard opens and sometimes not. This is happening in both emulator and real device.

Any suggestions to overcome this behavior? Thank You.


Solution

  • you can pass focus to TextInput using reference whenever a Modal is visible

    <Modal onShow={() => {this.textInput.focus()}} > 
        <TextInput ref={input => {this.textInput = input}} />
    </Modal>