Skip to content

Conversation

@kligarski
Copy link
Contributor

@kligarski kligarski commented Dec 2, 2025

Description

Fixes Pressable hitSlop in header subviews on Fabric, iOS.

before after
before3446.mov
after3446.mov

Closes https://github.com/software-mansion/react-native-screens-labs/issues/552.

Changes

  • convert hit test point from RNSScreenStack's coordinates to that of RNSScreenStackHeaderConfig (on Fabric, it has negative origin.y so that ShadowTree knows about navigation bar + subviews positioning)
  • fix logic in RNSScreenStackHeaderConfig's hitTest:
    • previous implementation would always return after checking only one subview leading to inconsistent behavior
    • change order of iteration throughHeaderSubview's subviews and add early return, matching RCTViewComponentView implementation
  • add test screen
  • make PressableWithFeedback pass props to Pressable component

Test code and steps to reproduce

Run Test3466.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

Copy link
Member

@kkafar kkafar left a 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.

Comment on lines +172 to 182
// 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;
}
}
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Architecture: New Issues related only to new architecture Area: Native Stack Platform: iOS This issue is specific to iOS Type: Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants