Repository navigation
fix(ios): pass taps to the children of a long-press MenuView on Fabric - #1233
Merged
Naturalclar merged 2 commits intoNov 15, 2026
Merged
Conversation
On the new architecture the menu's UIButton is the component's contentView, which React Native keeps above the children, so it took every touch: with shouldOpenOnLongPress a Pressable or a Text link inside never received its press, and VoiceOver read the whole view as one element because the view takes isAccessibilityElement from its contentView. When the menu opens on a long press, the UIContextMenuInteraction now lives on the component view and the button steps out of touches and accessibility. The interaction forwards to the button's own delegate methods, so the menu, its title and the open/close events are unchanged. The preview is the component view (iOS 16 and earlier delegate methods both covered), and themeVariant is applied to the component view in that mode. Tap-to-open menus are untouched.
Contributor
Author
|
Quick follow-up: I have now checked this on a real iPhone too, in a release build of our app. A link inside a long-press |
Naturalclar
approved these changes
Nov 15, 2026
Naturalclar
left a comment
Member
There was a problem hiding this comment.
LGTM! thank you! tested locally on my side as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #1183.
On the new architecture,
MenuView.mmsets the menu'sUIButtonas the component'scontentView. React Native adds the contentView withaddSubview:and mounts the children withinsertSubview:atIndex:, so the button always sits above the children, and nothing overrides the hit test. Every touch lands on the button and React's touch target becomes theMenuViewitself. WithshouldOpenOnLongPress, aPressableor aTextwithonPressinside never gets its press. It also hides the children from VoiceOver:RCTViewComponentViewtakesisAccessibilityElementfrom its contentView, so the whole menu reads as one element.With this change, when
shouldOpenOnLongPressis on, theUIContextMenuInteractionlives on the component view and the button steps out of touches and accessibility. The interaction forwardsconfigurationForMenuAtLocationandwillEndto the button, so the menu, its title andonOpenMenu/onCloseMenucome from the same code as before. A tap reaches the child under the finger and a long press opens the menu. Menus that open on a tap are not touched.A few details a reviewer will probably ask about:
@available/API_AVAILABLE, and the build adds no warnings toMenuView.mm. On the iOS 18.6 simulator the preview shows the content. I think this also covers [iOS 18] Context menu preview is blank when using shouldOpenOnLongPress with React Native Fabric (New Architecture) #1201, but I haven't tried its exact case.LegacyMenuViewImplementationis the view itself and the children are mounted inside the button, so the hit test already reaches them. I read it but didn't build or run it.shouldOpenOnLongPresschanges, so it relies onprepareForRecyclekeeping_props, asshowsMenuAsPrimaryActionalready does. There's a comment about it in the code.point(inside:), and the button no longer takes touches in long-press mode, sohitSlopis not applied there. I can move it to the component view if you want it kept.About #1218: it covers a related case differently, with a new
onPressprop for a tap on the anchor, driven by the button'stouchUpInside. This PR adds no prop; the children keep their own press handling. The two do overlap on iOS: with this change the button no longer takes touches in long-press mode, so if both land, the tap for #1218 would have to come from the component view rather than the button. Happy to adjust either way.I also added a small case to the example app: a long-press menu with a
Pressablecounter and a link-styleTextinside.Test Plan
Example app (React Native 0.81.1, new architecture, pods installed as in CI with
RCT_USE_PREBUILT_RNCORE=1 RCT_USE_RN_DEP=1, Release build), on the iOS 26.5 and iOS 18.6 simulators. In the new example case I tapped the counter twice and the link once, then long-pressed the counter and the link:Same results on both iOS versions.
Android (API 36 emulator, Debug): nothing changes. Taps already reach the children there. A long press opens the menu and the
Pressablealso fires on release, as it did before, because the AndroidMenuViewdoesn't cancel the JS touch.yarn typescript,yarn lintandyarn testpass.Not covered: a real device, listening with VoiceOver (I only checked the accessibility tree), the old architecture, and visionOS (I didn't build it).
I have screenshots of master against this branch on both iOS versions and on Android, and can add them here.