react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

Doesn't work in a modal

Open martinezguillaume opened this issue 8 years ago • 101 comments

Hi ! I have a little issue on Android, onGestureEvent is not trigger when GestureHandler components is on a modal on Android. When I change the modal to a View, it works perfectly 👌

No problem on iOS

martinezguillaume avatar Apr 11 '18 09:04 martinezguillaume

+1 any workaround?

mordaha avatar Jun 08 '18 13:06 mordaha

I don’t use Modal for now, I just re-create it with a View in absolute position

martinezguillaume avatar Jun 08 '18 14:06 martinezguillaume

using modal screen for now, after googling and chats Modal from RN considered too much buggy thing

mordaha avatar Jun 08 '18 22:06 mordaha

+1

csto avatar Jun 20 '18 14:06 csto

Hi, @martinezguillaume, @mordaha, @csto I did take a look on this issue and I suppose it's not a matter of our library, but RN Core.

osdnk avatar Jul 10 '18 12:07 osdnk

@osdnk is this fixable?

mars-lan avatar Jul 14 '18 06:07 mars-lan

+1 gesture does not work on modal

ParhamZare avatar Dec 11 '18 15:12 ParhamZare

I also ran into this bug today.

ewendel avatar Jan 28 '19 11:01 ewendel

Same problem. Gesture does not work on modal on Android. Expo for example

ghost avatar Feb 01 '19 08:02 ghost

Same for me. Tested react-native's PanResponder handlers on modal - works fine.

I have a thoughts about this: when we are linking this library to android project, we are doing next step

@Override
            protected ReactRootView createRootView() {
                return new RNGestureHandlerEnabledRootView(MainActivity.this);
            }

And we know that modal is separate package. May be theres sense to do something same with it?

Dmitrylolo avatar Feb 26 '19 17:02 Dmitrylolo

I was using a standard React Native Modal and was experiencing this issue. I worked around the problem by creating a new screen and displaying it as a modal. I'm using react-native-navigation, so:

Navigation.showModal({
    component: {
      name: navRoutes.ImageModal,
      passProps: { image },
    },
  })

Gestures are working as expected on both iOS and Android, and I still get transparent background that I wanted from my original modal.

samzmann avatar Mar 26 '19 17:03 samzmann

I have dug into it for a while.

  1. It's a problem of RNGH. Sorry 😒
  2. It happens bc modals are not rendered below an RN root view.
  3. It's fixable by replacing modals' mechanism in a similar way as we do with an RNRootView by wrapping it with some extra logic. See https://github.com/kmagiera/react-native-gesture-handler/blob/master/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java
  4. I have no time to do it now, it's time-consuming work and probably requires copying some code in an RNGH core on Android native side.

If someone wants and has time to do it, I'll happily review it and merge immediately if it would be workable and not too hacky.

@martinezguillaume @mordaha @csto @mars-lan @ParhamZare @ewendel @Via-profit @Dmitrylolo @LaVielle

osdnk avatar Mar 26 '19 18:03 osdnk

Also, I've made a try two months ago.

https://github.com/kmagiera/react-native-gesture-handler/commit/139da18039683bed3c439c991c7eaf802086bf86

Maybe it could be an inspiration for someone 🤷‍♂️

osdnk avatar Mar 26 '19 18:03 osdnk

Hey @osdnk I need this feature for my app, so I was thinking I could give it a try, but I don't have a lot of experience with RNGestureHandler, or with Android. Could you give me some more insight on what I would need to do to make it work ? Also I was looking at your previous try, and I would like to know what's missing for it to be finished, and if it could be used as a starting point.

AlexUzan avatar Apr 04 '19 14:04 AlexUzan

same error.

yqz0203 avatar Apr 24 '19 11:04 yqz0203

@kmagiera @osdnk any update on this? even Touchable*'s don't work inside the modal and this is frustrating

paolospag avatar May 09 '19 08:05 paolospag

+1. i use reanimated-bottom-sheet with modal

blohamen avatar May 24 '19 07:05 blohamen

Any updates? Or perhaps, any other modal component that does not suffer from this issue? RN's modal honestly works like quite bad and is full of bugs (such as getting stuck if combined with an alert)

cristianoccazinsp avatar May 30 '19 17:05 cristianoccazinsp

@cristianoccazinsp I ended up using https://github.com/react-native-community/react-native-modal

mars-lan avatar May 30 '19 17:05 mars-lan

Odd. That component is supposed to use react's modal internally. Did it make a difference to you?

El jue., 30 de mayo de 2019 14:38, Mars Lan [email protected] escribió:

@cristianoccazinsp https://github.com/cristianoccazinsp I ended up using https://github.com/react-native-community/react-native-modal

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kmagiera/react-native-gesture-handler/issues/139?email_source=notifications&email_token=ALU263ACF3LNSRSPFWR45ELPYAGJTA5CNFSM4EZ6UZL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWS7SOQ#issuecomment-497416506, or mute the thread https://github.com/notifications/unsubscribe-auth/ALU263GRH2KHBXUZBGHNKA3PYAGJTANCNFSM4EZ6UZLQ .

cristianoccazinsp avatar May 31 '19 09:05 cristianoccazinsp