-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard covers input when inside a react navigation bottom tab navigator #1424
Comments
Same issue here. Tried all sorts of different things with KeyboardAvoidingView (with each different behaviour and with/without Only thing I found that has helped somewhat is setting Btw, this issue is similar to #1272. |
I was able to fix the issue and close the gap with the following: <GiftedChat
bottomOffset={83}
...
/> and tabBarOptions: {
keyboardHidesTabBar: !(Platform.OS === 'ios')
} |
Yeah I did the same, but that number is good for only a subset of phones. Once you switch to something like an iPad that distance is different and it cuts off half the input. I tried to look into measuring the distance from the bottom dynamically, but there was nothing obvious on react-navigation to do so (discussion about it here https://github.com/react-navigation/tabs/issues/97). Ended up just setting the background to the same color as the input so the extra height didn't look weird. Will circle back to calculating the height when I have some time, or hopefully they realize this a pretty common use case (chat inside a stack inside tabs). |
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> |
Was this resolved? I am also using React Navigation, but I cant get the TextInput to move up with the keyboard. I've gone in and changed the SafeAreaView into KeyboardAvoidingView, that didn't work for me. Is this truly a React Navigation issue? Edit: I managed to get the keyboard to pop up with |
Can confirm this is still an issue with iOS / Expo / gifted chat 0.11.3. Works fine after you start typing but the input is definitely hidden when the keyboard loads initially. |
I am having the same issue, does anyone have an example of a working keyboardavoidingview with Expo? |
|
@mkhoussid adding a This seems to be a focus issue on iOS, the best hack solution I've come up with is to patch into the keyboard show/hide events and then force a toolbar reset, but this isn't as smooth as a native experience should be. We need a proper bug fix on this.
|
@ian No, it's an issue for both mobile OS'. And the linked solution worked just fine for me. Perhaps something else is wrong with your code. Other people experiencing this should try it, not much to lose. Also, try converting your component to a functional component. I've ran into inexplicable issues with class based components in the past, that I couldn't reproduce with functional components. |
@mkhoussid Android working fine, this seems to be an iOS specific issue. This issue is specific to gifted chat when used with |
@ian Yeah, and it was broken on both for me. It's a bug either way, with and without |
I found this solution that does actually work all the way, at least for me, based on this:
EDIT: the bottom solution was incomplete for me, leaving it for posterity I found a temporary solution to this:, react-native-keyboard-spacer:
|
For me, i needed changed behavior="padding" to behavior="height". |
I was able to address the symptoms by applying |
I had this issue when I had a code to hide
|
Just like the other solution, what worked for me was the following:
My target is iOS only I don't know if the code above has a breaking effect on Android. |
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. |
/reopen |
only this solution work for me |
I might have a solution for you, first I'll go over of what I tried. Since I am also using the tab navigation (but I am setting these settings
Where:
Tested with emulators and physical devices and seems to work fine! |
Issue Description
The problem is when
Gifted Chat
is inside of abottom tab navigator
fromreact-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 abottom 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 atab navigator
.Steps to Reproduce / Code Snippets
Expected Results
The input should not be covered by keyboard on focus.
Additional Information
The text was updated successfully, but these errors were encountered: