fix(ios): prevent menu-dismissal taps from triggering underlying views - #177
Open
arobdog wants to merge 1 commit into
Open
fix(ios): prevent menu-dismissal taps from triggering underlying views#177arobdog wants to merge 1 commit into
arobdog wants to merge 1 commit into
Conversation
The tap that dismisses an open context menu is also delivered to the app window, so React Native pressables underneath fire — dismissing a menu could press a button or navigate. While a menu is displayed, cover the window with a transparent view that consumes touches, removed when the menu ends. Removal (and onCancel) is keyed to the configuration that actually displayed: the view attaches two menu interactions sharing one delegate, and the one that never displayed also reaches willEndForConfiguration — on the long-press path at finger release, while the menu is still open — which would otherwise remove the scrim early and fire a spurious onCancel. Closes mpiannucci#120
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Problem
On iOS, the tap that dismisses an open context menu is also delivered to the app window, so React Native pressables underneath it fire. Dismissing a menu by tapping elsewhere can press a button, select a row, or navigate - reported in #120, and reproducible in both
dropdownMenuModeand the long-press flow.Fix
While a menu is displayed, cover the window with a transparent
UIViewthat consumes every touch, and remove it when the menu ends. The menu itself is unaffected (it lives in its own system window above the app's). This is the approach posted in #120's thread (credit to that diff), with two changes found necessary in production use:willEndForConfiguration— on the long-press path this happens at finger release, while the menu is still open. Unguarded, that removes the scrim early (reintroducing the bug for long-press-opened menus) and fires a spuriousonCancel. The same guard therefore also fixesonCancelfiring while the menu is still visible.didMoveToWindowif the view unmounts while a menu is open.Android needs no equivalent: its native menu consumes the outside-dismiss touch (verified on device).
Testing
Verified in a production React Native app (new architecture, RN 0.7x) on iOS simulator and devices: menus opened by tap and by long-press; dismissal taps on rows/buttons/tab bar only dismiss; menu item selection,
onPress, andonCancelall behave as before; no scrim leak after unmount-while-open.Closes #120