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.

Keyboard covers input when inside a react navigation bottom tab navigator

See original GitHub issue

Issue Description

The problem is when Gifted Chat is inside of a bottom tab navigator from react-navigation when I first focus the message box the keyboard covers the text input. Once I type the first letter the text input comes into view with the correct positioning.

This only happens when the GiftedChat component is inside a bottom tab navigator. Everything works fine when the chat component is inside ONLY a stack navigator. It breaks again if inside a stack navigator nested inside a tab navigator.

ezgif com-video-to-gif

Steps to Reproduce / Code Snippets

import { View } from 'react-native';
import { GiftedChat } from 'react-native-gifted-chat';
import { createAppContainer } from 'react-navigation';
import { createBottomTabNavigator } from 'react-navigation-tabs';

function ThreadScreen() {
  return (
    <View style={{ flex: 1, backgroundColor: 'red' }}>
      <GiftedChat
        messages={[]}
        user={{
          _id: 1,
        }}
        onSend={() => {}}
      />
    </View>
  );
}

const Navigator = createAppContainer(
  createBottomTabNavigator({
    Thread: {
      screen: ThreadScreen,
    },
  })
);

function App() {
  return <Navigator />;
}

export default App;

Expected Results

The input should not be covered by keyboard on focus.

Additional Information

  • Nodejs version: 8.16.1
  • React version: 16.9.0
  • React Native version: 0.61.1
  • react-native-gifted-chat version: 0.10.1
  • Platform(s) (iOS, Android, or both?): iOS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:21

github_iconTop GitHub Comments

10reactions
woodcockjoshcommented, Dec 29, 2020

/reopen

5reactions
partiellkorrektcommented, Oct 9, 2019

I am measuring the height of the Bottom TabBar in the following way:

Add hooks to the render-function:

const [bottomOffset, setBottomOffset] = useState(0)
const wrapper = useRef<View>()
const handleLayout = useCallback(() => {
  wrapper.current && wrapper.current.measureInWindow((_x: number, y: number, _width: number, height: number): void => {
    const nextBottomOffset = Dimensions.get('window').height - y - height
    setBottomOffset(nextBottomOffset)
  })
}, [])

And then wrap GiftedChat like this:

<View style={{ flex: 1 }} onLayout={handleLayout} ref={wrapper}>
  <GiftedChat
    bottomOffset={bottomOffset}
    {...chatProps}
  />
</View>
Read more comments on GitHub >

github_iconTop Results From Across the Web

React native bottom tab bar pushing itself up when opening ...
by doing this, the bottom navigator was staying hidden behind the keyboard. however, the ScrollView containing TextInputs was not working ...
Read more >
Hiding tab bar in specific screens - React Navigation
Sometimes we may want to hide the tab bar in specific screens in a stack navigator nested in a tab navigator. Let's say...
Read more >
ios keyboard covers the input which is located in the bottom of ...
Coding example for the question ios keyboard covers the input which is located in the bottom of the screen-React Native.
Read more >
How to dismiss keyboard with react-navigation in React Native ...
TextInput inside ScrollView# · 'never' (the default), tapping outside of the focused text input when the keyboard is up dismisses the keyboard.
Read more >
Avoid Keyboard in React Native Like a Pro - Netguru
Screens with react-native-keyboard-manager and react-native-avoid-softinput are handling keyboard with similar effect - single line input's ...
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