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

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Mar 31, 2025

Description

When GestureHandler & GestureHandlerRootView are present, the pressables
in subtree of GestureHandler will lose focus on fast initial movement.
See the video below 👇.

Note

Edit: the fast movement requirement most likely comes from the fact that we use fling for the EmptyGestureHandler. In case you use e.g. Pan, the movement does not have to be fast.

Note

The issue is reproducible w/o react-native-screens.

The issue affects us, because #1913 added custom-screen-transitions based
on integration with gesture-handler & reanimated. Each ScreenStack is since then
wrapped in a GestureDetector, which uses either EmptyGestureHandler
or one defined based on gesture config.

Issue mechanism

Basically it seems like bug in gesture-handler. The RNGestureHandlerRootHelper cancels gesture
on the root view, causing RN pressable gesture handling to be cancelled. Instead, the attached gesture-handler
intercepts the touch events.

Warning

I was able to reproduce the issue 100% reliably earlier w/o presence of the Screen component, however
testing it now it seems that the Screen is required (w/o Screen in view hierarchy it seems to work fine...).
Dunno what is going on 🤷

Issue recording

lose-focus-on-fast-swipe.mp4

Changes

It looks to me that it has to be handled on the side of gesture-handler / reac-native core.

Currently, I've decided to disable the EmptyGestureHandler we wrap the ScreenStack.

Caution

This is only partial workaround. There still will be issue in case someone setups the
goBackGesture & we pass enabled GestureHandler to GestureDetector.

Test code and steps to reproduce

Test2819, may require you to wrap HomeOne inside a Screen, depending on the device/RN/other code mood I guess.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@kkafar kkafar changed the base branch from main to @kkafar/improve-naming March 31, 2025 12:38
@kkafar kkafar changed the title fix(Android): pressables could lose focus when gesture-handler was present fix(Android): pressables lose focus on fast movement when gesture-handler is present Mar 31, 2025
@kkafar kkafar deleted the branch main March 31, 2025 13:37
@kkafar kkafar closed this Mar 31, 2025
@kkafar kkafar reopened this Mar 31, 2025
@kkafar kkafar changed the base branch from @kkafar/improve-naming to main March 31, 2025 13:39
@kkafar kkafar force-pushed the @kkafar/spf-formsheet-enter-flicker-paper branch from 5eddcfb to d77402f Compare March 31, 2025 13:40
@kkafar kkafar merged commit 68d099a into main Mar 31, 2025
5 checks passed
@kkafar kkafar deleted the @kkafar/spf-formsheet-enter-flicker-paper branch March 31, 2025 13:40
Copy link
Contributor

@kligarski kligarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants