Skip to content

Commit 90ec670

Browse files
committed
fix: remove gesture conflicts caused by GestureDetector
1 parent b2a365f commit 90ec670

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

packages/webpack-plugin/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx

+15-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React, { ReactNode, useContext, useEffect, useMemo } from 'react'
1+
import React, { ReactNode, useContext, useEffect } from 'react'
22
import { DimensionValue, EmitterSubscription, Keyboard, View, ViewStyle } from 'react-native'
33
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated'
4-
import { GestureDetector, Gesture } from 'react-native-gesture-handler'
54
import { KeyboardAvoidContext } from './context'
65
import { isIOS } from './utils'
76

@@ -19,17 +18,6 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
1918
const basic = useSharedValue('auto')
2019
const keyboardAvoid = useContext(KeyboardAvoidContext)
2120

22-
const dismiss = () => {
23-
Keyboard.isVisible() && Keyboard.dismiss()
24-
}
25-
26-
const gesture = useMemo(() => {
27-
return Gesture.Tap()
28-
.onEnd(() => {
29-
dismiss()
30-
}).runOnJS(true)
31-
}, [])
32-
3321
const animatedStyle = useAnimatedStyle(() => ({
3422
transform: [{ translateY: -offset.value }],
3523
flexBasis: basic.value as DimensionValue
@@ -43,6 +31,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
4331
basic.value = 'auto'
4432
}
4533

34+
const onTouchEnd = () => {
35+
Keyboard.isVisible() && Keyboard.dismiss()
36+
}
37+
4638
useEffect(() => {
4739
let subscriptions: EmitterSubscription[] = []
4840

@@ -99,18 +91,16 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
9991
}, [keyboardAvoid])
10092

10193
return (
102-
<GestureDetector gesture={gesture}>
103-
<View style={style}>
104-
<Animated.View
105-
style={[
106-
contentContainerStyle,
107-
animatedStyle
108-
]}
109-
>
110-
{children}
111-
</Animated.View>
112-
</View>
113-
</GestureDetector>
94+
<View style={style} onTouchEnd={onTouchEnd}>
95+
<Animated.View
96+
style={[
97+
contentContainerStyle,
98+
animatedStyle
99+
]}
100+
>
101+
{children}
102+
</Animated.View>
103+
</View>
114104
)
115105
}
116106

0 commit comments

Comments
 (0)