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

[Bug][Android]: Conflict with react-native-modal when Fabric/new architecture enabled

Open Dat-Mobile opened this issue 10 months ago • 27 comments

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

Android

What happened?

The modal shows up with blank background and its children are collapsed I already created the bug but it was marked as invalid https://github.com/gorhom/react-native-bottom-sheet/issues/2166

Reproduction steps

Place both components in the same screen then the issue happen:

import Modal from "react-native-modal"; import BottomSheet, {...} from "@gorhom/bottom-sheet";

This issue only happen if:

  • New architecture enabled
  • On Android, both debug and release
  • (react-native-modal) and in the same screen

Here's the button I press to open the react-native-modal:

Then the modal shows up with blank background and its children are collapsed

When I remove from the screen, the works fine again

Reproduction sample

https://snack.expo.dev/@liudmyla.chubar/drag-down-issue

Relevant log output

Reproduction sample above is not of the issue!!
I only use it so that the issue won't marked as invalid

Dat-Mobile avatar Feb 17 '25 16:02 Dat-Mobile

Same issue but with Modal directly from react-native.

nemoneph avatar Feb 23 '25 16:02 nemoneph

I am also seeing this issue when trying to use Modal from 'react-native' in combination with BottomSheet from '@gorhom/bottom-sheet' (v5.1.1).

My app has a FlashList with items. A BottomSheet containing a BottomSheetScrollView is used to show filtering options for the list. With new arch disabled, clicking an item in the list opens the modal as expected. When creating a new build with new arch enabled, clicking an item will not show the modal content, but makes the the screen unresponsive to any input. So some kind of overlay is rendered, but the modal itself is not visible.

Whenever I remove the BottomSheet from the view everything is working as expected.

This issue is blocking me from moving to new arch.

rklomp avatar Mar 03 '25 09:03 rklomp

any solution ?

danish5454 avatar Mar 14 '25 16:03 danish5454

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 Apr 14 '25 09:04 github-actions[bot]

Still an issue

rklomp avatar Apr 14 '25 11:04 rklomp

This issue still happens with React Native 0.78.2

thanhcuong1990 avatar Apr 15 '25 06:04 thanhcuong1990

@thanhcuong1990 RN 0.76.3 is also experiencing the same issue.

danish5454 avatar Apr 15 '25 07:04 danish5454

clean your keyboard bro

msphn avatar Apr 15 '25 08:04 msphn

clean your keyboard bro

I'm not using any input fields. Simply opening the modal after the bottom sheet closes.

danish5454 avatar Apr 15 '25 08:04 danish5454

the issue still remains. any fixes? I need to use Modal from react-native, and react-native-modal library as well...

tmak1990 avatar Apr 24 '25 07:04 tmak1990

Unfortunately I have not found a solution yet.

@gorhom Do you have any idea what could cause this?

rklomp avatar Apr 24 '25 07:04 rklomp

Hey I have the exact same issue. The modal is stuck at the top left corner and freeze all the screen

poupsipoups avatar May 16 '25 09:05 poupsipoups

I'm having exactly the same issue, any fix?

HuseinHQ avatar May 20 '25 07:05 HuseinHQ

Depending on your setup, you may need to add a <BottomSheetModalProvider> to the root of your modal screen, if using react-navigation.

This solved it for me.

arancauchi avatar May 21 '25 07:05 arancauchi

arancauchi

thank you for your advice, I am not using react-navigation but tried it and didn't fix the issue unfortunately.

tmak1990 avatar May 23 '25 15:05 tmak1990

Making coverScreen={false} prop on Modal component of 'react-native-modal' and add to styles a zIndex 999 solve the problem for me

IbraheemShawhnee avatar May 29 '25 21:05 IbraheemShawhnee

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 Jun 29 '25 09:06 github-actions[bot]

same issues, can anyone solve this problem?

plaknight avatar Jul 02 '25 08:07 plaknight

Having the same issue. I was using react-native Modal and now I switched to react-native-modal, however, I need the modal to take up the full page, so coverScreen={false} will not work for my case

brycnguyen avatar Jul 10 '25 07:07 brycnguyen

I found a solution that works for me: I moved all my modals into a provider and placed them in the App/Layout. I manage their state using a global state manager like Zustand. This is the only solution that worked for me after two days of trying.

DvzZDev avatar Jul 22 '25 15:07 DvzZDev

@gorhom any update on this?

Muhammadmahadsaeed avatar Jul 29 '25 09:07 Muhammadmahadsaeed

In case this helps anyone, I was facing this issue. My bottom sheet modal was just invisible. The main issue being sheet not closing properly

To fix this, I did a couple of hacky things:

  1. Set index prop to 1 only for Android (forces it to open by default for Android - state is going to be controlled by a local state in parent)
...
index={Platform.select({
          ios: -1,
          android: 1,
          default: -1,
        })} // hidden initially except on android where visibility is controlled by local state
...
  1. I used a separate local state to track modal open/closes only for android. For iOS, the Ref-based control worked well. In Sheet:
    if (!open) {
      return null;
    }
    return (
      <BottomSheet
       ...

When using component:

    <MyCustomBottomSheetComponent
        ref={replyBottomSheetRef}
        open={Platform.select({
          android: isReplyBottomSheetOpen,
          ios: true,
          default: true,
        })}
    ...
  1. Create an effect to close modal when hardware back button is pressed using BackHandler. You'll need to pass in an onClose handler to your component
    // Effect to handle back button press on android
    useEffect(() => {
      if (Platform.OS === "android" && open && !backHandlerRef.current) {
        const backHandler = BackHandler.addEventListener(
          "hardwareBackPress",
          () => {
            onClose();
            return true;
          }
        );
        // Use a ref to avoid multiple listeners being added
        backHandlerRef.current = backHandler;
        return () => {
          backHandler.remove();
          backHandlerRef.current = null;
        };
      }
    }, [open, onClose, backHandlerRef]);

It's hacky but it works + preserves the pan handle drag animations across both devices.

juliussneezer04 avatar Aug 26 '25 08:08 juliussneezer04

Wrapping the <Modal> inside of a <View> with 'absolute' position and 'flex-1' works for me.

Not sure what exactly the issue is, but it seems like the Modal component couldn't get the computed width and height of the screen where it's being rendered. This "wrapper hack" works because it contains the Modal within a container that has full width and height. The position absolute is to make sure it doesn't affect your layout

// Nativewind
<View className="absolute inset-0 flex-1">
  <Modal>
    ...
  </Modal>
</View>

// ===========

// style prop
<View 
  style={{
      position: 'absolute',
      inset: 0,
      flex: 1,
  }}
  <Modal>
    ...
  </Modal>
</View>

@Dat-Mobile Can you let me know if this works for you too? Thanks!

butadpj avatar Aug 30 '25 22:08 butadpj

Making coverScreen={false} prop on Modal component of 'react-native-modal' and add to styles a zIndex 999 solve the problem for me

It worked for me. Thanks a lot

chuthuong2004 avatar Sep 30 '25 06:09 chuthuong2004

I am using RN-version:0.77 and when click to open any modal in the release APK, the whole app is killed and Android drops back to the phone’s home screen (like a full crash/force close).How to fix it?

akku27-cse avatar Oct 03 '25 13:10 akku27-cse

@butadpj shitty workaround but works, thanks, i can still see it empty for a second then the content loads

ShkoMaghdidEbrahim avatar Oct 31 '25 00:10 ShkoMaghdidEbrahim