Skip to content

DndProvider inside of a ScrollView was capturing gestures even when disabled=true, preventing scrolling #47

Description

@gjbadros

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @mgcrea/react-native-dnd@2.5.3 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@mgcrea/react-native-dnd/dist/DndProvider.js b/node_modules/@mgcrea/react-native-dnd/dist/DndProvider.js
index 2bbf21f..f605c45 100644
--- a/node_modules/@mgcrea/react-native-dnd/dist/DndProvider.js
+++ b/node_modules/@mgcrea/react-native-dnd/dist/DndProvider.js
@@ -298,11 +298,12 @@ export const DndProvider = forwardRef(function DndProvider({ children, springCon
         return panGesture;
         // eslint-disable-next-line react-hooks/exhaustive-deps
     }, [disabled]);
+    const Component = disabled? View : GestureDetector;
     return (<DndContext.Provider value={contextValue.current}>
-        <GestureDetector gesture={panGesture}>
+        <Component gesture={panGesture}>
           <View ref={containerRef} collapsable={false} style={style} testID="view">
             {children}
           </View>
-        </GestureDetector>
+        </Component>
       </DndContext.Provider>);
 });

This issue body was partially generated by patch-package.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions