Skip to content

[NET12] Show ContextFlyout context menus on iOS and Android - #40482

Merged
kubaflo merged 10 commits into
mainfrom
jfversluis-context-menus-all-elements
Dec 2, 2026
Merged

kubaflo merged 10 commits into
mainfrom
jfversluis-context-menus-all-elements

Conversation

@jfversluis

@jfversluis jfversluis commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 299baba4fef8b9445e41228b8284cbfdde2372d4

Dimension Assessment Rationale
Change confidence 8/10 ↑ Device tests pass on Android (45/45), iOS 26.5 (20/20) and Mac Catalyst (28/28); the new tests fail without their fixes.
↑ iOS (11/11) and Android (21/22, resolution guard only) ContextActions UI tests pass locally.
↓ The Mac Catalyst and Windows UI tests changed to send a real right-click but couldn't run locally; CI for this revision is pending.
↓ Windows and VoiceOver on a device are untested.

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

FlyoutBase.ContextFlyout now works on every view on iOS and Android, not only on Windows and Mac Catalyst. It reuses the existing MenuFlyout, MenuFlyoutItem, MenuFlyoutSubItem and MenuFlyoutSeparator API, so items, submenus, separators, Command/CommandParameter, IsEnabled and bindings all work as they do on desktop. Icons work on iOS and Mac Catalyst; Android context menus don't show icons natively, so they're left out there. This is similar to what Plugin.Maui.NativeContextMenus offers, but built in.

<Border>
    <FlyoutBase.ContextFlyout>
        <MenuFlyout>
            <MenuFlyoutItem Text="{Binding PinText}" Command="{Binding PinCommand}" />
            <MenuFlyoutSubItem Text="Share">
                <MenuFlyoutItem Text="Copy link" IconImageSource="{FontImageSource Glyph=...}" />
            </MenuFlyoutSubItem>
            <MenuFlyoutSeparator />
            <MenuFlyoutItem Text="Delete" Command="{Binding DeleteCommand}" />
        </MenuFlyout>
    </FlyoutBase.ContextFlyout>
    ...
</Border>

It only lights up for views that set a ContextFlyout. Views without one get no interaction, listener or tracking, so they behave exactly as before.

Context menu on iOS and Android

Submenus on iOS and Android

Behavior matches each platform

The goal was to behave the way a native app on each platform does, and to keep everything that works today working.

iOS (UIContextMenuInteraction)

  • Opens on long press, with the system lift preview. The preview follows the view's clip and corner radius.
  • Like native, the context menu takes over the long press, including from a LongPressGestureRecognizer. Reordering a CollectionView keeps its long press.
  • Separators are rendered as inline sections, which is how UIKit draws menu dividers. Submenus and icons work.

Android (the platform's own context menu, View.ShowContextMenu)

  • Opens on long press at the press point, as well as with a secondary (right) mouse click and by holding Enter or the D-pad center on a focused view (at its center). Like native, it opens as a dialog for TalkBack and on Android 6 and earlier.
  • Like native View.createContextMenu, the menus of the view's ancestors are added after its own.
  • Long press priority follows Android: a view that already handles a long click (for example a LongPressGestureRecognizer, or CollectionView reordering) keeps it. The menu still opens with a secondary click or the keyboard.
  • An accessibility action is added so the menu is reachable with TalkBack.
  • Submenus, separators (dividers between groups, Android 9+) and IsEnabled work. Like native Android context menus, items have no icons.
  • Long presses are detected by MAUI rather than by making views long-clickable (see Related PRs for why); only showing the menu is left to Android.

Text inputs (Entry, Editor, SearchBar) on all three platforms

Native text fields keep their own selection on long press, so these don't get a separate menu. Instead, the ContextFlyout items (theirs or an ancestor's) are added to the system's text menus, as native apps do:

  • iOS and Mac Catalyst 16+: added to the edit menu (GetEditMenu). On earlier versions the context menu opens on long press.
  • Android: added to the selection and insertion toolbars, and to the native context menu shown for a secondary click.

Flyout items in the text menus on iOS and Android

Lift preview on a rounded card on iOS and Android

Mac Catalyst fixes

The iOS path is shared with Mac Catalyst, so these are fixed there as well:

  • Context menu submenus were merged into the main menu bar. They are now standalone menus.
  • An unsupported icon source crashed while building the menu. The item is now shown without an icon.
  • The interaction and the flyout handler were not cleaned up when the view's handler was disconnected.

Opt-out

Apps that already set ContextFlyout for Windows or Mac Catalyst will now also see those menus on iOS and Android, and the items in the text menus on all three. To keep the previous behavior, set this in the project file:

<MauiEnableMobileContextFlyouts>false</MauiEnableMobileContextFlyouts>

It's a trimmable feature switch (RuntimeFeature.AreMobileContextFlyoutsEnabled), documented in docs/design/FeatureSwitches.md. With it off, iOS and Android show no context menus and the text menus only show system items. Windows is unaffected.

Public API

The only public API change is two overrides, for both net-ios and net-maccatalyst:

override Microsoft.Maui.Platform.MauiTextField.GetEditMenu(UIKit.UITextRange! textRange, UIKit.UIMenuElement![]! suggestedActions) -> UIKit.UIMenu?
override Microsoft.Maui.Platform.MauiTextView.GetEditMenu(UIKit.UITextRange! textRange, UIKit.UIMenuElement![]! suggestedActions) -> UIKit.UIMenu?

Limitations

  • Platform limitations are documented on FlyoutBase.SetContextFlyout and MenuItem.IconImageSource: no icons on Android, a dialog on Android 6 and earlier and for accessibility services, dividers only on Android 9+, and only file and font icons on iOS and Mac Catalyst.
  • To add the flyout items, an OnCreateContextMenuListener is temporarily set on the window's decor view while Android builds the context menu (Android builds it from the view up to the decor view). Android has no getter for it, so an app's own listener on the decor view would be replaced. Apps don't normally set one there, as it would make the whole window long-clickable.
  • Android hosts that aren't a MauiAppCompatActivity (embedding) can't observe touches before they're dispatched. There, a long press opens the menu only on views that already take taps (like a Button), because making other views long-clickable would stop their taps from reaching their parents. All views keep the accessibility long-click action.

Tests

  • Device tests in Controls.DeviceTests (ContextFlyoutTests*.cs): menu building, merging, priority rules, text menus, key and touch handling, CollectionView reordering, embedded hosts, and the opt-out switch.
    • Android: 45/45 on an API 36 emulator. Earlier revisions passed on a Pixel 10 (API 36) and on API 37 and API 29 emulators.
    • iOS 26.5 simulator: 20/20
    • Mac Catalyst: 28/28
    • The tests added for review feedback were checked to fail without their fixes.
  • UI tests (Issue33402, 6 tests), covering:
    • bound commands on items and submenu items;
    • parent taps and CollectionView selection still working;
    • long press on a view with a gesture following the platform;
    • an Entry keeping native text selection (Android) or cursor placement (iOS), with the system text actions, while showing the flyout items.
    • On Mac Catalyst and Windows the tests send a real secondary click. App.RightClick sends a click command that the mouse actions perform as a primary click.
  • Regression runs:
    • ContextActions UI tests: iOS 11/11. Android 21/22: the failure is ActionModeMenuShouldNotBeVisibleAfterSwitchingTab, a visual test that requires a specific emulator resolution.
    • Android CollectionView (146 passed, 0 failed) and Gesture (3/3) device tests.
    • Android DragAndDrop and Gestures UI tests: every failure passed on a rerun, except PanGestureDoesNotFlickerWhenResizingView and SwipeGesture, which fail the same way without this PR on that emulator.
  • Manually tested at runtime on the iOS simulator, a Pixel 10, an Android emulator, and Mac Catalyst with a right-click. Also tested with TalkBack (before Android switched to its native context menu; the accessibility action is covered by device tests since), and with the opt-out switch on a device.
  • Not yet tested: Windows (its code path is unchanged) and VoiceOver on a physical device. The Mac Catalyst and Windows UI tests couldn't run locally (the Mac2 driver doesn't start on this machine), so they rely on CI.

Recordings

iOS:

ios-context-menus.mp4

Android:

android-context-menus.mp4

Related PRs

#40470 (draft) also targets #33402. Both show Android's own context menu. The difference is how it's opened: #40470 sets OnCreateContextMenuListener on the view, which makes it long-clickable, and lets Android open the menu. That's much smaller, and Android then provides ancestor merging, right-click, keyboard and TalkBack itself. But long-clickable views also consume taps, and views with MAUI gesture recognizers never get the native long click, so this PR detects the long press itself and only lets Android show the menu.

Comparison
#40470 This PR
Android menu Android's own context menu Android's own context menu
Android icons No No (native context menus don't show them)
Taps on Android The view becomes long-clickable and consumes taps: a parent's tap gesture or CollectionView selection stops working on items with a menu Unchanged (UI tests)
Views with MAUI gesture recognizers (Android) No menu: the gesture touch listener stops the native long click Menu opens
LongPressGestureRecognizer, CollectionView reordering Not handled Each platform's native priority
Text inputs The menu replaces text selection Selection is kept; items are added to the system text menus
iOS submenus Menu-bar code path; titles that parse as a UIMenuIdentifier ("Share", "Edit", ...) look like they could crash Standalone context menus
iOS separators Empty sections, likely not drawn Inline sections (dividers)
Mac Catalyst fixes, opt-out switch No Yes
Tests 3 device tests Device tests on Android, iOS and Mac Catalyst; 6 UI tests; runtime verification
Size ~240 lines ~3,900 lines (~1,600 of them tests)
Android detection Android's own (right-click, keyboard, TalkBack for free) MAUI's own touch, key and accessibility handling

The #40470 iOS rows come from reading its code, not from running it.

Issues Fixed

Fixes #33402

jfversluis and others added 6 commits November 18, 2026 14:00
FlyoutBase.ContextFlyout (MenuFlyout, MenuFlyoutItem, MenuFlyoutSubItem,
MenuFlyoutSeparator) previously only worked on Windows and Mac Catalyst.
It now opens native context menus on iOS and Android too, using the
existing API. Views without a ContextFlyout are unaffected.

iOS / Mac Catalyst
- Enable the existing UIContextMenuInteraction path on iOS (long press)
  and register MenuFlyoutHandler on iOS.
- Build context sub menus as standalone UIMenus instead of going through
  the main menu bar builder (NRE on iPhone; on Catalyst, sub items titled
  like a main menu, e.g. "Edit", were merged into the menu bar).
- Draw separators as inline sections, ignore unsupported/empty icons
  instead of throwing, skip menus for disabled, input transparent or
  empty flyouts, and clean up the interaction on handler disconnect.

Android
- New ContextFlyoutManager shows an AndroidX PopupMenu built from the
  flyout each time it opens (sub menus, group dividers for separators,
  icons, disabled items, commands).
- New ContextFlyoutTouchTracker observes touches before
  MauiAppCompatActivity / modal dialogs dispatch them, so views keep
  their touch behavior (parent taps, CollectionView selection,
  scrolling). Long press and secondary click open the menu, then the
  in-flight touch is cancelled. Shift+F10 / Menu key and the TalkBack
  long-click action are supported; a native long-click listener is used
  outside MauiAppCompatActivity.

Tests: device tests for Android and iOS/Catalyst and an Appium UI test
(Issue33402).

Fixes #33402

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…lyout

A context flyout is purely additive: everything a long press did before
keeps working, and Mac Catalyst behaves as it did before iOS support.

- iOS and Android: when the element, an ancestor or the view under the
  finger already handles long press, it keeps priority over the context
  flyout: LongPressGestureRecognizer, drag (Android), text selection in
  Entry/Editor, CollectionView reordering, ListView context actions and
  tooltips (Android). The menu still opens with a secondary click or
  Shift+F10, and the TalkBack long-click action falls back to the view's
  own behavior. MAUI marks its own long-press recognizers instead of
  guessing, because UIKit adds long-press recognizers to some views
  (e.g. collection view cells).
- Android: drop the Menu key trigger, which opens the options menu.
- Mac Catalyst: disabled controls keep opening their context menu.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Keyboard: holding Enter / D-pad center on a focused, clickable control
  opens its context flyout (or the closest ancestor's), like a native
  long click; the key release then doesn't click. A short press still
  clicks. Shift+F10 was removed: Android doesn't use it.
- Position: menus open where the view was pressed or right-clicked
  (and at the center of the view for the keyboard), like native context
  menus, instead of at the view's corner. An invisible 1x1 anchor is
  removed once all menus, including sub menus, are closed.
- Icons: items without an icon are laid out like a native popup menu,
  without reserved icon space.

Keys are observed on the focused view through its KeyPress event, set
up from the activity's existing OnPostCreate, so no public API changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
iOS: let UIKit arbitrate like native apps, so the context menu wins over
long-press gestures and text selection. Only CollectionView reordering keeps
the long press, including when the menu is on the collection or around it.

Android: follow View.performLongClickInternal. The innermost view under the
finger that takes touches handles the long press: its own long-press handler
(gesture recognizer or long-click listener) comes first, then the context
menu of that view or its closest ancestor, before text selection and
tooltips. Touch targets follow ViewGroup's Z order, disabled and input
transparent gesture views and views whose menu can't show let touches
through, and pending gesture long presses under the finger are cancelled
when the menu opens. Holding a confirm key also works on views whose input
comes from tap gestures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Text inputs keep their own text selection, like native apps, and the items
of their context flyout (or an ancestor's) join the system's text menus:
- iOS/Mac Catalyst 16+: Entry, Editor and SearchBar add the items to their
  edit menu (MauiTextField/MauiTextView override GetEditMenu); a long press
  on them selects text instead of opening the context menu.
- Android: long press keeps selecting text and the selection/insertion
  toolbars show the items; a secondary click opens the native text context
  menu with the items added. Read-only text and text-based controls that
  don't select text (pickers) keep opening the context menu.

Android also follows native context menu composition: the menus of a view's
ancestors are added after its own. Keyboard long presses are tracked per
window and match native modifier handling per API level, touches reset when
their window goes away, and context menu actions on iOS keep working when
the menu is requested again.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Lets apps turn off the new iOS/Android context menus and the text menu
integration, restoring the previous behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 15:10
@github-actions

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot added area-controls-general General issues that span multiple controls, or common base classes such as View or Element platform/android platform/ios platform/macos macOS / Mac Catalyst labels Nov 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved Android flyout bugs can block keyboard and long-press activation, misplace popups in RTL, and display executable items from detached flyouts after asynchronous icon loading.

5 open issues
What changed in this PR

Extends .NET MAUI’s existing FlyoutBase.ContextFlyout API to iOS and Android for #33402, while integrating with native text menus and preserving existing gesture behavior.

Changes:

  • Adds mobile context-menu presentation, Android keyboard/accessibility support, and text-menu integration.
  • Fixes shared iOS/Mac Catalyst submenu handling, unsupported icons, and handler cleanup.
  • Adds an opt-out feature switch, documentation, samples, and device/UI regression coverage.
File Description
src/​Core/​src/​RuntimeFeature.cs Defines the mobile context-flyout feature switch.
src/​Core/​src/​PublicAPI/​net-maccatalyst/​PublicAPI.Unshipped.txt Records text edit-menu overrides for Mac Catalyst.
src/​Core/​src/​PublicAPI/​net-ios/​PublicAPI.Unshipped.txt Records text edit-menu overrides for iOS.
src/​Core/​src/​Platform/​iOS/​MenuExtensions.cs Builds separator sections and handles unsupported icons.
src/​Core/​src/​Platform/​iOS/​MauiUIContextMenuInteraction.cs Coordinates menu creation, text inputs, and reordering priority.
src/​Core/​src/​Platform/​iOS/​MauiTextView.cs Adds flyout items to Editor edit menus.
src/​Core/​src/​Platform/​iOS/​MauiTextField.cs Adds flyout items to Entry edit menus.
src/​Core/​src/​Platform/​iOS/​MauiSearchBar.cs Extends SearchBar text edit menus.
src/​Core/​src/​Platform/​iOS/​ContextFlyoutEditMenu.cs Merges flyout actions into native text menus.
src/​Core/​src/​Platform/​Android/​MauiAppCompatActivity.Lifecycle.cs Starts keyboard focus observation.
src/​Core/​src/​Platform/​Android/​MauiAppCompatActivity.cs Routes touch events through context-menu tracking.
src/​Core/​src/​Platform/​Android/​ContextFlyoutTouchTracker.cs Detects long presses and secondary clicks.
src/​Core/​src/​Platform/​Android/​ContextFlyoutTextMenus.cs Extends text toolbars and secondary-click menus.
src/​Core/​src/​Platform/​Android/​ContextFlyoutManager.cs Builds and presents menus with targeting and accessibility support.
src/​Core/​src/​Platform/​Android/​ContextFlyoutKeyTracker.cs Opens menus when confirm keys are held.
src/​Core/​src/​Handlers/​View/​ViewHandler.iOS.cs Enables iOS mapping and cleans up interactions.
src/​Core/​src/​Handlers/​View/​ViewHandler.cs Registers context-flyout mapping across platforms.
src/​Core/​src/​Handlers/​View/​ViewHandler.Android.cs Attaches and detaches Android menu managers.
src/​Core/​src/​Handlers/​MenuFlyoutSubItem/​MenuFlyoutSubItemHandler.iOS.cs Builds standalone context submenus.
src/​Core/​src/​Handlers/​MenuFlyoutItem/​MenuFlyoutItemHandler.iOS.cs Safely handles icons and actions from earlier menus.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue33402.cs Adds menu-command and input-behavior UI tests.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​Issue33402.xaml.cs Supplies commands and state for the test page.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​Issue33402.xaml Defines bound menus and gesture test scenarios.
src/​Controls/​tests/​DeviceTests/​Elements/​ContextFlyout/​ContextFlyoutTests.iOS.cs Tests Apple menu construction, text integration, and priority.
src/​Controls/​tests/​DeviceTests/​Elements/​ContextFlyout/​ContextFlyoutTests.cs Adds shared fixtures and switch-testing helpers.
src/​Controls/​tests/​DeviceTests/​Elements/​ContextFlyout/​ContextFlyoutTests.Android.cs Tests Android menus, input routing, and accessibility.
src/​Controls/​src/​Core/​Platform/​ModalNavigationManager/​ModalNavigationManager.Android.cs Enables touch and keyboard tracking in modal windows.
src/​Controls/​src/​Core/​Platform/​GestureManager/​GesturePlatformManager.Android.cs Shares gesture priority and suppresses consumed key releases.
src/​Controls/​src/​Core/​Platform/​Android/​TapAndPanGestureDetector.cs Supports cancelling pending gesture long presses.
src/​Controls/​src/​Core/​Menu/​FlyoutBase.cs Documents platform behavior and opt-out configuration.
src/​Controls/​src/​Core/​Hosting/​AppHostBuilderExtensions.cs Registers the iOS MenuFlyout handler.
src/​Controls/​src/​Core/​Handlers/​Items2/​iOS/​ReorderableItemsViewController2.cs Preserves reordering priority in the current Apple handler.
src/​Controls/​src/​Core/​Handlers/​Items/​iOS/​ReorderableItemsViewController.cs Preserves reordering priority in the legacy Apple handler.
src/​Controls/​src/​Core/​Handlers/​Items/​Android/​MauiRecyclerView.cs Marks reordering as taking long-press priority.
src/​Controls/​src/​Build.Tasks/​nuget/​buildTransitive/​netstandard2.0/​Microsoft.Maui.Controls.targets Exposes the opt-out through MSBuild configuration.
src/​Controls/​samples/​Controls.Sample/​Pages/​Core/​ContextFlyoutPage.xaml Updates sample labels to mention long press.
docs/​design/​FeatureSwitches.md Documents the switch, default, and platform scope.

Review effort: Balanced

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 20, 2026
Show the flyout with View.ShowContextMenu instead of an AndroidX PopupMenu,
like native Android context menus: at the press point on Android 7.0+,
as a dialog for accessibility services and earlier versions. The items
are added by a listener on the window's decor view while the menu is
built. Native context menus don't show icons, so they're no longer shown
on Android; this and the other platform limitations are documented.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MauiBot

MauiBot commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@jfversluis — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform iOS


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved context-flyout regressions suppress header/footer menus when reordering is enabled, break Android keyboard access, and allow stale menu ownership to dismiss unrelated text menus.

6 open issues
2 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs
#	src/Controls/src/Core/Platform/GestureManager/GesturePlatformManager.Android.cs
#	src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
#	src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
#	src/Core/src/RuntimeFeature.cs
Copilot AI balanced review requested due to automatic review settings November 30, 2026 22:09
@github-actions github-actions Bot added s/autopilot-reviewing MAUI Autopilot: MAUI expert review in progress and removed s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) labels Nov 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active issues leave iOS context-menu image updates throwing, Android wrapped controls bypassing long-press gesture priority, and key tracking replacing native listeners and breaking keyboard behavior.

3 open issues

Review effort: Balanced

if (VirtualView.IsInContextFlyout())
{
UIImage? contextUiImage = VirtualView.Source.GetPlatformMenuImage(MauiContext!);
UIImage? contextUiImage = VirtualView.Source.GetPlatformContextMenuImage(MauiContext!);
if (!ContextFlyoutManager.HasFlyoutFor(focused))
return;

focused.KeyPress += OnKeyPress;
return true;
}

return HasLongPressHandler(target, Get(target));

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 14 findings

Reviewed commit 9e3d3fa.

See inline comments for details.

if (VirtualView.IsInContextFlyout())
{
UIImage? contextUiImage = VirtualView.Source.GetPlatformMenuImage(MauiContext!);
UIImage? contextUiImage = VirtualView.Source.GetPlatformContextMenuImage(MauiContext!);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[critical] Logic and Correctness Verification - Opening an iOS context flyout containing a UriImageSource or StreamImageSource still throws InvalidOperationException. This helper ignores the icon during creation, but ElementHandler.SetVirtualView subsequently runs the Source mapper: MapSource -> UpdateImageSource -> GetPlatformMenuImage, which throws for the same source. The Source mapping from #40072 is present in the pinned head, so the creation-only fallback also fails for text edit menus and subsequent icon updates on iOS/Mac Catalyst. Apply the context-menu image policy in the mapper too. UnsupportedIconSourceIsIgnored already supplies the triggering input.

if (manager._usesLongClickFallback || !view.IsAttachedToWindow || !view.IsShown || !view.Enabled || view.RootView != root || !manager.CanShow())
continue;

if (!TryMapToLocal(root, view, x, y, out _, out _))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] Performance-Critical Path Optimization - Every ordinary ACTION_DOWN scans all registered flyouts before native touch dispatch. For each eligible view, TryMapToLocal allocates an ancestor List and backing storage and traverses native parents before rejecting an out-of-bounds point. A ScrollView containing 100 attached, shown rows with nonempty flyouts therefore adds at least 100 lists/backing arrays and 100 JNI parent-chain traversals to every tap or scroll start, even without opening a menu; IsShown does not exclude offscreen rows clipped by the viewport. Restrict lookup to the touched branch and avoid an allocated ancestor chain per candidate. The touch tests do not exercise this scaling case.

}
else
{
ContextFlyoutManager.Attach(handler, platformView);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] Logic and Correctness Verification - For an Android Label with Clip or Shadow, gestures attach to handler.ToPlatform(), the WrapperView, but this registers the flyout on the inner PlatformView. DefersLongPress checks the inner label's gesture state instead of its wrapper's, so the same label's long-press/drag recognizer loses priority and the menu opens instead. A wrapper focused for a TapGestureRecognizer also cannot find its inner flyout through the ancestor-only keyboard lookup. Account for the effective container in registration and lookup, including container changes. The priority and keyboard fixtures use unwrapped labels.

itemView = itemView.Parent as AView;

return itemView is not null && GetChildViewHolder(itemView) is { } holder &&
_itemTouchHelperCallback.GetMovementFlags(this, holder) != 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] CollectionView - Android (Items/) - With CanReorderItems=true, SelectionMode=None, plain non-interactive rows, and a flyout on the CollectionView, FindTouchTargetAt skips the row and falls back to the RecyclerView itself. CanStartReorderAt then walks outside the recycler and returns false, so the menu timer opens first and cancels reordering. Resolve the holder from the press location, not only a touch-consuming descendant. The opposite error occurs with EmptyViewAdapter: its negative header/footer/placeholder types receive nonzero flags because GetMovementFlags excludes only the normal adapter's header/footer constants, suppressing empty-state flyouts despite there being no source item to reorder. Check the active adapter too. The real-collection fixture uses populated rows with item-level flyouts and misses both cases.


var writer = new ContextFlyoutManager.MenuWriter((menuItem, element) => items[menuItem.ItemId] = new WeakReference<IMenuElement>(element))
{
FirstGroupId = FirstGroupId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] Logic and Correctness Verification - The app's existing action-mode callback can add an item with group ID 1000 and item ID 1000. These fixed starting IDs give the first flyout leaf the same identifiers: OnActionItemClicked mistakes the app item for the flyout leaf and executes the wrong command, and the next Update deletes the app item through RemoveGroup(1000). Allocate identifiers that do not collide with existing entries and remove only owned items. ToolbarCallbackStub uses group 0/item 1, so the custom-callback test cannot detect this collision.

}

_pendingNativeMenu = null;
SetMenu(scope.Menu, scope.SubMenus, null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Async and Threading Safety - In an embedded Android host, call PerformLongClick on flyout-bearing button A, then invoke button B's accessibility long-click action before yielding. B rebuilds the window's reused menu and becomes its owner, but A's pending scope is unchanged. This queued SetMenu then assigns B's menu to A, so removing A closes B's menu. Dismiss also closes a pending scope's menu without checking whether another request replaced it. Track a menu/request generation so superseded scopes cannot adopt or close newer menus. The fallback-removal fixture covers teardown before adoption, not replacement by another menu.

if (!ShowNativeContextMenuCore(view, position, CollectFlyouts(view), out var menu, out var subMenus))
return false;

SetMenu(menu, subMenus, position);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Async and Threading Safety - A synchronous ContextMenuCreated subscriber can clear the target's ContextFlyout while Show is constructing the menu. Detach calls Dismiss before this request has populated either _menu or _pendingNativeMenu, so nothing is closed. The root listener still holds the collected flyout and adds its items, and this SetMenu adopts the result after teardown, leaving the removed flyout's menu open. Track the synchronous request through teardown and revalidate attachment before adopting its result. The removal regression test exercises posted native-long-click adoption, not removal from a menu-construction callback.

return null;
}

