Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,37 @@ - (void)animateTarget:(RNGHUIView *)target toOpacity:(CGFloat)opacity scale:(CGF
#endif
}

#if !TARGET_OS_OSX

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
UITouch *touch = [touches anyObject];
if (touch.view != self) {
[self sendActionsForControlEvents:UIControlEventTouchDown];
}
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
UITouch *touch = [touches anyObject];
if (touch.view != self) {
[self sendActionsForControlEvents:UIControlEventTouchUpInside];
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

touchesEnded unconditionally sends UIControlEventTouchUpInside whenever the touch began on a subview (touch.view != self). This can fire the press action even when the finger is released outside the control bounds (drag-out cancellation), which breaks expected Pressable/UIControl semantics. Consider checking the touch end location against pointInside:withEvent: (respecting hitTestEdgeInsets) and sending UIControlEventTouchUpInside only when inside; otherwise send UIControlEventTouchUpOutside (or cancel as appropriate).

Suggested change
[self sendActionsForControlEvents:UIControlEventTouchUpInside];
CGPoint location = [touch locationInView:self];
if ([self pointInside:location withEvent:event]) {
[self sendActionsForControlEvents:UIControlEventTouchUpInside];
} else {
[self sendActionsForControlEvents:UIControlEventTouchUpOutside];
}

Copilot uses AI. Check for mistakes.
}
}
Comment on lines +228 to +244
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

In the touch.view != self path the control manually emits only TouchDown, TouchUpInside, and TouchCancel, but never emits drag-related events (TouchDragExit/TouchDragEnter/TouchDragOutside) or TouchUpOutside. Since commonInit wires handleAnimatePressOut to TouchDragExit/TouchUpOutside, this can cause pressed visuals/state to behave differently when the finger moves outside the control before ending. Consider implementing touchesMoved: to mirror UIControl’s inside/outside tracking and emit the corresponding control events (or otherwise ensure press-out is dispatched when the touch leaves bounds).

Copilot uses AI. Check for mistakes.

- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[super touchesCancelled:touches withEvent:event];
UITouch *touch = [touches anyObject];
if (touch.view != self) {
[self sendActionsForControlEvents:UIControlEventTouchCancel];
}
}

#endif

- (void)handleAnimatePressIn
{
RNGHUIView *target = self.animationTarget ?: self;
Expand Down
Loading