Add onNativeTouchEnd event (Android finger-lift from WebView MotionEvent stream)#13
Merged
Merged
Conversation
…ent stream)
Exposes a new `onNativeTouchEnd` direct event that fires from the WebView's own
MotionEvent stream on a terminal action, carrying { action, pointerCount, x, y }
where `action` is one of 'up' | 'cancel' | 'pointerUp'. Unlike RN's onTouchEnd
responder, this observes the WebView's native touch stream directly, so it can
detect a finger lift even when Chromium's native text-selection controller seizes
the gesture and suppresses the usual RN/DOM release signals.
- Codegen spec + JS types (src/RNCWebViewNativeComponent.ts, src/WebViewTypes.ts)
with a typed string-union action ('up' | 'cancel' | 'pointerUp')
- Android: TopNativeTouchEndEvent, dispatchTouchEvent override (observe-only,
always returns super), maps the MotionEvent action to the string and is
registered in old+new arch managers
- iOS: no-op RCTDirectEventBlock property + export for codegen-interface parity
(never fired on iOS/macOS)
- Rebuilt lib/ declarations + view config
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a new
onNativeTouchEnddirect event to the WebView. It fires from the WebView's ownMotionEventstream on a terminal gesture action, with a typed payload:Why
On Android, once Chromium's native text-selection controller seizes a selection-drag gesture, it dispatches
touchcancel/pointercanceland delivers no further events to React Native's view tree or the WebView's DOM — so RN'sView.onTouchEnd,onPointerUp, RNGHonTouchesUp, DOMtouchend/pointerupall get cancelled and never report the finger lift.The WebView's own
dispatchTouchEvent, however, still receives the realACTION_UPon a selection-drag release. This event surfaces that signal so a consumer can reliably detect when the user finishes a text selection. (Used downstream to fix First Class Lookup not opening on Android word-select.)Verified on a Pixel 6a: a 2–3 word drag-select release reports
action: 'up'; a selection-handle re-drag (separate popup window) reports only'cancel'.Changes
src/RNCWebViewNativeComponent.ts,src/WebViewTypes.ts) with the typed string-union action.TopNativeTouchEndEvent, adispatchTouchEventoverride (observe-only — always returnssuper, no behavior change), mapping theMotionEventaction to the string, registered in both old- and new-arch managers.RCTDirectEventBlockproperty + export so the shared codegen interface stays consistent across platforms (never fired on iOS/macOS).lib/(declarations + view config).Risk
dispatchTouchEventis observe-only and always returnssuper.dispatchTouchEvent(event), so existing touch/scroll/selection behavior is unchanged. The event is Android-only; the iOS side is a compile-time stub.🤖 Generated with Claude Code