partial void DisconnectingHandler(PlatformView platformView)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Regression Prevention and Test Coverage - The iOS/Mac Catalyst disconnect-cleanup fix has no discriminating regression test. InteractionIsAddedAndRemovedWithContextFlyout clears the flyout while its owning handler stays connected; no added test disconnects that handler with ContextFlyout still set and asserts teardown. Omitting this cleanup therefore leaves the current assertions unchanged. Build a menu, disconnect the owning view handler, assert that the interaction is removed and the flyout handler is disconnected, then verify reconnection restores the menu.

Assert.Equal(1, copyClicks);

// Disabled items do nothing
Assert.True(callback.OnActionItemClicked(null, FindItem(menu, "Disabled")));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Regression Prevention and Test Coverage - This disabled-action assertion cannot detect activation of the disabled item: copyClicks observes only Copy, while Disabled has neither a Clicked subscriber nor a command. Removing ToolbarCallback.OnActionItemClicked's IsEnabled guard still satisfies this assertion even though MenuItem.Activate raises Clicked for disabled items. Observe the disabled item's Clicked event directly, including an item disabled after the toolbar was built, to discriminate the current-state rejection path.

{

#if WINDOWS || MACCATALYST
#if WINDOWS || IOS || MACCATALYST

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Backward Compatibility and Migration - This unconditional iOS default changes custom-handler resolution even with MauiEnableMobileContextFlyouts=false. In an app using UseMauiApp, TryAddHandler(typeof(MenuFlyout), typeof(CustomFlyoutHandler)) previously installed the custom handler on iOS; HasEnabledElementHandlerDefault now sees this attribute and skips that registration, selecting MenuFlyoutHandler instead. Preserve the previous resolution when disabled, or document migration to AddHandler in HandlerResolution.md's Behavior changes section; the opt-out guidance does not explain this difference.

[moderate] Trimming and AOT Compatibility - The PublicConstructors-annotated attribute also roots MenuFlyoutHandler independently of the disabled mapping branch in full-trim/NativeAOT apps that construct MenuFlyout in shared XAML. Use the existing conditional nested-attribute pattern to return null on iOS when the feature is disabled, preserving Windows/Mac Catalyst defaults. The device fixtures explicitly register MenuFlyoutHandler and bypass this attribute.

@github-actions github-actions Bot added s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) and removed s/autopilot-reviewing MAUI Autopilot: MAUI expert review in progress s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) labels Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

