Compatibility with react-native-bottom-sheet? #309
Replies: 3 comments 7 replies
-
Hello @junchenjun and sorry for long response 🙂
I think it could be cause because of async nature of switching on/off module. Basically I'm updating a state variable (async operation), then I update a prop of native view via bridge (also async operation). So I assume if during these updates you show keyboard/modal it can cause glitches 😔
Because once you wrapped your app in
The one way is yes, disabling/enabling the module per specific screens (bottom sheet modal in your case). I don't have a lot of experience with bottom sheets modals, but can't you handle keyboard appearance on your own? For example apply |
Beta Was this translation helpful? Give feedback.
-
Hey everyone! I have been having the same issue with the '@gorhom/bottom-sheet' library for a while now and I think I figured out a way to get this to work on both platforms very consistently. Below is a custom component I created called import { SCROLLABLE_TYPE, createBottomSheetScrollableComponent, type BottomSheetScrollViewMethods } from '@gorhom/bottom-sheet';
import type { BottomSheetScrollViewProps } from '@gorhom/bottom-sheet/src/components/bottomSheetScrollable/types';
import { memo } from 'react';
import { ScrollViewProps as RNScrollViewProps } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
import Animated from 'react-native-reanimated';
type KeyboardAwareScrollViewProps = {
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
bottomOffset?: number;
/** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */
disableScrollOnKeyboardHide?: boolean;
/** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */
enabled?: boolean;
} & RNScrollViewProps;
const AnimatedScrollView = Animated.createAnimatedComponent<KeyboardAwareScrollViewProps>(KeyboardAwareScrollView);
const BottomSheetScrollViewComponent = createBottomSheetScrollableComponent<BottomSheetScrollViewMethods, BottomSheetScrollViewProps>(SCROLLABLE_TYPE.SCROLLVIEW, AnimatedScrollView);
const BottomSheetScrollViewWithKeyboardHandling = memo(BottomSheetScrollViewComponent);
BottomSheetScrollViewWithKeyboardHandling.displayName = 'BottomSheetScrollViewWithKeyboardHandling';
export default BottomSheetScrollViewWithKeyboardHandling as (props: BottomSheetScrollViewProps) => ReturnType<typeof BottomSheetScrollViewWithKeyboardHandling>; The consume it like this (should be able to use all the same props on import BottomSheet from '@gorhom/bottom-sheet';
import BottomSheetScrollViewWithKeyboardHandling from './BottomSheetScrollViewWithKeyboardHandling';
export function Example() {
return (
<BottomSheet>
<BottomSheetScrollViewWithKeyboardHandling>
{/* More content here*/}
</BottomSheetScrollViewWithKeyboardHandling>
</BottomSheet>
);
} Some of the types weren't being exported so I either recreated them here or tried to find it in Looking at the source code for both they are very very close to full compatibility without this and when I saw the Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
A lot of fixes/integrations landed since the time when discussion was created. I believe now If you discover any issue, then please open a new issue ❤️ I'll close this discussion. |
Beta Was this translation helpful? Give feedback.
-
Specifically with the bottom sheet modal from react-native-bottom-sheet
When KeyboardProvider is enabled, it breaks keyboard behaviour in the bottom sheet modal.
The bottom sheet uses the default Android behaviour to push the whole modal above the keyboard. When KeyboardProvider is enabled, the modal no longer gets pushed up.
I use the suggested keyboard handling method for the bottom sheet modal.
Right now I am disabling KeyboardProvider by default and only enabling it on certain pages(If I do it the other way around, it causes an animation glitch when the modal opens up), which is not ideal because I have to write lots of code to disable/enable it.
Anyway just wondering if anyone has encountered the issues or did I miss anything?
Love this library btw
Beta Was this translation helpful? Give feedback.
All reactions