question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to avoid keyboard for bottom half modal

See original GitHub issue

Let’s say we have a bottom half modal with some TextInput. How can we avoid the keyboard? I’ve tried KeyboardAvoidingView and it did nothing.

CC @mmazzarolo.

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:23
  • Comments:44 (7 by maintainers)

github_iconTop GitHub Comments

141reactions
fredrivettcommented, Sep 17, 2018

FWIW for those coming from Google, I solved this by using a nested KeyboardAvoidingView inside my Modal (the avoidKeyboard mentioned above in v4 didn’t work for me).

<Modal>
  <KeyboardAvoidingView
    behavior="position"
    enabled
  >
    {myContent}
  </KeyboardAvoidingView>
</Modal>

Note: behaviour="position", this didn’t work when using padding for me.

35reactions
0xleeakicommented, Nov 13, 2020

Hey, you can try using “behavior={Platform.OS === “android” ? undefined : “position”}”

<Modal
        isVisible={showCoupon}>
        <KeyboardAvoidingView enabled  behavior={Platform.OS === "android" ? undefined : "position"}>
          <ScrollView scrollEnabled={false} keyboardShouldPersistTaps="handled">
          <View style={[styles.modalContent, { flex: 1 }]}>
          </View>
        </ScrollView>
        </KeyboardAvoidingView>
</Modal>

For Style:

modalContainer: {
    justifyContent: 'flex-end'
  },
  modalContent: {
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

In React Native, How Can I Use KeyboardAvoidingView with a ...
I am having trouble getting a KeyboardAvoidingView to work in iOS, specifically when wrapping a Modal in it. Testing in ...
Read more >
How to create a modal like this. Where the keyboard doesn't ...
How to create a modal like this. Where the keyboard doesn't disrupts the view. ... Is there a way to avoid monolith React...
Read more >
Prevent the On-screen Keyboard from Covering up Text Inputs
[00:34] First, make sure it fills the entire screen by setting a flex one style prop. Then we'll replace the main container view...
Read more >
Avoid Keyboard in React Native Like a Pro - Netguru
Learn how to make text fields accessible with visible keyboard in React Native apps based on keyboard avoiding view, keyboard events and ...
Read more >
react native modal keyboard avoiding - You.com
NOTE: You may need to adjust the offset prop of KeyboardAvoidingView if the keyboard has got autocomplete enabled. Stick button at the bottom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found