-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[iOS] Keep button hit testing within its own subtree #4495
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1193,13 +1193,22 @@ - (void)mouseExited:(NSEvent *)event | |
|
|
||
| - (void)mouseDown:(NSEvent *)event | ||
| { | ||
| if (!_userEnabled) { | ||
| return; | ||
| } | ||
|
|
||
|
|
||
| _isTouchInsideBounds = YES; | ||
| [self handleAnimatePressIn]; | ||
| [super mouseDown:event]; | ||
| } | ||
|
|
||
| - (void)mouseUp:(NSEvent *)event | ||
| { | ||
| if (!_userEnabled) { | ||
| return; | ||
| } | ||
|
|
||
| NSPoint locationInView = [self convertPoint:[event locationInWindow] fromView:nil]; | ||
| _isHovered = NSPointInRect(locationInView, self.bounds); | ||
| [self recordHoverSampleForMouseEvent:event]; | ||
|
|
@@ -1212,6 +1221,10 @@ - (void)mouseUp:(NSEvent *)event | |
|
|
||
| - (void)mouseDragged:(NSEvent *)event | ||
| { | ||
| if (!_userEnabled) { | ||
| return; | ||
| } | ||
|
|
||
| NSPoint locationInWindow = [event locationInWindow]; | ||
| NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil]; | ||
| BOOL currentlyInside = NSPointInRect(locationInView, self.bounds); | ||
|
|
@@ -1244,6 +1257,10 @@ - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event | |
|
|
||
| - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event | ||
| { | ||
| if (!_userEnabled) { | ||
| return NO; | ||
| } | ||
|
|
||
| _isTouchInsideBounds = YES; | ||
| // A pencil's hover-out arrives just before touch-down but only schedules the | ||
| // clear, so `_isHovered` still reflects the open hover. Under Reduce Motion | ||
|
|
@@ -1469,7 +1486,7 @@ - (RNGHUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event | |
| } | ||
|
|
||
| RNGHUIView *inner = [super hitTest:point withEvent:event]; | ||
| while (inner && ![self shouldHandleTouch:inner atPoint:point]) { | ||
| while (inner && inner != self && ![self shouldHandleTouch:inner atPoint:point]) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -eu
file='packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm'
printf '%s\n' '--- hit-test and predicate definitions ---'
rg -n -C 12 'hitTest:withEvent:|shouldHandleTouch:atPoint:|setUserEnabled:|userEnabled|inner != self' "$file"
printf '%s\n' '--- changed hunks ---'
git diff --unified=25 -- "$file"Repository: software-mansion/react-native-gesture-handler Length of output: 9944 🤖 get_repo_knowledge executed:
Length of output: 1911 🏁 Script executed: #!/bin/bash
set -eu
file='packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm'
printf '%s\n' '--- class declaration and hit-test implementation ---'
sed -n '1,75p;1360,1498p' "$file"
printf '%s\n' '--- related declarations/usages ---'
rg -n -C 5 'RNGestureHandlerButton|hitTest:withEvent:|pointerEvents' packages/react-native-gesture-handler/apple -g '*.h' -g '*.mm' | head -n 260Repository: software-mansion/react-native-gesture-handler Length of output: 35500 Return
🤖 Prompt for AI Agents |
||
| inner = inner.superview; | ||
| } | ||
| return inner; | ||
|
|
||
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: software-mansion/react-native-gesture-handler
Length of output: 17645
🤖 get_repo_knowledge executed:
get_repo_knowledge software-mansion/react-native-gesture-handler /tmp/coderabbit-repo-knowledge/software-mansion-react-native-gesture-handler-7e5c6f9e/learnings /tmp/coderabbit-repo-knowledge/software-mansion-react-native-gesture-handler-7e5c6f9e/conventionsLength of output: 4187
🏁 Script executed:
Repository: software-mansion/react-native-gesture-handler
Length of output: 20051
Cancel active input when the button becomes disabled.
setUserEnabled:does not cancel active tracking or reset the press state. On macOS, disabledmouseUp:andmouseDragged:return before clearing_isTouchInsideBoundsor completing the press animation. On iOS,continueTrackingWithTouch:withEvent:andendTrackingWithTouch:withEvent:can dispatch drag and up actions after the button is disabled.When disabling the button, cancel active tracking and reset the local press state. Add regression coverage for disabling the button between touch-down and touch-up.
🤖 Prompt for AI Agents