-
-
Notifications
You must be signed in to change notification settings - Fork 599
fix(iOS, Stack, Fabric): Pressable hitSlop in header subviews on Fabric
#3446
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
base: main
Are you sure you want to change the base?
Conversation
kkafar
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.
This looks really good, but I have a question that needs to be answered before we proceed.
| // We wrap the headerLeft/Right component in a UIBarButtonItem | ||
| // so we need to hit test subviews, because of the view flattening | ||
| // (we match RCTViewComponentView implementation). | ||
| for (UIView *headerComponentSubview in [subview.subviews reverseObjectEnumerator]) { | ||
| CGPoint convertedPoint = [self convertPoint:point toView:headerComponentSubview]; | ||
| UIView *hitTestResult = [headerComponentSubview hitTest:convertedPoint withEvent:event]; | ||
|
|
||
| if (hitTestResult != nil) { | ||
| headerComponent = hitTestResult; | ||
| return hitTestResult; | ||
| } | ||
| } |
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.
The comment above the for loop explicitly states, that the default behaviour of reverse iterating over the children) has been deliberately changed to left to right.
Can we do some research & see what problem exactly this approach solved & whether we do not introduce a regression with swapping this back?
Description
Fixes Pressable
hitSlopin header subviews on Fabric, iOS.before3446.mov
after3446.mov
Closes https://github.com/software-mansion/react-native-screens-labs/issues/552.
Changes
RNSScreenStack's coordinates to that ofRNSScreenStackHeaderConfig(on Fabric, it has negative origin.y so that ShadowTree knows about navigation bar + subviews positioning)RNSScreenStackHeaderConfig's hitTest:HeaderSubview's subviews and add early return, matchingRCTViewComponentViewimplementationPressableWithFeedbackpass props toPressablecomponentTest code and steps to reproduce
Run
Test3466.Checklist