BottomSheetTextInput that has multiline enabled, does not push bottom sheet up when focused and keyboard shows.
See original GitHub issueBug
BottomSheetTextInput that has multiline enabled, does not push bottom sheet up when focused and keyboard shows. If I remove the ability to have multiline enabled, it works as expected with no issue.
Environment info
Library | Version |
---|---|
@gorhom/bottom-sheet | “^3.6.3” |
react-native | “0.63.4” |
react-native-reanimated | “^2.0.0” |
react-native-gesture-handler | “^1.9.0” |
Steps To Reproduce
Setting up a simple implementation of the BottomSheetModal
will show how it behaves.
- Make one
BottomSheetTextInput
have multiline while the other does not. - Tap the one without
multiline
to see it function correctly. - Tap the one with
multiline
to see it does not slide up the bottom sheet.
Describe what you expected to happen:
- Keyboard should push up the bottom sheet when using
BottomSheetTextInput
withmultiline
enabled.
Reproducible sample code
Note: This is inside a wrapper component that just has data/state management with a View
with the style {{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
.
import React, { useContext, useMemo, useRef } from 'react';
import { StyleSheet, ScrollView, TouchableOpacity, Platform } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useNavigation } from '@react-navigation/core';
import {
BottomSheetModal,
BottomSheetModalProvider,
BottomSheetBackdrop,
BottomSheetTextInput,
BottomSheetScrollView,
} from '@gorhom/bottom-sheet';
import { Text } from '../components/common/Text';
import { View } from '../components/common/View';
import { Button } from '../components/common/Button';
import { ReorderIcon } from '../assets/svg/ReorderIcon';
import { ACTIVE_OPACITY } from '../constants';
import { localizedStrings } from '../localization/localizedStrings';
import { colors, globalStyles, SCREEN_HEIGHT, SCREEN_WIDTH } from '../styles/globalStyles';
import { GradientFooter } from '../components/common/GradientFooter';
import { HorizontalLine } from '../components/common/HorizontalLine';
export const ListScreen: React.FC<{}> = () => {
const { top, bottom } = useSafeAreaInsets();
const { goBack } = useNavigation();
const buttonMargin = Platform.OS === 'ios' ? bottom - 8 : bottom + 16;
const sheetRef = useRef<BottomSheetModal>(null);
const snapPoints = useMemo(() => ['35%'], []);
const handleShowPress = () => {
sheetRef.current && sheetRef.current.present();
};
return (
<>
<ScrollView
style={[styles.container, { paddingTop: top + globalStyles.standardPadding * 2 }]}
>
<View style={styles.header}>
<TouchableOpacity
// TODO re-order feature
onPress={() => {}}
activeOpacity={ACTIVE_OPACITY}
style={styles.rightAlign}
>
<ReorderIcon />
</TouchableOpacity>
<View style={styles.center}>
<View style={styles.button} marginVertical={globalStyles.screenPadding}>
<Button
fontSize={14}
title={'+ Add to List'}
onPress={handleShowPress}
/>
</View>
</View>
</View>
</ScrollView>
<GradientFooter style={styles.center}>
<TouchableOpacity
hitSlop={{ left: 30, right: 30 }}
activeOpacity={ACTIVE_OPACITY}
onPress={goBack}
>
<Text fontSize={14} style={{ marginTop: buttonMargin }} fontFamily="americaBold">
{localizedStrings.labels.back}
</Text>
</TouchableOpacity>
</GradientFooter>
<BottomSheetModalProvider>
<BottomSheetModal
ref={sheetRef}
snapPoints={snapPoints}
keyboardBehavior="interactive"
keyboardBlurBehavior="restore"
handleComponent={null}
backdropComponent={BottomSheetBackdrop}
style={{ ...globalStyles.shadow }}
>
<BottomSheetScrollView style={[styles.cardContent, { paddingBottom: bottom * 4 }]}>
<BottomSheetTextInput
placeholder="Add title"
placeholderTextColor={colors.grey}
style={styles.text}
accessibilityComponentType
accessibilityTraits
/>
<HorizontalLine width={'100%'} />
<BottomSheetTextInput
placeholder="Add more details"
placeholderTextColor={colors.grey}
style={styles.text}
multiline
accessibilityComponentType
accessibilityTraits
/>
</BottomSheetScrollView>
</BottomSheetModal>
</BottomSheetModalProvider>
</>
);
};
const styles = StyleSheet.create({
absolute: {
position: 'absolute',
},
bottom: {
...globalStyles.shadow,
paddingTop: globalStyles.standardPadding,
padding: globalStyles.screenPadding,
},
button: {
width: 170,
},
cardContent: {
padding: globalStyles.screenPadding,
},
center: {
alignItems: 'center',
justifyContent: 'center',
},
container: {
flex: 1,
},
header: {
paddingHorizontal: globalStyles.screenPadding,
},
image: {
width: '100%',
position: 'absolute',
},
rightAlign: {
alignSelf: 'flex-end',
},
text: {
paddingVertical: globalStyles.standardPadding * 2,
},
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:16 (1 by maintainers)
Top Results From Across the Web
How to Move bottomsheet along with keyboard which has ...
To fix this issue. Add isScrollControlled = true to BottomSheetDialog it'll allow the bottom sheet to take the full required height which gives...
Read more >Keyboard Handling | React Native Bottom Sheet - GitHub Pages
To handle the keyboard appearance, I have simplified the approach by creating a pre-integrated TextInput called BottomSheetTextInput, which communicate ...
Read more >react native modal keyboard avoiding - You.com
When the Text Input is focused, the keyboard is brought up and you can see a white are which is pushing all of...
Read more >react-spring-bottom-sheet - npm
A react ref to the element you want to get keyboard focus when opening. If not provided it's automatically selecting the first interactive ......
Read more >Avoid Keyboard in React Native Like a Pro - Netguru
In addition, when multiline input is focused, it is pushed up even when it ... In the bottom sheet example, BottomSheetModal component from ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi everyone, sorry for the delay, this issue is resolved for
v4
and it will release on4.0.0-alpha.25
👍Any update on BottomSheetTextInput with multiline?