MAUI Autopilot — Stopped

@kubaflo ❌ The last fix round found nothing more it could fix. Decide how to continue, or comment /review autopilot to run it again. Run.

@github-actions github-actions Bot added the s/autopilot-needs-maintainer-decision MAUI Autopilot stopped: a maintainer needs to decide how to continue label Nov 30, 2026
kubaflo added a commit that referenced this pull request Dec 1, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Proposes an opt-in cross-platform `Picker.PresentationMode` API with
`PickerPresentationMode.Default` and `Menu`. `Default` preserves the
existing presentation; the default interface member also preserves
existing custom `IPicker` implementations.

```xaml
<Picker PresentationMode="Menu" ItemsSource="{Binding Choices}" />
```

| Platform | Menu presentation |
| --- | --- |
| iOS / Mac Catalyst | Native UIButton menu over the existing styled
picker field |
| Android | Anchored AppCompat ListPopupWindow, shared by classic and
Material picker handlers |
| Windows | Existing native ComboBox dropdown |

Synchronizes selection, open/focus state, item changes, enabled state
and Apple accessibility. Changing mode dismisses the active presenter
without changing selection. Menu contents use system styling; the closed
field keeps its existing text/title/font/color mappings. Includes
bindable validation, API entries for every platform partition, unit
coverage and platform device coverage. No Sandbox changes.

**Apple limitation:** Native menu activation via `IsOpen`/`Focus`
requires iOS or Mac Catalyst 17.4+. Earlier supported versions can open
the menu through user interaction; unsupported programmatic opening logs
a warning and resets `IsOpen`. This is documented on the API. Native
presentation completion is observed before reporting the menu open, so
immediate dismissal works correctly.

Designed independently before searching other proposals. No open PR
implementing this Picker API was found; #40439 and #40482 concern
general context menus rather than this Picker selection presentation.

**Local validation** (repository-pinned .NET 12 SDK):

- `.dotnet/dotnet
artifacts/bin/Controls.Core.UnitTests/Debug/net12.0/Microsoft.Maui.Controls.Core.UnitTests.dll
--filter-class Microsoft.Maui.Controls.Core.UnitTests.PickerTests` —
passed, 67 tests.
- `.dotnet/dotnet build src/Core/src/Core.csproj -f net12.0-android37.0
--no-restore -p:PublicApiType=Validate -m:1 -v:q` — passed, zero
warnings/errors.
- `.dotnet/dotnet build src/Core/src/Core.csproj -f net12.0-ios27.1
--no-restore -p:PublicApiType=Validate -m:1 -v:q` — passed, zero
warnings/errors.
- `PublicApiType=Validate DOTNET_ROOT="$PWD/.dotnet"
DOTNET_ROLL_FORWARD=Major .dotnet/dotnet tool run pwsh -- -NoProfile
-File .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1
-Project Core -Platform maccatalyst -IncludeClasses
Microsoft.Maui.DeviceTests.PickerHandlerTests -IncludeMethods
MenuPresentationTracksItemsSelectionAndAccessibility,MenuPresentationOpensAndDismissesWithoutChangingSelection
-Configuration Debug -SkipXcodeVersionCheck -OutputDirectory
artifacts/log/picker-menu -Timeout 00:15:00` — passed, 2 tests, genuine
native TRX verified. Used installed Xcode 27.2 with a workload expecting
27.1; the version-check override is explicit.
- Scoped `dotnet format whitespace` and `git diff --check` — passed.

Android device execution, iOS simulator execution and Windows
build/device execution were not run locally; platform CI remains
required. An additional Android device-test BuildOnly attempt and an
isolated single-node compile both stalled without compiler output and
were stopped; they are not passing validation evidence. The Android
framework build above did complete successfully.

- Re-run on final head `8f50764074` (Mac Catalyst device tests above,
same command): passed 2/2 per native TRX; Android `Core.csproj` build at
head: passed, 0 warnings/errors.

**Initial CI:** [Pester
scripts](https://github.com/dotnet/maui/actions/runs/46619448948)
reports 18 failures. All 18 failing identities match the [latest
completed main
baseline](https://github.com/dotnet/maui/actions/runs/46459374473)
(2,476 passed / 18 failed in both runs); they concern unchanged
release/automation scripts. Native Azure DevOps results are not yet
available. Full CI is not claimed green. The optional `ci-analysis`
skill/script was unavailable in this session; the GitHub workflow logs
were inspected directly.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #23999

### Let AI finish this PR

- [ ] **Let the MAUI agent address review feedback and fix remaining
issues on this PR.** Maintainers still decide whether it is merged. For
PRs from forks, keep "Allow edits by maintainers" on so the agent can
push to your branch; otherwise it opens a follow-up PR that keeps your
commits.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch
designated for that work.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo
kubaflo previously approved these changes Dec 2, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo

kubaflo commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Merged main and resolved the conflicts. Kept the mobile context flyout docs and Apple edit-menu APIs alongside the updated diagnostics docs and Picker APIs from main.

@dalexsoto stamp

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamping as requested by @kubaflo; no code review performed.

@kubaflo
kubaflo merged commit 873c706 into main Dec 2, 2026
4 of 6 checks passed
@kubaflo
kubaflo deleted the jfversluis-context-menus-all-elements branch December 2, 2026 11:55
kubaflo added a commit that referenced this pull request Dec 3, 2026
<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `9dcc527695b333857bbd78405b4fd5c2549f5bc4`

| Dimension | Assessment | Rationale |
| --- | --- | --- |
| Change confidence | 9/10 | ↑ Preserves selectable text and changes
only the editable branch predicate |
| Diagnosis confidence | 9/10 | ↑ Read-only mapping clears the native
listener while retaining focus |
| Evidence fit | 9/10 | ↑ Native API 33 TRX reproduces only the reported
row and passes all 18 with the fix |
<!-- /copilot-assessment -->

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

<!-- Enter description of the fix in this section -->

A long press on a focusable read-only `Entry` should open its context
flyout rather than defer to nonexistent native text editing. #40191
(`5c1da3386e`) kept the view focusable but clears its native
`EditText.KeyListener`; #40482 (`873c706238`) classified every eligible
`EditText` as selectable regardless of whether it can edit. Require a
key listener for the editable path while preserving native selection for
views explicitly marked selectable. The existing priority theory also
checks editable entries and secondary clicks.

**Validation:** Android API 33 arm64 emulator, CoreCLR; the runner
provisioned and cleaned up its own virtual device.

- `pwsh -NoProfile -File
.github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project
Controls -Platform android -IncludeMethods
Microsoft.Maui.DeviceTests.ContextFlyoutTests.LongPressFollowsNativePriority
-Timeout 00:25:00 -OutputDirectory
"$PWD/.local-temp/android-baseline-serial"` — **17 passed, 1 failed, 0
skipped** on unmodified `main`; only `ReadOnlyEntry` failed, matching
CI.
- `pwsh -NoProfile -File
.github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project
Controls -Platform android -IncludeMethods
Microsoft.Maui.DeviceTests.ContextFlyoutTests.LongPressFollowsNativePriority
-Timeout 00:25:00 -OutputDirectory "$PWD/.local-temp/android-fixed"` —
**18 passed, 0 failed, 0 skipped** with the fix, including editable
entries and secondary click.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Reported by [.NET MAUI device-test build
1707231](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1707231).

### Let AI finish this PR

- [ ] **Let the MAUI agent address review feedback and fix remaining
issues on this PR.** Maintainers still decide whether it is merged. For
PRs from forks, keep "Allow edits by maintainers" on so the agent can
push to your branch; otherwise it opens a follow-up PR that keeps your
commits.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Dec 3, 2026
…#41195)

<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `cefdfbd8a1cc0be652410d6ff60c58bfb23e3675`

| Dimension | Assessment | Rationale |
| --- | --- | --- |
| Change confidence | 9/10 | ↑ Filters only views inserted during native
presentation and reuses the weak table as the marker<br>↓ UIKit
implementation differs by OS |
| Diagnosis confidence | 9/10 | ↑ Instrumentation identified the UIKit
sibling and the interaction-count difference |
| Evidence fit | 9/10 | ↑ All four selected MenuFlyout rows passed on
the updated revision<br>↓ CI uses iOS 27.2 rather than 27.1 |
<!-- /copilot-assessment -->

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

<!-- Enter description of the fix in this section -->

Keep transient UIKit menu presentation subviews from becoming the
compatibility renderer's `PlatformView`. `c950332974` (#40439)
introduced both programmatic cases. The native menu button inserts an
additional UIKit sibling when it opens; the compatibility renderer's
existing filter only excludes MAUI's own presenter views. On iOS 27.1
that sibling became the renderer’s target, and it could still be present
when the menu was replaced. Track the views inserted by native
presentation weakly, for their lifetime, without relying on private
UIKit class names or owning their removal. Reuse the weak table itself
as the marker, matching the existing iOS long-press recognizer pattern.

The separate interaction-count failure was a stale expectation:
`873c706238` (#40482) added native iOS interactions when the mobile
feature is enabled. Replacing a flyout must remove its programmatic
presenter while retaining the platform context-menu interaction on
supported configurations.

**Validation:** iPhone Duo simulator on iOS 27.1, CoreCLR; the CI lane
used iOS 27.2.

```bash
selectors='Microsoft.Maui.DeviceTests.ButtonTests.ImageAndTextGroupHonorsAlignmentMapperCustomization,Microsoft.Maui.DeviceTests.ButtonTests.ImageAndTextGroupPreservesUnsetAlignmentAxis,Microsoft.Maui.DeviceTests.ButtonTests.ImageAndTextGroupRendersAtRequestedAlignment,Microsoft.Maui.DeviceTests.AccessibilityTests+InNewWindowCollection.ValidateIsImportantForAccessibility,Microsoft.Maui.DeviceTests.ContextFlyoutTests.ProgrammaticCompatibilityMenuCanReplaceAndActivate,Microsoft.Maui.DeviceTests.ContextFlyoutTests.ProgrammaticPresenterRemovedOnFlyoutChange'
menu='Microsoft.Maui.DeviceTests.ContextFlyoutTests.ProgrammaticCompatibilityMenuCanReplaceAndActivate,Microsoft.Maui.DeviceTests.ContextFlyoutTests.ProgrammaticPresenterRemovedOnFlyoutChange,Microsoft.Maui.DeviceTests.ContextFlyoutTests.ProgrammaticNativeMenuReopensAfterNativeDismissal'
```

- `pwsh -NoProfile -File
.github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project
Controls -Platform ios -DeviceUdid BF9ED2ED-8DA6-40F2-A979-A3698BA8BF36
-IncludeMethods "$selectors" -Timeout 00:25:00 -OutputDirectory
"$PWD/.local-temp/ios-baseline"` — two MenuFlyout failures, one pass.
- `pwsh -NoProfile -File
.github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project
Controls -Platform ios -DeviceUdid BF9ED2ED-8DA6-40F2-A979-A3698BA8BF36
-IncludeMethods "$selectors" -Timeout 00:25:00 -OutputDirectory
"$PWD/.local-temp/ios-fixed2"` — all three MenuFlyout rows passed,
including replacement and action activation; the two remaining failures
were Button cases outside this PR.
- `pwsh -NoProfile -File
.github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project
Controls -Platform ios -DeviceUdid BF9ED2ED-8DA6-40F2-A979-A3698BA8BF36
-IncludeMethods "$menu" -Timeout 00:25:00 -OutputDirectory
"$PWD/.local-temp/ios-menu-marker"` — **4 passed, 0 failed, 0 skipped**
on the updated PR revision, including native dismissal and reopening.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Reported by [.NET MAUI device-test build
1707231](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1707231).

### Let AI finish this PR

- [ ] **Let the MAUI agent address review feedback and fix remaining
issues on this PR.** Maintainers still decide whether it is merged. For
PRs from forks, keep "Allow edits by maintainers" on so the agent can
push to your branch; otherwise it opens a follow-up PR that keeps your
commits.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Dec 4, 2026
<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `4cc1459caf36f82344d8d007e906b1073a665b76`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 7/10 | Test-only change; iOS 26 passes 6/6
locally. The Mac Catalyst app and test project built, but the locked
desktop prevented XCTest from starting. Windows and iOS 18.5 still need
PR CI validation. |
| Diagnosis confidence | 8.5/10 | Windows CI logs and screenshots show a
window-relative element center passed to an absolute desktop click. iOS
18.5 still exposes Forward after the fixture's single advance. |
| Evidence fit | 8/10 | The red baseline is main CI builds 1707647 and
1707913: four Windows failures and one iOS 18.5 failure in each. No
matching local red baseline; fix-green evidence must come from
`maui-pr-uitests` on this PR. |

<!-- /copilot-assessment -->

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

<!-- Enter description of the fix in this section -->

- **Windows:** Add the session window's current origin to the element
center and pass `x` and `y` (without `elementId`) to [`windows:
click`](https://github.com/appium/appium-windows-driver/tree/v3.1.1#windows-click).
Build 1707913 found the right element: WinAppDriver returned `(13,75)`
with size `984×35`, but Appium clicked virtual-screen point `(505,92)`
before applying the centered window's origin. The screenshots show the
desktop context menu, not a missing app menu item. Windows passed in
[1707488](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1707488)
and failed in 1707647 and 1707913, consistent with window-position
dependence; the passing run's window origin was not captured.
- **iOS:** Follow a visible **Next Page**/**Forward** button up to five
times until **Entry item** is visible. If the menu is a scrollable list
with no forward button, keep using Appium's element tap to scroll the
item into view. Preserve selection and command assertions, Android
overflow handling, and Mac Catalyst's secondary-click behavior.

#### Validation

- **Main CI red baseline:**
[1707647](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1707647)
and
[1707913](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1707913)
each failed four Issue33402 Windows cases
(`ContextFlyoutRunsBoundCommand`,
`ContextFlyoutSubItemRunsBoundCommand`,
`ContextFlyoutOnChildDoesNotBlockParentTap`,
`ContextFlyoutOnCollectionViewItemKeepsSelectionWorking`) and one iOS
18.5 case (`LongPressOnEntryKeepsTextSelectionAndShowsFlyoutItems`). The
iOS page source shows an additional visible **Forward** button after the
test advanced once.
- **Local iOS 26.0:** `./.github/scripts/BuildAndRunHostApp.ps1
-Platform ios -Configuration Release -TestFilter
"FullyQualifiedName~Issue33402" -DeviceUdid
DBF8C370-1F32-48FE-AEF8-27FB4F2A1D9A` — **6 passed**, with headless
Appium and an isolated simulator. The unmodified suite also passed on
iOS 26.0; this is a regression check, not a local red-to-green result.
- **Local Mac Catalyst:** `./.github/scripts/BuildAndRunHostApp.ps1
-Platform maccatalyst -Configuration Debug -TestFilter
"FullyQualifiedName~Issue33402"` — HostApp and test project built;
XCTest could not initialize with the macOS session locked
(`Authentication cancelled. System authentication is running.`). No
Catalyst test case executed locally.
- **Local formatting:** `dotnet format whitespace --folder --include
src/TestUtils/src/UITest.Appium/Actions/AppiumTouchActions.cs
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33402.cs
--verify-no-changes` and `git diff --check` — both passed.
- **Not run locally:** Android; Windows; iOS 18.5 (the installed Xcode
versions could not download an 18.x simulator runtime). **Fix-green
evidence must come from `maui-pr-uitests` on this PR**, particularly the
Windows and iOS 18.5 lanes. No fix-green result is claimed yet.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Relates to #33402 (CI failures in the UI coverage added by #40482).

### Let AI finish this PR

- [ ] **Let the MAUI agent address review feedback and fix remaining
issues on this PR.** Maintainers still decide whether it is merged. For
PRs from forks, keep "Allow edits by maintainers" on so the agent can
push to your branch; otherwise it opens a follow-up PR that keeps your
commits.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-general General issues that span multiple controls, or common base classes such as View or Element platform/android platform/ios platform/macos macOS / Mac Catalyst s/autopilot-needs-maintainer-decision MAUI Autopilot stopped: a maintainer needs to decide how to continue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show ContextMenu on long press on visual element in mobile platform

5 participants