Skip to content

fix(android): skip hidden children when finding a touch target - #59524

Open
bitsniper-ai wants to merge 1 commit into
react:mainfrom
bitsniper-ai:fix/touch-target-skip-hidden-children
Open

bitsniper-ai wants to merge 1 commit into
react:mainfrom
bitsniper-ai:fix/touch-target-skip-hidden-children

Conversation

@bitsniper-ai

Copy link
Copy Markdown

Summary:

TouchTargetHelper.findTouchTargetView walks a view's children from the top down and returns the first one under the touch point, without checking whether that child is shown. A native child that is GONE or INVISIBLE therefore becomes the touch target, and the touch is lost: nothing under it receives it.

The common case is RefreshControl on Android. SwipeRefreshLayout keeps its refresh indicator (a CircleImageView) as a child that rests GONE at the top centre of the scroll view. Every tap on content under that resting box, such as a button or chip near the top of a list, goes to the hidden indicator instead. This is #33163, which was closed as stale without a fix.

Android's own dispatch has the rule this applies: ViewGroup.canViewReceivePointerEvents lets a child take a pointer event only when it is VISIBLE or has an animation running. This change skips any other child in the same loop, before the child's point is computed.

The only React-managed views React Native hides are display: 'none' ones (SurfaceMountingManager.updateLayout sets them INVISIBLE), which should never take a touch either; Yoga lays them out at zero size, so today only a hitSlop could reach one. Every other view that changes outcome is a hidden native child that Android's own dispatch would never send a touch to.

Changelog:

[ANDROID] [FIXED] - Hidden native children (such as RefreshControl's resting indicator) no longer swallow touches meant for the views under them

Test Plan:

Repro: a ScrollView with a RefreshControl and a Pressable at the top centre of its content.

  • Before: tapping the Pressable where it overlaps the indicator's resting box does nothing (onPress never fires); tapping its other parts works.
  • After: every part of the Pressable fires onPress; pull to refresh still shows the indicator and refreshes.

Checked on: Samsung S21 (Android 15), React Native 0.86.3 (Fabric), built from source with this change. In our app, a filter chip at the top of a pull-to-refresh list: before, taps inside the indicator's resting box (CircleImageView, GONE, at [650,305][790,445]) never reached the chip; after, 9 of 9 taps across that box selected it.

🤖 Generated with Claude Code

@meta-cla

meta-cla Bot commented Oct 27, 2026

Copy link
Copy Markdown

Hi @bitsniper-ai!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bitsniper-ai
bitsniper-ai force-pushed the fix/touch-target-skip-hidden-children branch from c78ad09 to 4cdbf24 Compare October 27, 2026 03:53
@meta-cla

meta-cla Bot commented Oct 27, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 27, 2026
@meta-cla

meta-cla Bot commented Oct 27, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 27, 2026
@meta-codesync

meta-codesync Bot commented Oct 27, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D127811837.

@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 4cdbf24e7ddb.

ios: no capture

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant