Skip to content

[iOS] Ignore Apple's default retention offset for buttons and rely strictly on hitslop instead#4038

Open
j-piasecki wants to merge 2 commits intomainfrom
@jpiasecki/ios-strict-button-bounds
Open

[iOS] Ignore Apple's default retention offset for buttons and rely strictly on hitslop instead#4038
j-piasecki wants to merge 2 commits intomainfrom
@jpiasecki/ios-strict-button-bounds

Conversation

@j-piasecki
Copy link
Member

Description

Apple enforces a stupidly large retention offset in the default UIControl touch tracking loop, which was conflicting with shouldCancelWhenOutside and hitSlop props. This PR overrides the default tracking loop to rely only on our props instead.

Test plan

Tested on the example added in #4018

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts iOS UIControl touch-tracking for RNGestureHandlerButton to ignore Apple’s default “retention offset” behavior and instead base drag/up-inside vs outside decisions strictly on the component’s hitSlop/hitTestEdgeInsets, improving consistency with shouldCancelWhenOutside.

Changes:

  • Adds internal state to track whether the touch is currently inside the hitSlop-adjusted bounds.
  • Overrides continueTrackingWithTouch to generate drag enter/exit and drag inside/outside events using strict bounds checks (bypassing UIControl’s default behavior).
  • Overrides endTrackingWithTouch to send TouchUpInside vs TouchUpOutside based on strict bounds checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants