Repository navigation
fix: explain why ContextMenu.open is unavailable on iOS - #71
Merged
AdamMusa merged 1 commit intoNov 2, 2026
Merged
Conversation
The Cupertino ContextMenu registered no invoke listener, so a Ruby context_menu.open waited out its whole timeout. Flutter's CupertinoContextMenu opens only from its own long-press gesture (the open routine is private, there is no controller), matching UIKit where context menus cannot be presented from code. Reply immediately with an UnsupportedError that says so and points to action_sheet; other method names get the usual unknown-method error.
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.
Wave-3 item 3. Engine-only.
Problem
On iOS and macOS,
context_menu.openwaited for the whole Ruby timeout, because the Cupertino ContextMenu registered no invoke listener.Why there is no native implementation
Flutter 3.41.2's
CupertinoContextMenuopens only from its own long-press gesture:_CupertinoContextMenuState._openContextMenu()is private.actions,child/builderandenableHapticFeedback. There is no controller.This mirrors UIKit: a
UIContextMenuInteractioncannot be presented from code either. Simulating a long press with synthetic pointer events would be fragile, so I did not do it.Fix
The Cupertino renderer now registers a listener that replies immediately with:
Other method names get the usual
Unknown ContextMenu method: <name>error. Material is unchanged and keeps opening its popup at the given or center position.Relation to #59: the generic fail-fast fix would also stop the timeout here, but only with a generic "not supported" message. This PR adds the reason and the alternative. The two merge cleanly, and when both are in, this listener's message is the one Ruby sees.
Tests
test/widgets/ruby_context_menu_open_test.dart(3 tests):open: settles within one frame while the Ruby timeout is 30 s and fake time is not advanced. TheUnsupportedErrormentionsContextMenu.open,long pressandaction_sheet, and no menu is presented.closegetsUnknown ContextMenu method: close.open: still presents the menu (theCopyaction appears).Before the fix, iOS
opendid not settle, and the second test hung for 10 minutes (the real-time limit).verify_pr.sh(Flutter 3.41.2):