React-native-gifted-chat: Keyboard height on iOS

Created on 31 Jul 2016  路  16Comments  路  Source: FaridSafi/react-native-gifted-chat

First: congrats on the release of the new component! Looks like a huge improvement over gifted-messenger!

I'm having trouble with the keyboard leaving a gap (same height as my navbar it seems):

schermafbeelding 2016-07-31 om 15 24 17

schermafbeelding 2016-07-31 om 15 24 25

Any idea on how to fix this? (The navigation I'm using is react-native-navigation)

Thanks

Most helpful comment

I added bottomOffset prop in 0.0.6
You need to set the distance from the bottom of the screen

<GiftedChat bottomOffset={56} />

All 16 comments

Hello @TimBroddin,
Does your GiftedChat container has a paddingBottom ? If yes try to switch to a marginBottom

Hi @FaridSafi,

You are quick. No it doesn't, but it's wrapped inside a Navigator that's wrapped inside a TabView.

Thanks!

schermafbeelding 2016-07-31 om 15 37 44

What if you wrap GiftedChat inside a <View style={{flex: 1}} /> ?
I tried to set up the react-native-navigation example but it's in RN 0.25.1

I will need a code sample to help you more

same here. Mine is RN 0.28.0. Keyboard size is about the same as the one above.

@ssmlee04 do you use react-native-navigation?

Can you share part of your code guys please? An example that I can run

I used <TabBarIOS> and a <AdMobBanner>. And it seems the extra height equals to the sum of the two's height. I'll see if I can come up with something minimum.

@ssmlee04 Did you try to wrap GiftedChat inside a <View style={{flex: 1}} /> ?

@FaridSafi I'll try to make an example repo tonight

@TimBroddin I can reproduce the issue, I will fix it

Sorry it took so long @FaridSafi, I made an example repository: https://github.com/TimBroddin/gifted-chat-keyboard-bug

Thanks for all the hard work!

I added bottomOffset prop in 0.0.6
You need to set the distance from the bottom of the screen

<GiftedChat bottomOffset={56} />

Works, thanks a lot @FaridSafi!

Hi @FaridSafi , thanks for the component and for adding the bottomOffset property.

We were having the same issue as @TimBroddin and tried the fix using the bottomOffset property. As expected the bottomOffset is applied when opening the keyboard, and isn't applied when closing the keyboard. In my case it unfortunately is applied on the initial render with the keyboard closed, as the _onType_ method gets called. This leads to the text input being pushed below the tabbar.

See https://github.com/FaridSafi/react-native-gifted-chat/pull/187 for my pull request

Unfortunately I couldn't get the example repo at https://github.com/TimBroddin/gifted-chat-keyboard-bug to work, to validate that the same issue holds there.

Thanks @FaridSafi. bottomOffset can work. was carried away doing something.

Hi @FaridSafi, the bottomOffset property doesn't help when the textbox is hidden initially.

I'm using RN 0.32.1, navigator experimental and TabBarIOS. The chat input box is being hidden by the tab bar.

My render method:

render() {
    return (
      <View style={{flex: 1}}>
        <GiftedChat
          messages={this.state.messages}
          onSend={this.onSend}
          loadEarlier={this.state.loadEarlier}
          user={{
            _id: this.state.id,
            name: this.props.result.first_name,
            avatar: this.props.result.picture,
          }}
          renderBubble={this.renderBubble}
          renderFooter={this.renderFooter}
          bottomOffset={56} 
        />
      </View>
    )
  }

The output I see on my iPhone 6s+ simulator:

screen shot 2016-09-11 at 2 16 28 pm

submitted a new issue: #232

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SytzeAndr picture SytzeAndr  路  3Comments

yazhengwang picture yazhengwang  路  3Comments

radvc picture radvc  路  3Comments

arayaryoma picture arayaryoma  路  3Comments

cerberusv2px picture cerberusv2px  路  3Comments