Skip to content

fix(Android): pressables lose focus on fast movement when gesture-handler is present #2819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions apps/src/tests/Test2819.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import { Text, View } from 'react-native';
import PressableWithFeedback from '../shared/PressableWithFeedback';
import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler';


function SharedPressable() {
return (
<PressableWithFeedback>
<View style={{ height: 120 }}>
<Text>Regular pressable</Text>
</View>
</PressableWithFeedback>
);
}

function HomeOne() {
return (
<View style={{ height: 600, backgroundColor: 'seagreen' }}>
<SharedPressable />
</View>
);
}

export function App() {
const gesture = Gesture.Pan()
.onBegin(() => {
'worklet';
})
.enabled(true); // Change this to `false` to fix the issue.
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<GestureDetector gesture={gesture}>
<HomeOne />
</GestureDetector>
</GestureHandlerRootView>
);
}

export default App;
1 change: 1 addition & 0 deletions apps/src/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 3 additions & 1 deletion src/gesture-handler/ScreenGestureDetector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import {
} from './constraints';
import { GestureProviderProps } from '../types';

const EmptyGestureHandler = Gesture.Fling();
// 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 = ({
children,
Expand Down
Loading