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
A gap between text input and keyboard on iOS #1306
Comments
It looks to be happening when the keyboard changes it's side - when the auto correct component vanishes, the keyboard does not re-adjust which causes the GiftedChat component not to cover the entire screen leaving this gap Edit: It seems to happen on iPhone XR and X, on iPhone 6, 8 it works perfectly, I suspect it might have something to do with the SafeAreaView |
I am having this same issue and am using SafeAreaView. Tested on my Xs max. |
I had a similar issue at #1294 i marked it as closed, but now with the new updates it happens again, even using that patch, any idea @xcarpentier ? |
It seems if you add "renderInputToolbar" prop, and only return |
@Ariavm95 Hi, thank you for the advice, but it doesn't help |
any workaround here ? something is really wrong with the layout |
yes putting autoCorrect: false fixed the problem temporarily, but it's an annoying compromise though, sometimes also on some refresh, it gets broken again, not sure what's the behaviour here |
bottomOffset={50} works so far for me. #1202 |
I found this happens even on the latest version (0.11.2). It seems most likely to happen if I navigate to my chat screen, lock the phone, and then unlock it. It went away when I commented out the iPhone X logic to get around the home bar found at react-native-gifted-chat/src/GiftedChat.tsx Line 563 in e4576d4
I'm of the opinion that home bar/ notch avoidance is so contextual that I prefer component libraries to not handle it and leave it to the implementing developer. In my case, I have a tab bar showing at the bottom sometimes that already needs to avoid the home bar. I understand that having it in there may be more friendly for some, though, and may be more in line with the goals of the library. @xcarpentier I'd be happy to put in a pull request to fix, but want to do it in a way that's consistent with your outlook on this. I could see removing the iPhone X logic entirely, or leaving it on by default but providing a flag for users to turn it off. |
Just wanted to share that this is what worked for me: import { Dimensions, Platform } from 'react-native';
function isIphoneX() {
const dimen = Dimensions.get("window");
return (
Platform.OS === "ios" &&
!Platform.isPad &&
!Platform.isTVOS &&
(dimen.height === 812 ||
dimen.width === 812 ||
(dimen.height === 896 || dimen.width === 896))
);
} from npm package react-native-iphone-x-helper. No clue why those numbers are the ones that work. The size of the gap seems linear with the distance from those numbers for me. Edit: I'm also using SafeAreaView as the top level component of my app. |
In my case the problem was the bottom tab navigator ,,, when i removed it ,, everything worked perfectly |
@ZaidAbo same here, I used the |
The same thing @nadav2051 describes still happens to me in 0.13.0 - ios. removed the tab bar. did anyone find a workaround ?
|
I don't quite understand these lines of code and they might be the culprit for some people.
https://github.com/FaridSafi/react-native-gifted-chat/blob/master/src/GiftedChat.tsx#L589 Why is it being set to 33? The first render will leave my custom Also, I don't see any possible workaround as this is internally handled. Removing these lines fixes the issue for me. Also, I'm not sending a PR for this as I'm still uncertain why this was added. thoughts? |
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. |
Can you help explain the purpose of this change? https://github.com/FaridSafi/react-native-gifted-chat/blob/master/src/GiftedChat.tsx#L589 |
You can hide your keyboard each time your app is going to background by using this code:
But this is temporary hack! I think that GiftedChat should not ignore bottomOffset that developer passes to it. Or it should have to bottomOffsets: bottomOffset and bottomOffsetX, and if developer passes only bottomOffset, than summarise bottomOffset and 33, if there is bottomOffsetX to use only it. |
I am also having the same issue as @abdielou. the bottomOffset toggles between what I have set and 33 |
I currently have this to add to bottomOffset: export const CHAT_BOTTOM_OFFSET = () => {
// When the keyboard opens, there seems to be a gap at the bottom of the input on iOS
// We hide the bottomTabBar when the keyboard opens, the gap is the same height
//
// C.getStatusBarHeight(C.isIphoneX() -> iPhoneX 44 / iPhone8 20
//
// When coming back into the app when focused on the input on iPhoneX only there is a problem
if (Platform.OS === 'ios') {
if (isIphoneX()) {
return getStatusBarHeight(isIphoneX()) + MIN_COMPOSER_HEIGHT; // iPhoneX = (44+33)=77
} else {
return HEADER_BAR_HEIGHT; // 44
}
}
if (Platform.OS === 'android') return 0;
return 0;
}; as well as: // https://github.com/FaridSafi/react-native-gifted-chat/issues/1306#issuecomment-591956022
const dismissKeyboardOnBackground = nextAppState => {
if (nextAppState.match(/inactive|background/)) {
// Close keyboard when the app goes into the background to fix an issue on iPhoneX where the bottomOffset is not being applied and whitespace added to the bottom.
Keyboard.dismiss();
}
};
useEffect(() => {
AppState.addEventListener('change', dismissKeyboardOnBackground);
return () => {
AppState.removeEventListener('change', dismissKeyboardOnBackground);
};
}, []); It seems to have resolved the problem but it's hurting my soul. |
Hey guys. I did this in order to support devices with Notch. I see some of you are adding the GiftedChat component as a BottomTabNavigator component and in which you are not contemplating the height of the BottomTabNavigator, which by default in react-navigation is 50
Then not to contemplate it, you must add bottomOffset = DEFAULT_TABBAR_HEIGHT + Height of SafeAreaView The height of SafeAreaView can be taken out in this way if
and this library is already installed with react-navigation so you can access it without having to reinstall it if not, you can do this:
|
thanks but getInset is gone from the 'react-native-safe-area-view' and this library was not installed with react-navigation 5
|
This worked for me. I set a const for footerHeight that I pass to my navigation logic, and then use it as apart of the input offset:
|
The bug still appears randomly.
And in your giftedchat set bottomOffset like this
And for react-navigation 5 after searching alot I used DEFAULT_TABBAR_HEIGHT = 49 instead of 50 now so far it's not appeared again. |
Try the new version. I supplied a fix for that which should cover the issue. |
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. |
@hirbod Can you reference this issue in your fix? |
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. |
In case others find this with a similar issue, the commit @abdielou was asking about is here: Unfortunately, I'm still having an occasional issue where multiple keyboardWillShow events are detected by GiftedChat even if the keyboard is already open. This can happen if the user starts typing and then hits the input bar again. This sets the internal |
I'm solving this by setting |
For someone who uses import { useSafeAreaInsets } from "react-native-safe-area-context";
function App() {
const insets = useSafeAreaInsets();
return (
<GiftedChat
// ...
bottomOffset={insets.bottom}
/>
)
} |
If you have a bottom tab navigator, then this might be a useful solution.
|
and
|
@irodeanu Thank you. This is the answer that works best for me. Also eliminated a random empty gap at the top of the gifted chat component and my header. |
…bottomTabsBarNavigation FaridSafi/react-native-gifted-chat#1306 Used fix by sumanbhattarai
Issue Description
There is a gap between input text and keyboard on iOS. I tried to fix it with bottomOffset, but it didn't help.
Steps to Reproduce / Code Snippets
https://pastebin.com/pAJz5W2C
https://pastebin.com/RGCWP2JL
https://ibb.co/09NTN9Q
Expected Results
There shouldn't be nay gaps.
Additional Information
The text was updated successfully, but these errors were encountered: