Repository navigation
Conversation
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.
Summary
Ruby's
ContextMenu(materials/contextmenu_control.rb, wire typeContextMenu) declareson_selectandon_dismiss. The Material renderer fires"select"when an item is chosen and"dismiss"when the menu closes without a choice. Both carry the payload{b, tr, id, idx, ic, g, l}.On iOS and macOS,
CupertinoContextMenuControlrenders Flutter'sCupertinoContextMenu. Before this fix, only each action's own"click"fired, socontext_menu(items: [...], on_select:, on_dismiss:)never reported either event.Fix
CupertinoContextMenuSelectioninherited widget wraps each action.CupertinoContextMenuActionControl, which also rendersPopupMenuItem, reports the pressed item to it before closing. The menu then fires"select"with the Material payload keys:idis the item id,idxits index among the visible items, andicthe item count. The item's own"click"still fires.CupertinoContextMenuhas no open or close callbacks, but its actions are only built while the menu route is up. Each wrapped action registers with the menu when it mounts and unregisters when it disposes. When the last one goes, the session has ended, and a session without a chosen item fires"dismiss". Because the count is reference-counted, a rebuilt sheet (for example after rotation) does not end the session.b: "primary"andtr: "longPress", because the native menu opens on a long press.gandlarenull, because the native menu reports no pointer position.Out of scope: the Cupertino renderer still ignores
primary_items,secondary_itemsandtertiary_items, since iOS has a single long-press trigger, and it does not wrap the menu inLayoutControl.Tests
New
test/widgets/ruby_context_menu_events_test.dart(Cupertino). It long-presses to open the native menu, then:selectwithid 4,idx 1andic 2, and nodismiss.clickand the menu'sselectwithidx 0.dismisswithic 2. A second session then reportsselectindependently.All three tests failed before the fix, with no menu events.
verify_pr.sh:flutter test+698, all passed (695 baseline + 3 new).flutter analyze lib testfound no issues. Flutter 3.41.2.Wave-2 follow-up P2