Skip to content

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

@gjbadros

Description

@gjbadros

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch @mgcrea/[email protected] 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.

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