Skip to content
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

fix(android): prevent taps while scrolling #961

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gpp-0
Copy link

@gpp-0 gpp-0 commented Jan 16, 2025

Summary

This PR fixes a bug on Android where taps sometimes incorrectly trigger while swiping between pager screens, see issues #960 and #954. These issues in turn were opened in order to investigate bluesky-social/social-app#7312
The cause of the bug seems to have had to do with React not being notified when the native pager starts scrolling, which meant that it didn't properly cancel gestures in the pager's children.

The fix involves adding a call to notifyNativeGestureStarted, whose purpose is exactly to notify JS that a native gesture has started so it can dispatch the appropriate cancel events, see its use in other similar components like ReactScrollView

This call was added to NestedScrollableHost, where scrolling canceling logic was already present, however the behavior of nested scrollables should hopefully remain unchanged.

Test Plan

I have tested the issues this PR aims to solve (#960, #954, bluesky-social/social-app#7312) and I cannot reproduce the described bugs anymore.
I have also tested all the examples in the repo, and all seem to function as expected. In particular, examples with scrollables (eg. ScrollViewInsideExample) or nested pagers (eg. NestPagerView) seem to be unaffected.

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)

@gaearon
Copy link

gaearon commented Jan 17, 2025

Verified this fixes the issue in our app.

gaearon added a commit to bluesky-social/social-app that referenced this pull request Jan 17, 2025
* [Android] Fix taps triggering while swiping

* Revert "[Android] Try to disambiguate taps from swipes (#7448)"

This reverts commit 96054f4.

* Update patch to match callstack/react-native-pager-view#961

* Make it symmetrical

---------

Co-authored-by: Dan Abramov <[email protected]>
@troZee
Copy link
Member

troZee commented Jan 17, 2025

Hello 👋
Thank you for your 1st contribution to the pager library. In this PR, I fixed the CI #962 . Could you rebase your PR with the main branch?

Once it is rebased, we will merge it

Thank you for your cooperation 🙏

Copy link
Collaborator

@MrRefactor MrRefactor left a comment

Choose a reason for hiding this comment

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

Looks good to me!

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.

4 participants