Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Change
onTouchEvent
to dispatchTouchEvent
in `NativeVie…
…wGestureHandler` (#3244) ## Description Currently wrapping `WebView` into `NativeViewGestureHandler` doesn't work as expected - events from `native` gesture do not reach `WebView`. This happens because inside `NativeViewGestureHandler` we call `onTouchEvent` method. In native hierarchy `WebView` is nested inside `ViewGroup`, which means that calling `onTouchEvent` instead of `dispatchTouchEvent` won't do anything to the `WebView`. Should fix #2454 Fixes #3196 ## Test plan Tested on example app and the code below: <details> <summary>Test code</summary> ```jsx import * as React from 'react'; import { View, StyleSheet } from 'react-native'; import { WebView } from 'react-native-webview'; import { Gesture, GestureDetector, GestureHandlerRootView, } from 'react-native-gesture-handler'; function WebViewScreen() { const native = Gesture.Native() .shouldActivateOnStart(true) .disallowInterruption(true); const pan = Gesture.Pan().onChange(console.log); const g = Gesture.Simultaneous(native, pan); return ( <View style={styles.webViewContainer}> <GestureDetector gesture={g}> <WebView source={{ uri: 'https://templates.tiptap.dev/nw6Cmz6HfD' }} style={styles.webView} javaScriptEnabled={true} domStorageEnabled={true} startInLoadingState={true} onError={(syntheticEvent) => { const { nativeEvent } = syntheticEvent; console.warn('WebView error: ', nativeEvent); }} /> </GestureDetector> </View> ); } export default function BuggyApp() { return ( <GestureHandlerRootView> <WebViewScreen /> </GestureHandlerRootView> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, text: { fontSize: 18, }, webView: { flex: 1, }, webViewContainer: { flex: 1, width: '100%', }, }); ``` </details>
- Loading branch information