[v4] Dismissing keyboard on Android leaves blank space
Bug
I'm experiencing an issue where dismissing the keyboard on Android leaves a blank space the size of the keyboard in it's place. I have tried setting the keyboardBlurBehavior to restore but it doesn't seem to make a difference
https://github.com/gorhom/react-native-bottom-sheet/assets/4990483/e8a2497b-1b3c-4c67-81e5-793e8a3c1251
Environment info
| Library | Version |
|---|---|
| @gorhom/bottom-sheet | 4.6.3 |
| react-native | 0.74.1 |
| react-native-reanimated | 3.9.0-rc.1 |
| react-native-gesture-handler | 2.16.0 |
Steps To Reproduce
- Open the example code below on a android device
- dismiss the keyboard
Describe what you expected to happen:
Once keyboard is dismissed the sheet content takes up full space again
Reproducible sample code
As I'm using a navigator I will post the config used here rather than the example snack
Bottom Sheet
<BottomSheet
ref={sheetRef}
index={open ? 0 : -1}
animateOnMount={false}
handleComponent={null}
snapPoints={snapPoints}
keyboardBehavior="extend"
enablePanDownToClose={true}
onChange={handleSheetChanges}
animatedIndex={animatedPosition}
android_keyboardInputMode="adjustResize"
backdropComponent={CustomBackdrop}
backgroundComponent={CustomBackground}
maxDynamicContentSize={SCREEN_HEIGHT - topSafeAreaInset}
onAnimate={(fromIndex, toIndex) => {
if (fromIndex === 0 && toIndex === -1) {
Keyboard.dismiss();
}
}}>
<Navigator />
</BottomSheet>
Navigator
const Navigator: FC = () => {
const theme = useAppTheme();
const forCardPopin: StackCardStyleInterpolator = useCallback(
({current, next}) => {
const progress = current.progress;
const nextProgress = next ? next.progress : undefined;
return {
cardStyle: {
transform: [
{
translateY: progress.interpolate({
inputRange: [0, 1],
outputRange: [theme.spacing.xlY, 0],
}),
},
],
opacity: progress,
backgroundColor: theme.colors.mainBackground,
borderTopLeftRadius: theme.borderRadii.xl,
borderTopRightRadius: theme.borderRadii.xl,
overflow: 'hidden',
},
containerStyle: {
opacity: nextProgress?.interpolate({
inputRange: [0, 1],
outputRange: [1, 0],
}),
},
};
},
[theme],
);
const screenOptions = useMemo<StackNavigationOptions>(
() => ({
headerShown: false,
safeAreaInsets: {top: 0},
cardStyleInterpolator: forCardPopin,
cardStyle: {
backgroundColor: theme.colors.mainBackground,
borderStartStartRadius: theme.borderRadii.xl,
borderStartEndRadius: theme.borderRadii.xl,
overflow: 'hidden',
},
}),
[forCardPopin, theme.borderRadii.xl, theme.colors.mainBackground],
);
return (
<NavigationContainer
ref={navigationRef}
independent={true}
theme={{
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: theme.colors.none,
},
}}>
<Stack.Navigator screenOptions={screenOptions}>
<Stack.Screen name="AskScreen" component={Screen} />
<Stack.Screen name="LocationScreen" component={LocationsScreen} />
<Stack.Screen name="ManageTagsScreen" component={TopicsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
};
Hi @kierancrown Were you able to fix the issue and know the root cause of this?
@gorhom
You might need to use https://ui.gorhom.dev/components/bottom-sheet/components/bottomsheettextinput
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
I'm getting this same issue. any solution
This helped me a lot https://github.com/gorhom/react-native-bottom-sheet/issues/1504#issuecomment-1725661786