[Android] Fix native handlers attaching to a nested button instead of the detector's child - #4464
[Android] Fix native handlers attaching to a nested button instead of the detector's child#4464m-bert wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe Android gesture detector now attaches native handlers directly to each non- ChangesNative handler attachment
Merge Risk: ⚪ Minimal · up to This localized Android change corrects which view receives native gesture handling; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Removes Android-only logic that attempted to “dive into” the detector child view hierarchy to find an inner ButtonViewGroup, ensuring native gesture handlers attach to the GestureDetector’s direct child again (while preserving the existing RefreshControl unwrapping behavior).
Changes:
- Removed the
ViewGroup/ButtonViewGroupsearch path so the native handler target is always the detector’s direct child. - Deleted the now-unused
tryFindGestureHandlerButtonhelper and related imports.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Description
tryFindGestureHandlerButtonwas added in #3634 to find the button inside the wrapperViewof thedisplay: contentssandwich. #4044 replaced that structure with a single-view button, so the correct target is the detector's direct child again - but the search was left in and still fired whenever the child's first child happened to be a bareButtonViewGroup(e.g.PressableorTouchableas the first child of a button or of a view under a native-gesture detector), attaching the handler to that inner button instead.Before this change, the outer button in the test screen did not react to presses anywhere except over the inner pressable, and pressing the inner pressable fired the outer handler's callbacks alongside the inner ones (with a doubled
pressInon the inner pressable).This PR removes the search so native handlers always attach to the detector's child, with the existing exception of
RefreshControlunwrapping.Test plan
Compared builds from this branch and its base commit on the Android emulator using the test screen below:
Test screen