gorhom / react-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options 🚀
https://ui.gorhom.dev/components/bottom-sheet
MIT License
6.66k stars 740 forks source link

[v4] Too small snappoint leads to crash when keyboard appers #1890

Open MilewskiMateo opened 1 month ago

MilewskiMateo commented 1 month ago

Bug

This bug occurs when the snap point is set to a small value and opening the keyboard crashes the entire modal. The error only occurs on Android; it works fine on iOS. In my case, the snap point is set to 240, and it crashes. However, if I set it to 340, the keyboard pops up correctly. I also tried changing the keyboardBehavior parameter, but it didn't help.

Environment info

Library Version
@gorhom/bottom-sheet 4.6.3
react-native 0.74.2
react-native-reanimated 3.12.1
react-native-gesture-handler 2.16.2

Steps To Reproduce

  1. Install the above libraries in a React Native project.
  2. Configure the BottomSheetModal component with snapPoints set to 240.
  3. Open the modal and try to open the keyboard (e.g., by clicking on a text input).
  4. Notice that the modal crashes the application on Android.

Describe what you expected to happen:

  1. The modal should work correctly when the keyboard is opened, as it does on iOS.
  2. The modal should not crash the application.

Reproducible sample code

import React, { useRef } from 'react';
import { View, TextInput, Button } from 'react-native';
import { BottomSheetModal } from '@gorhom/bottom-sheet';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

const App = () => {
  const bottomSheetModalRef = useRef(null);

  const handlePresentModalPress = () => {
    bottomSheetModalRef.current?.present();
  };

  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <Button title="Open Bottom Sheet" onPress={handlePresentModalPress} />
      <BottomSheetModal
        handleComponent={null}
        backdropComponent={null}
        enableContentPanningGesture={false}
        enableHandlePanningGesture={false}
        ref={bottomSheetModalRef}
        snapPoints={[240]}
        backgroundStyle={{
          borderRadius: 24,
        }}
      >
        <View style={{ padding: 20 }}>
          <TextInput placeholder="Type here..." style={{ borderWidth: 1, padding: 10 }} />
        </View>
      </BottomSheetModal>
    </GestureHandlerRootView>
  );
};

export default App;

https://github.com/user-attachments/assets/7ed7679b-d1c2-481d-9083-6a8ef969761b

ryzencool commented 1 month ago

I also encountered this bug.

bezxc commented 4 weeks ago

Same issue (

Adelkkaa commented 4 weeks ago

Any issue (

webRuslanZ commented 4 weeks ago

Any issue (

ezranbayantemur commented 2 weeks ago

Same here. Any update?