Skip to content

Commit 042d319

Browse files
authored
Fix ScrollView intercepting touches through out-of-bounds children (#3017)
## Description In facebook/react-native#43464 `clipChildren` started being set to false on scrollviews, which caused `isViewClippingChildren` to return false. Because of this, gesture handler would traverse the children of the scrollview even when touch was out of bounds: https://github.com/user-attachments/assets/6d108b55-6e06-4202-bc77-9d9dd2825456 This PR adds special cases for scroll views that have `overflow` set to `visible` so that scrolling works on all of its children. ## Test plan Test components sample on FabricExample app
1 parent e394532 commit 042d319

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import android.view.View
44
import android.view.ViewGroup
55
import com.facebook.react.uimanager.PointerEvents
66
import com.facebook.react.uimanager.ReactPointerEventsView
7+
import com.facebook.react.views.scroll.ReactHorizontalScrollView
8+
import com.facebook.react.views.scroll.ReactScrollView
79
import com.facebook.react.views.view.ReactViewGroup
810
import com.swmansion.gesturehandler.core.PointerEventsConfig
911
import com.swmansion.gesturehandler.core.ViewConfigurationHelper
@@ -40,12 +42,11 @@ class RNViewConfigurationHelper : ViewConfigurationHelper {
4042
} else parent.getChildAt(index)
4143
}
4244

43-
override fun isViewClippingChildren(view: ViewGroup): Boolean {
44-
if (view.clipChildren) {
45-
return true
46-
}
47-
return if (view is ReactViewGroup) {
48-
"hidden" == view.overflow
49-
} else false
45+
override fun isViewClippingChildren(view: ViewGroup) = when {
46+
view.clipChildren -> true
47+
view is ReactScrollView -> view.overflow != "visible"
48+
view is ReactHorizontalScrollView -> view.overflow != "visible"
49+
view is ReactViewGroup -> view.overflow == "hidden"
50+
else -> false
5051
}
5152
}

0 commit comments

Comments
 (0)