Skip to content

fix: prevent parent Pressable from firing onPress on link/task tap#143

Merged
hryhoriiK97 merged 3 commits intomainfrom
fix/prevent-parent-pressable-on-link-tap
Mar 9, 2026
Merged

fix: prevent parent Pressable from firing onPress on link/task tap#143
hryhoriiK97 merged 3 commits intomainfrom
fix/prevent-parent-pressable-on-link-tap

Conversation

@hryhoriiK97
Copy link
Copy Markdown
Collaborator

@hryhoriiK97 hryhoriiK97 commented Mar 9, 2026

What/Why?

Fixes: #142

Tapping a markdown link inside a Pressable fires both onLinkPress and the parent's onPress. This PR prevents the parent from receiving the tap when the user taps a link or task list checkbox.

  • iOS: Override touchEventEmitterAtPoint: to return nil on interactive elements, preventing JS touch dispatch entirely.
  • Android: Call NativeGestureUtil.notifyNativeGestureStarted to cancel the JS gesture. A brief opacity flash on the parent is unavoidable due to how Android Fabric dispatches touchStart before child views receive the touch — same limitation as RN's own ScrollView.

Why not e.stopPropagation()?

onLinkPress is a custom native event, separate from the touch/responder system that powers Pressable. stopPropagation() only affects the onLinkPress bubble — it has no effect on native touch dispatch, which must be intercepted at the platform level.

Testing

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes

@hryhoriiK97 hryhoriiK97 merged commit 9ca4639 into main Mar 9, 2026
5 checks passed
@hryhoriiK97 hryhoriiK97 deleted the fix/prevent-parent-pressable-on-link-tap branch March 10, 2026 11:33
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.

onLinkPress parent Pressable triggers

1 participant