react-native-modalize icon indicating copy to clipboard operation
react-native-modalize copied to clipboard

Keyboard Avoiding View not working on both iOS and Android

Open shridhar52war opened this issue 4 years ago • 10 comments

Describe the bug KeyboardAvodingView is not working for both platforms with TextInput

Dependencies:

  • react-native-modalize-2.0.5
  • react-native-0.61.5
  • react-native-gesture-handler - 1.7.0

Sharing code snippet here:

<SafeAreaView style={{ flex: 1}}>
  <Button onClick={() => {
    modalizeRef.current.open();
  }}></Button>
  <Modalize
    ref={modalizeRef}
    snapPoint={300}
    panGestureComponentEnabled
    avoidKeyboardLikeIOS={true}
    HeaderComponent={
      <View style={{ padding: 30 }}>
        <Text>Header</Text>
      </View>
    }
  >
    <View
      style={{
        padding: 20,
      }}
    >
      <View style={{ paddingVertical: 20 }}>
        <TextInput placeholder="Write something here" />
      </View>
    </View>
  </Modalize>
</SafeAreaView>

shridhar52war avatar Aug 17 '20 10:08 shridhar52war

I've got this working by using the keyboardAvoidingOffset prop.

I removed all height props and used keyboardAvoidingOffset={100}.

<Modalize
      disableScrollIfPossible
      adjustToContentHeight
      keyboardAvoidingOffset={100}
      scrollViewProps={{ keyboardShouldPersistTaps: 'handled' }}
    >

image

Cookizza avatar Aug 24 '20 00:08 Cookizza

@shridhar52war try this, it worked for me

 <Modalize
    ref={modalizeRef}
    adjustToContentHeight
  >

ViniCleFer avatar Oct 14 '20 12:10 ViniCleFer

@ViniCleFer did this work on android too?

algokano avatar Mar 16 '21 11:03 algokano

@Sarvarr i don't remember, but try it and tell me, please.

I think yes.

ViniCleFer avatar Mar 16 '21 11:03 ViniCleFer

@ViniCleFer when i enable adjustToContentHeight the content is not scrolling on android. disableScrollIfPossible={false} i added this line and it worked for me #219

algokano avatar Mar 16 '21 17:03 algokano

@shridhar52war try this, it worked for me

 <Modalize
    ref={modalizeRef}
    adjustToContentHeight
  >

That's not really fixing the problem. He's explicitly using snapPoint, which gets canceled by adjustToContentHeight, so I assume he wants the keyboard avoiding behavior by interacting with the text input while the modal is not fully opened (aka. on the snap point).

I can confirm that on iOS the keyboard avoiding is not working with snapPoint while using the flatlist renderer.

Adding adjustToContentHeight defeats the purpose of snapPoint while making the modal unscrollable at the moment.

Do we have any updates on this one @jeremybarbet ?

teuscm avatar Apr 06 '21 00:04 teuscm

Facing an issue with the keyboard avoiding view as well where the keyboard lands right on top of the list of results (as you can see my modal is opened at 65% of the screen from bottom to top). I have:

    <Modalize
      alwaysOpen={shouldStayOpen ? 100 : 0}
      handlePosition="inside"
      HeaderComponent={() => (
        <CustomHeaders handleCancel={handleForceClose} />
      )}
      keyboardAvoidingBehavior="padding"
      modalHeight={(Layout.window.height * 65) / 100}
      onClose={handleOnClose}
      onOpen={handleOnOpen}
      overlayStyle={modalizeStyle}
      ref={combinedRef}
      scrollViewProps={{
        scrollEnabled: currentStep < 2
      }}
    >
      {renderContent()}
    </Modalize>

manuelxaguilar avatar Apr 23 '21 00:04 manuelxaguilar

same issue. any update on this one?

carissacks avatar Jun 07 '21 07:06 carissacks

Any update about this?

wdospinal avatar Jul 28 '21 15:07 wdospinal

@shridhar52war try this, it worked for me

 <Modalize
    ref={modalizeRef}
    adjustToContentHeight
  >

Worked for me! Thanks

mateuscesarglima avatar Apr 01 '24 02:04 mateuscesarglima