-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(iOS): handles pointerEvents for Pressable component
#3925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(iOS): handles pointerEvents for Pressable component
#3925
Conversation
packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm
Outdated
Show resolved
Hide resolved
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR! Just one more thing and it should be ready to go 🎉
packages/react-native-gesture-handler/apple/RNGestureHandlerButton.h
Outdated
Show resolved
Hide resolved
pointerEvents for Pressable componentpointerEvents for Pressable component
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I didn't want to bother you anymore I took the liberty of adding some minor changes (newline and header) to match other enums.
Thank you very match for this PR ❤️
Description
fixes: #3891
fixes: #3904
This PR implements
pointerEventssupport forPressablecomponent fromreact-native-gesture-handleron iOS. Previously, settingpointerEvents="box-none"(or other modes) had no effect on iOS, while it worked correctlyon Androidand with React Native'sPressableon iOS.Android PR: #3927
Implementation Details
The implementation follows React Native's
hitTestlogic forpointerEvents:box-only: Returnsselfif point is inside (respectinghitSlop),nilotherwisebox-none: Checks subviews only, returns the hit subview ornilnone: Always returnsnilauto: Uses standard hit testing withshouldHandleTouchlogicThe implementation respects
hitTestEdgeInsets(hitSlop) for all modes, ensuring consistent behavior with React Native'sPressable.Test plan
Tested all
pointerEventsmodes on iOS:pointerEvents="none"- View and subviews don't receive touchespointerEvents="box-none"- View doesn't receive touches, subviews dopointerEvents="box-only"- View receives touches, subviews don'tpointerEvents="auto"- Default behavior works as expectedI've used https://github.com/huextrat/repro-pressable-gh to test scenarios
Tested on both old architecture (Paper) and new architecture (Fabric).
edit:
pointerEventswith RNGH Pressable is not working on Android