From ca9bf1d7fbe93a1ffa67f62a01357b62a204e7c8 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Sun, 30 Mar 2025 15:37:00 +0200 Subject: [PATCH 1/7] Add minimal repro --- apps/src/tests/TestRepro.tsx | 43 ++++++++++++++++++++++++++++++++++++ apps/src/tests/index.ts | 1 + 2 files changed, 44 insertions(+) create mode 100644 apps/src/tests/TestRepro.tsx diff --git a/apps/src/tests/TestRepro.tsx b/apps/src/tests/TestRepro.tsx new file mode 100644 index 0000000000..d87db6af6a --- /dev/null +++ b/apps/src/tests/TestRepro.tsx @@ -0,0 +1,43 @@ +import React from 'react'; +import { Text, View } from 'react-native'; +import PressableWithFeedback from '../shared/PressableWithFeedback'; +import { GestureHandlerRootView } from 'react-native-gesture-handler'; +import { GestureDetectorProvider } from 'react-native-screens/gesture-handler'; +import { Screen, ScreenStack } from 'react-native-screens'; + + +function SharedPressable() { + return ( + + + Regular pressable + + + ); +} + +function HomeOne() { + return ( + + + + + + ); +} + +export function App() { + return ( + + + + + + + + + + ); +} + +export default App; diff --git a/apps/src/tests/index.ts b/apps/src/tests/index.ts index 29c21b2c97..79f3117c4d 100644 --- a/apps/src/tests/index.ts +++ b/apps/src/tests/index.ts @@ -137,5 +137,6 @@ export { default as TestMemoryLeak } from './TestMemoryLeak'; export { default as TestFormSheet } from './TestFormSheet'; export { default as TestAndroidTransitions } from './TestAndroidTransitions'; export { default as TestAnimation } from './TestAnimation'; +export { default as TestRepro } from './TestRepro'; From 8906f07a5cf11115b91235d4bc281fa773baab1e Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Sun, 30 Mar 2025 17:01:12 +0200 Subject: [PATCH 2/7] Simplify reproduction even more --- apps/src/tests/TestRepro.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/src/tests/TestRepro.tsx b/apps/src/tests/TestRepro.tsx index d87db6af6a..b96defbc1b 100644 --- a/apps/src/tests/TestRepro.tsx +++ b/apps/src/tests/TestRepro.tsx @@ -1,8 +1,7 @@ import React from 'react'; import { Text, View } from 'react-native'; import PressableWithFeedback from '../shared/PressableWithFeedback'; -import { GestureHandlerRootView } from 'react-native-gesture-handler'; -import { GestureDetectorProvider } from 'react-native-screens/gesture-handler'; +import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler'; import { Screen, ScreenStack } from 'react-native-screens'; @@ -18,24 +17,26 @@ function SharedPressable() { function HomeOne() { return ( - - - - + + ); } export function App() { + const gesture = Gesture.Pan() + .onBegin(() => { + 'worklet'; + }); return ( - + - + ); } From 5404081faceafea5b900fe87ffc986018f57de37 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 31 Mar 2025 13:12:46 +0200 Subject: [PATCH 3/7] Simplify reproduction even more 2 --- apps/src/tests/TestRepro.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/src/tests/TestRepro.tsx b/apps/src/tests/TestRepro.tsx index b96defbc1b..664b1e4603 100644 --- a/apps/src/tests/TestRepro.tsx +++ b/apps/src/tests/TestRepro.tsx @@ -31,11 +31,9 @@ export function App() { return ( - - - - - + + + ); From 4349ba38c6ae6f974ee6781843bdf940b4d93b62 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 31 Mar 2025 14:19:14 +0200 Subject: [PATCH 4/7] Simplify reproduction even more 3 --- apps/src/tests/TestRepro.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/src/tests/TestRepro.tsx b/apps/src/tests/TestRepro.tsx index 664b1e4603..d51206e0eb 100644 --- a/apps/src/tests/TestRepro.tsx +++ b/apps/src/tests/TestRepro.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { Text, View } from 'react-native'; import PressableWithFeedback from '../shared/PressableWithFeedback'; import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler'; -import { Screen, ScreenStack } from 'react-native-screens'; function SharedPressable() { @@ -27,13 +26,12 @@ export function App() { const gesture = Gesture.Pan() .onBegin(() => { 'worklet'; - }); + }) + .enabled(true); // Change this to `false` to fix the issue. return ( - - - + ); From f5e32f77f6a5bdc8419ebe27670c492482bbe8c5 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 31 Mar 2025 14:22:15 +0200 Subject: [PATCH 5/7] Partially workaround the issue --- src/gesture-handler/ScreenGestureDetector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gesture-handler/ScreenGestureDetector.tsx b/src/gesture-handler/ScreenGestureDetector.tsx index 14edd7520c..7b48bd52ac 100644 --- a/src/gesture-handler/ScreenGestureDetector.tsx +++ b/src/gesture-handler/ScreenGestureDetector.tsx @@ -24,7 +24,7 @@ import { } from './constraints'; import { GestureProviderProps } from '../types'; -const EmptyGestureHandler = Gesture.Fling(); +const EmptyGestureHandler = Gesture.Fling().enabled(false); const ScreenGestureDetector = ({ children, From 52e0df3cae5438b05ac4eff9753aa4ff289d2bd4 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 31 Mar 2025 14:38:09 +0200 Subject: [PATCH 6/7] Rename the test to Test2819 --- apps/src/tests/{TestRepro.tsx => Test2819.tsx} | 0 apps/src/tests/index.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename apps/src/tests/{TestRepro.tsx => Test2819.tsx} (100%) diff --git a/apps/src/tests/TestRepro.tsx b/apps/src/tests/Test2819.tsx similarity index 100% rename from apps/src/tests/TestRepro.tsx rename to apps/src/tests/Test2819.tsx diff --git a/apps/src/tests/index.ts b/apps/src/tests/index.ts index 79f3117c4d..86ebb0e46f 100644 --- a/apps/src/tests/index.ts +++ b/apps/src/tests/index.ts @@ -126,6 +126,7 @@ export { default as Test2717 } from './Test2717'; export { default as Test2767 } from './Test2767'; export { default as Test2789 } from './Test2789'; export { default as Test2811 } from './Test2811'; +export { default as Test2819 } from './Test2819'; export { default as TestScreenAnimation } from './TestScreenAnimation'; export { default as TestScreenAnimationV5 } from './TestScreenAnimationV5'; export { default as TestHeader } from './TestHeader'; @@ -137,6 +138,5 @@ export { default as TestMemoryLeak } from './TestMemoryLeak'; export { default as TestFormSheet } from './TestFormSheet'; export { default as TestAndroidTransitions } from './TestAndroidTransitions'; export { default as TestAnimation } from './TestAnimation'; -export { default as TestRepro } from './TestRepro'; From d77402f70803d987ce5bf2932975ac8a4493bae6 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Mon, 31 Mar 2025 14:40:06 +0200 Subject: [PATCH 7/7] Add comment on why the detector is disabled there --- src/gesture-handler/ScreenGestureDetector.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gesture-handler/ScreenGestureDetector.tsx b/src/gesture-handler/ScreenGestureDetector.tsx index 7b48bd52ac..2afab56309 100644 --- a/src/gesture-handler/ScreenGestureDetector.tsx +++ b/src/gesture-handler/ScreenGestureDetector.tsx @@ -24,6 +24,8 @@ import { } from './constraints'; import { GestureProviderProps } from '../types'; +// The detector is disabled to work around issue with pressables +// losing focus. See https://github.com/software-mansion/react-native-screens/pull/2819 const EmptyGestureHandler = Gesture.Fling().enabled(false); const ScreenGestureDetector = ({