Skip to content

[iOS, Mac Catalyst] Rebuild the menu bar when the Text of a menu item changes - #40190

Merged
kubaflo merged 1 commit into
dotnet:candidate/11.0.1xx-sr2from
marcelomoresco:fix/21417-catalyst-menu-bindings
Nov 13, 2026
Merged

kubaflo merged 1 commit into
dotnet:candidate/11.0.1xx-sr2from
marcelomoresco:fix/21417-catalyst-menu-bindings

Conversation

@marcelomoresco

Copy link
Copy Markdown
Contributor

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

Description of Change

On iOS and Mac Catalyst, WindowHandler.MapMenuBar builds the menu bar inside BuildMenu and then disconnects the menu handlers, because a UIMenu can only be built while BuildMenu runs. After that, a change to MenuBarItem.Text or MenuFlyoutItem.Text reaches no handler, and the built UIMenu/UICommand keep their titles, so the menu bar shows the first text.

Adding or removing items already rebuilds the menu bar: MenuBarTracker calls Window.Handler.UpdateValue(MenuBar), which calls UIMenuSystem.MainSystem.SetNeedsRebuild(), and BuildMenu creates new handlers from the current values. A change of Text on a MenuBarItem, or on a MenuFlyoutItem/MenuFlyoutSubItem inside one, now does the same (MenuBar.UpdateWindowMenuBar, called from the propertyChanged of MenuBarItem.TextProperty and MenuItem.TextProperty). Items of a context flyout don't rebuild the menu bar.

IsEnabled (including Command.CanExecute) already updates since #35546, because ValidateCommand reads it when the menu opens, so this PR only changes Text.

On Windows the menu handlers stay connected and already update the text; the extra MenuBar update sets the same MenuBar instance again.

Tests

Unit tests (MenuBarItemTests, Controls.Core.UnitTests):

  • changing the Text of a MenuBarItem, of a MenuFlyoutItem in it, and of an item inside a MenuFlyoutSubItem updates the window's MenuBar once
  • changing the Text of a context flyout item doesn't update it

Results:

  • without the fix, the first three tests fail (Menu tests: 102 passed, 3 failed)
  • with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30 skipped, 0 failed (en-US locale; TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull fails under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a BuildMenu override that logs): renaming a MenuBarItem and a MenuFlyoutItem 6 seconds after launch makes UIKit call BuildMenu again 1-2 ms later. The rebuild then goes through the same path as adding an item, which MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation covers on Mac Catalyst. I launched the app from a script, so its window didn't have the active appearance and I couldn't take a screenshot of the menu bar.

Issues Fixed

Fixes #21417

… changes

WindowHandler.MapMenuBar builds the menu bar inside BuildMenu and then
disconnects the menu handlers, so a later change to MenuBarItem.Text or
MenuFlyoutItem.Text reached no handler and the menu bar kept the first
text.

A change of Text on a MenuBarItem, or on a MenuFlyoutItem inside one,
now asks the window to update its MenuBar, which calls
UIMenuSystem.MainSystem.SetNeedsRebuild, like adding or removing items
already does. Items of a context flyout don't rebuild the menu bar.

Fixes dotnet#21417
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40190

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40190"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Nov 12, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@marcelomoresco! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @marcelomoresco! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@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 12, 2026
@kubaflo

kubaflo commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

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

Result INCONCLUSIVE Platform Android


🧪 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 12, 2026

@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 — 0 findings

Reviewed commit 43d1b4a.

@kubaflo kubaflo 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.

Could you check the failing tests?

@marcelomoresco

Copy link
Copy Markdown
Contributor Author

@kubaflo I went through the failures in builds 1678187 (UI tests) and 1678188 (device tests):

  • Android UI tests (all shards, including Material3 and Shell Renderer): each job failed in install Gradle init script (Linux/macOS) (Bash exit code 1), after git fetch retries, before any test ran.
  • WinUI UI tests: each job failed in Set screen resolution (PowerShell exit code 1), before any test ran.
  • iOS and Mac Catalyst UI tests that ran: the failures are in CarouselView (Issue12848Test, AddItemsToCarouselViewWorks, VerifyCarouselViewItemsRenderAfterBinding, ...), CollectionView (CanTapButtonOnEmptyView, EnsureCollectionViewLayoutOnItemsSourceChange, VerifyVerticalItemSpacingPageRendering, VerifyGroupedCollectionViewVisibleItemIndices), HybridWebView (VerifyHybridWebView_SameHybridRootWithDifferentDefaultFile, ...), FlexLayoutCycleException and VerifyNavigationEventArgs. None of their pages has a menu bar, and this PR only does something when the Text of a MenuBarItem, or of a menu item inside one, changes.
  • Device tests: the Android (Mono) failure is the Essentials work item. The CoreCLR device tests passed on Android, iOS and Mac Catalyst, and the Helix unit tests passed.

