react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

[v4] Dismissing keyboard on Android leaves blank space

Open kierancrown opened this issue 1 year ago • 2 comments

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

  1. Open the example code below on a android device
  2. 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>
  );
};

kierancrown avatar Jun 08 '24 20:06 kierancrown

Hi @kierancrown Were you able to fix the issue and know the root cause of this?

purushottam-e9 avatar Jun 18 '24 08:06 purushottam-e9

@gorhom

purushottam-e9 avatar Jun 18 '24 08:06 purushottam-e9

You might need to use https://ui.gorhom.dev/components/bottom-sheet/components/bottomsheettextinput

psycho-baller avatar Jul 04 '24 21:07 psycho-baller

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.

github-actions[bot] avatar Aug 05 '24 09:08 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Aug 11 '24 09:08 github-actions[bot]

I'm getting this same issue. any solution

krunalinfynno avatar Apr 03 '25 12:04 krunalinfynno

This helped me a lot https://github.com/gorhom/react-native-bottom-sheet/issues/1504#issuecomment-1725661786

Isaccobosio avatar May 12 '25 13:05 Isaccobosio