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

ios keyboard not showing up fix #193

Open
pIyUsH00rAj opened this issue Aug 22, 2022 · 2 comments
Open

ios keyboard not showing up fix #193

pIyUsH00rAj opened this issue Aug 22, 2022 · 2 comments

Comments

@pIyUsH00rAj
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @twotalltotems/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@twotalltotems/react-native-otp-input/dist/index.js b/node_modules/@twotalltotems/react-native-otp-input/dist/index.js
index 71580b8..3d822b8 100644
--- a/node_modules/@twotalltotems/react-native-otp-input/dist/index.js
+++ b/node_modules/@twotalltotems/react-native-otp-input/dist/index.js
@@ -105,7 +105,7 @@ export default class OTPInputView extends Component {
             }
         };
         this.focusField = (index) => {
-            if (index < this.fields.length) {
+            if (index < this.fields.length && this.fields[index]) {
                 this.fields[index].focus();
                 this.setState({
                     selectedIndex: index
@@ -155,7 +155,9 @@ export default class OTPInputView extends Component {
     }
     componentDidMount() {
         this.copyCodeFromClipBoardOnAndroid();
-        this.bringUpKeyBoardIfNeeded();
+        setTimeout(()=>{
+            this.bringUpKeyBoardIfNeeded();
+        },0)
         this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.handleKeyboardDidHide);
     }
     componentWillUnmount() {

This issue body was partially generated by patch-package.

@thiavila-sigma
Copy link

Thank you so much for this patch. It is working perfectly!

It is sad that this awesome library hasn't got any updates in a while, with everything changing for the new arch. I wish I had enough knowledge to keep supporting it.

An extra for anyone reading this post. It works fine with newer IOS devices, but with older devices (even with the newest IOSs) you'll only get a keyboard after you press the input field a thousand times. So here is the fix:

Still in "node_modules/@twotalltotems/react-native-otp-input/dist/index.js" search for onPress and change it for onPressOut. It gets shit done and it prevents from being clicked if you are in a scrollable page.

@timothyerwin
Copy link

this is actually covered in one of the closed tickets...you need to call Keyboard.dismiss() before showing the otp screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants