React-native-gifted-chat: Text box not visible when keyboard active using expo

Created on 26 Dec 2017  路  20Comments  路  Source: FaridSafi/react-native-gifted-chat

Issue Description

Text bot is invisible when keyboard active in android with expo. I'm usingforceGetKeyboardHeight={true} and the message content moves correctly but there is an empty space instead of the textbox.
screenshot_2017-12-26-18-51-19-590_host exp exponent

screenshot_2017-12-26-18-50-57-697_host exp exponent

Steps to Reproduce / Code Snippets

<GiftedChat
        messages={this.state.messages}
        forceGetKeyboardHeight={true}
        onSend={(messages) => this.onSend(messages)}
        user={{
          _id: 1,
        }}
      />

Expected Results

The text box should be visible.

Additional Information

  • Nodejs version: 8.9.3
  • React version: 16.0.0
  • React Native version: expo react native sdk 23.0.0
  • react-native-gifted-chat version: 0.3.0
  • expo version: 23.0.0
  • Platform(s) (iOS, Android, or both?): Tested on android
wontfix

Most helpful comment

I got it.. Just do like this..

 <View  style={{flex:1}}>
          <GiftedChat

            messages={this.state.messages} 
            onSend={messages => this.onSend(messages)}
            user={{
              _id: 1,
            }}
              ></GiftedChat>

            <KeyboardAvoidingView behavior={'padding'} keyboardVerticalOffset={80}/>
        </View>

need to declare flex to parent view to make it works. 馃憤

All 20 comments

And if you remove props forceGetKeyboardHeight?

@xcarpentier Then the screen does not get resized, the view remains the same and keyboard comes over it. I'm was able to fix it by removing the props forceGetKeyboardHeight and using KeyboardSpacer

I had the same issue , but in my case textInputBar was pushing above the keyboard but its view was coming partially.
<KeyboardAvoidingView behavior={'padding'} style={{flex:1}} keyboardVerticalOffset={30}> <ChatBot/> </KeyboardAvoidingView>
fixed my problem.
Here is my component where I have called GiftedChat .
Hope this helps.

Same issue here - also only on Android.

"react": "16.0.0-alpha.12",
"react-native": "0.48.3",
"react-native-gifted-chat": "^0.2.7",

Same with

"expo": "^24.0.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-24.0.0.tar.gz"
(RN 0.52)
"react-native-gifted-chat": "^0.2.7",

`
return (

    messages={ChatsStore.messages.slice()}
    onSend={(messages) => this.onSend(messages)}
    user={{
      _id: UserStore.user.id,
      name: UserStore.user.firstname,
      avatar: UserStore.user.avatar
    }}
  />
);

`

Hello,
Sorry about that.
There are almost 2 solutions to fix it:

@xcarpentier What do you mean by after GiftedChat? Like this:

<View>
        <GiftedChat
          messages={this.state.messages}
          onSend={this.onSend}
          user={{
              _id: 1
            }}
          forceGetKeyboardHeight
        />
      <KeyboardAvoidingView />
</View>

This and wrapping GiftedChat with KeyboardAvoidingView does not fix the issue. I am using:

"expo": "^25.0.0",
"react": "16.2.0",
"react-native": "0.52.0",
"react-native-gifted-chat": "^0.4.3",

Screenshot:

29830005_10156230493205120_1576481157_o

I got it.. Just do like this..

 <View  style={{flex:1}}>
          <GiftedChat

            messages={this.state.messages} 
            onSend={messages => this.onSend(messages)}
            user={{
              _id: 1,
            }}
              ></GiftedChat>

            <KeyboardAvoidingView behavior={'padding'} keyboardVerticalOffset={80}/>
        </View>

need to declare flex to parent view to make it works. 馃憤

@akulah91

I was wondering if you get this issue where the messages disappear when you type things.

Here is my code:

<View style={{ flex: 1 }}>
        <GiftedChat
          messages={this.state.messages}
          onSend={this.onSend}
          user={{
              _id: 1
            }}
          forceGetKeyboardHeight
        />
        <KeyboardAvoidingView behavior="padding" keyboardVerticalOffset={80} />
      </View>

And this is what I mean:

29955176_10156238416510120_1170559467_o

29995019_10156238417015120_559957920_o

CC: @xcarpentier

@watadarkstar that because you put forceGetKeyboardHeight on your code..
I also have that line before but its working well when not use that.

@akulah91 THANK YOU that worked! Life saver!

@watadarkstar most welcome..

I got it.. Just do like this..

 <View  style={{flex:1}}>
          <GiftedChat

            messages={this.state.messages} 
            onSend={messages => this.onSend(messages)}
            user={{
              _id: 1,
            }}
              ></GiftedChat>

            <KeyboardAvoidingView behavior={'padding'} keyboardVerticalOffset={80}/>
        </View>

need to declare flex to parent view to make it works. 馃憤

The code works fine but it adds a padding on iOS, so we have to check which Plaform the app is running, my fix was 馃憞馃従

<View style={{ flex: 1 }}>
        <GiftedChat
          messages={this.state.messages}
          onSend={this.onSend}
          user={{
              _id: 1
            }}

        />
       <KeyboardAvoidingView behavior={ Platform.OS === 'android' ? 'padding' :  null} keyboardVerticalOffset={80} />
      </View>

Its not working for me. I tried using KeyboardAvoidingView but still keyboard overlaps the text input

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Why use 80 ? I must use 190 so that it is clearly visible, Is there not a value that is noted for any device?

Why use 80 ? I must use 190 so that it is clearly visible, Is there not a value that is noted for any device?

yes my friend, i use 150

I use it like this, seems responsive....

                <KeyboardAvoidingView style={{flex: 1}} behavior={"padding"}
                                      keyboardVerticalOffset={Header.HEIGHT + StatusBar.currentHeight} enabled={Platform.OS === 'android'} >
                    <GiftedChat
                        messages={messages}
                        onSend={newMessages => onSend(newMessages)}
                        user=
                            {{
                                _id: 1,
                            }}
                        inverted={false}
                    />
                </KeyboardAvoidingView>

I got it.. Just do like this..

 <View  style={{flex:1}}>
          <GiftedChat

            messages={this.state.messages} 
            onSend={messages => this.onSend(messages)}
            user={{
              _id: 1,
            }}
              ></GiftedChat>

            <KeyboardAvoidingView behavior={'padding'} keyboardVerticalOffset={80}/>
        </View>

need to declare flex to parent view to make it works. 馃憤

thanks, worked form the first

forceGetKeyboardHeight will move messgeArray up

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonwcfan picture jasonwcfan  路  3Comments

luisar picture luisar  路  3Comments

arayaryoma picture arayaryoma  路  3Comments

inceptivetech picture inceptivetech  路  3Comments

pentarex picture pentarex  路  3Comments