Could you re-run the failed jobs?

@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 12, 2026
@MauiBot

MauiBot commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

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

Result INCONCLUSIVE Platform Android


🧪 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 12, 2026

@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 — 0 findings

Reviewed commit 43d1b4a.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@marcelomoresco — test-failure analysis for commit 43d1b4a.

Scope CI failures Commit 43d1b4a


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests

🧪 maui-pr-uitests

Matched failures predate these menu changes. All five target samples are partial; unmatched cases need equivalent base/head reproduction.


🧭 Follow-up — actions and refresh

Next action: Compare unresolved tests on base/head with identical setup; inspect Helix termination and restore missing UI diagnostics.

Maintainers: comment /review tests to refresh this report.

@kubaflo
kubaflo changed the base branch from net11 to candidate/11.0.1xx-sr2 November 13, 2026 21:05
@kubaflo
kubaflo merged commit 8086a15 into dotnet:candidate/11.0.1xx-sr2 Nov 13, 2026
127 of 182 checks passed
kubaflo added a commit that referenced this pull request Nov 13, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 17, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
… changes (#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes #21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
… changes (dotnet#40190)

<!-- 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!

### 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).

### Description of Change

On iOS and Mac Catalyst, `WindowHandler.MapMenuBar` builds the menu bar
inside `BuildMenu` and then disconnects the menu handlers, because a
`UIMenu` can only be built while `BuildMenu` runs. After that, a change
to `MenuBarItem.Text` or `MenuFlyoutItem.Text` reaches no handler, and
the built `UIMenu`/`UICommand` keep their titles, so the menu bar shows
the first text.

Adding or removing items already rebuilds the menu bar: `MenuBarTracker`
calls `Window.Handler.UpdateValue(MenuBar)`, which calls
`UIMenuSystem.MainSystem.SetNeedsRebuild()`, and `BuildMenu` creates new
handlers from the current values. A change of `Text` on a `MenuBarItem`,
or on a `MenuFlyoutItem`/`MenuFlyoutSubItem` inside one, now does the
same (`MenuBar.UpdateWindowMenuBar`, called from the `propertyChanged`
of `MenuBarItem.TextProperty` and `MenuItem.TextProperty`). Items of a
context flyout don't rebuild the menu bar.

`IsEnabled` (including `Command.CanExecute`) already updates since
dotnet#35546, because `ValidateCommand` reads it when the menu opens, so this
PR only changes `Text`.

On Windows the menu handlers stay connected and already update the text;
the extra `MenuBar` update sets the same `MenuBar` instance again.

#### Tests

Unit tests (`MenuBarItemTests`, Controls.Core.UnitTests):

- changing the `Text` of a `MenuBarItem`, of a `MenuFlyoutItem` in it,
and of an item inside a `MenuFlyoutSubItem` updates the window's
`MenuBar` once
- changing the `Text` of a context flyout item doesn't update it

Results:

- without the fix, the first three tests fail (Menu tests: 102 passed, 3
failed)
- with the fix, all of Controls.Core.UnitTests passes: 6738 passed, 30
skipped, 0 failed (en-US locale;
`TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNull` fails
under a pt-BR locale without this change too)

Mac Catalyst app (Sandbox with a `BuildMenu` override that logs):
renaming a `MenuBarItem` and a `MenuFlyoutItem` 6 seconds after launch
makes UIKit call `BuildMenu` again 1-2 ms later. The rebuild then goes
through the same path as adding an item, which
`MenuBarItemFeatureTests.MenuBarItem_LocationsMenuAddLocation` covers on
Mac Catalyst. I launched the app from a script, so its window didn't
have the active appearance and I couldn't take a screenshot of the menu
bar.

### Issues Fixed

Fixes dotnet#21417

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 30, 2026
…#40829)

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

Self-reported assessment, not an independent review.

Assessed revision: `7ee14bce88236c49b0e3145e239c43937783dded`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 8/10 | ↑ All five affected tests passed on initial
attempts in Catalyst CI; no skips<br>↓ Shared drag-helper timing has
wider test impact |
| Diagnosis confidence | 7/10 | ↑ CI validates active-window fixture
initialization and slower native drag delivery<br>↓ Exact OS scheduling
cause is inferred, not independently reproduced locally |
| Evidence fit | 8/10 | ↑ Raw initial-run TRX confirms the three target
tests plus Clicked and removed-element drag passed<br>↓ One validating
build, not two independent runs; no local Catalyst UI execution |
<!-- /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

Fix repeating Catalyst UI-test failures without ignoring tests or
changing product behavior.

- **Issue20685:** initialize its menu through a real button click after
the window is active, rather than requesting a menu rebuild during
`Loaded`. UIKit's `BuildMenu` selects only active window scenes; an
early rebuild can produce no custom menu. All three tests still open the
real native menu and verify Clicked/Command/CommandParameter callbacks.
Windows initialization is unchanged.
- **Catalyst drag helper:** slow the drag from 2500 to 500 points/s and
hold at the target for 1s rather than 0.1s, allowing Catalyst to
recognize the drag and deliver target events before release. This also
covers `DragAndDropWithAnElementThatIsRemoved`.
- **Issue12060:** require an actual `DragOver` before reporting success,
so a cancelled drag outside the target cannot falsely pass the
accepted-operation regression test.

#### Evidence

[main build
1704474](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1704474),
logs 5701 and 3989:

- Both menu command tests fail on original/retry in `OpenMenuAndTapItem`
line 25, waiting for **MenuItems**, before tapping the menu. Failure
screenshots and accessibility page sources show the test page loaded and
the stock menu bar, but **no MenuItems**. This is not an unexposed
result label or a failed command callback.
- `AcceptedOperationNoneDisablesDropOperation` fails on original/retry
at line 24 waiting for **Success**. Screenshots and page sources show
both boxes and Result=Running. The Mac2 log sends `macos:
clickAndDragAndHold` with duration=1, velocity=2500 and
holdDuration=0.1, returns success, then repeatedly finds no Success.
Gesture delivery, not element discovery, is the suspected failure.
- `DragAndDropWithAnElementThatIsRemoved` times out at line 24 waiting
for **DropResult** on the initial run; it passes the in-job retry.

This does not establish a recent product regression: the tests
previously passed and the provided PR build sometimes recovered on
retry. The changes address fixture initialization and gesture timing;
The passing CI run below supports the hypotheses, but does not
independently establish the exact OS scheduling cause.

#### Duplicate search

Searched open and closed/merged PRs across all bases for Issue20685,
Issue12060, the target test names, MenuFlyoutItem, menu rebuild, Mac2
drag, and clickAndDragAndHold. No equivalent open fix found. #40190
(candidate/11.0.1xx-sr2, now merged) addresses runtime Text changes, not
initial active-window menu construction; #39912 addresses screenshot
geometry, not drag timing/menu initialization. Context-menu enhancements
#40439/#40482 do not cover these menu-bar tests.

#### Validation

- `git diff --check` — passed.
- `dotnet format Microsoft.Maui.sln --no-restore --include
src/Controls/tests/TestCases.HostApp/Issues/Issue20685.cs
src/Controls/tests/TestCases.HostApp/Issues/Issue12060.cs
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20685.cs
src/TestUtils/src/UITest.Appium/Actions/AppiumCatalystTouchActions.cs
--exclude Templates/src --exclude-diagnostics CA1822` — attempted;
project references were not loaded (new checkout has no restored
assets). Not claimed as a successful compiler/analyzer validation.
- No local Catalyst Appium/XCTest UI automation was run. PR CI was
requested with `/azp run maui-pr-uitests`. Initial build 1704524
canceled immediately without running tests; a second comment started
validating build 1704526.


#### Validating Catalyst CI — build 1704526

[Build
1704526](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1704526)
compiled the CoreCLR sample successfully. All three relevant Catalyst
jobs finished **succeeded**. Downloaded their published artifact TRX
files, including the **initial-run raw TRX**, rather than inferring
execution from a green job badge:

| Test | Initial outcome | Duration |
|---|---|---|
| MenuFlyoutItem_CommandWorks | Passed | 4.54s |
| MenuFlyoutItem_CommandWithParameterWorks | Passed | 4.04s |
| MenuFlyoutItem_ClickedEventWorks (Shell1) | Passed | 4.29s |
| AcceptedOperationNoneDisablesDropOperation | Passed | 4.12s |
| DragAndDropWithAnElementThatIsRemoved | Passed | 5.16s |

Evidence artifacts: `drop-maccatalyst_ui_tests_coreclr-Shell2-1`,
`drop-maccatalyst_ui_tests_coreclr-Shell1-1`, and
`drop-maccatalyst_ui_tests_coreclr-Job11-1` →
`test-results/n-*/raw/*.trx`. No target test required an in-job retry.
Assessed/tested head remains `7ee14bce88236c49b0e3145e239c43937783dded`.

**Evidence limit:** this is one validating CI build, not two independent
builds, and is not a claim that the entire cross-platform pipeline is
green. No local Catalyst UI automation was run.

### 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. -->

No new issue is closed. Stabilizes existing regression coverage for
#20685, #12060 and #28416.

### 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>

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 43d1b4a2 Deployed Nov 12, 2026 by marcelomoresco via conclusion #2914
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants