Skip to content

[Windows] Fix crash when clicking a tab with sub tabs in the Shell TabBar overflow menu - #39412

Merged
kubaflo merged 5 commits into
dotnet:inflight/currentfrom
Empiree:fix/windows-shell-overflow-subtabs
Oct 21, 2026
Merged

kubaflo merged 5 commits into
dotnet:inflight/currentfrom
Empiree:fix/windows-shell-overflow-subtabs

Conversation

@Empiree

@Empiree Empiree commented Oct 15, 2026 •

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!

Description of Change

On Windows, clicking a Shell tab with more than one ShellContent in the overflow menu of the top tab bar (the ... button) crashed the app with E_BOUNDS (invalid vector subscript).

The crash is inside WinUI NavigationView. From what I see in the WinUI code, in Top mode it cant find the container of a data bound item that sits in the overflow menu, so the clicked item never gets IsSelected, only IsChildSelected, and when it expands right after the click WinUI reads past the end of the selected index path. MAUI always fills the tab bar through MenuItemsSource, so every tab with sub tabs runs into it. A plain WinUI NavigationView with MenuItemsSource and a similar item template crashes the same way.

Fixing up the selection state after the click only helps for the first click, other overflow bugs in WinUI show up after that (for example picking a sub tab from the overflow menu and closing the menu later crashes again). So now ShellItemHandler sets SelectsOnInvoked to false on overflow menu containers that have sub tabs, and clears it when the container leaves the overflow menu. MapMenuItems also updates the items that are already in the overflow menu, because a tab can get or lose sub tabs while it sits there. A click on such a tab just expands it, picking one of its sub tabs navigates like before and WinUI moves the tab into the bar. Tabs in the bar work like before.

There are four device tests. The first one opens a tab with one ShellContent from the overflow menu, then clicks the tab with sub tabs, picks Sub B and checks the navigation. The second one adds and removes a sub tab of a tab that already sits in the open overflow menu and checks the item follows. The third one moves a tab with sub tabs from the overflow menu back into the bar and checks it gets selected there like before. The fourth one applies the NavigationView template again and checks the new overflow menu behaves the same. Without the fix the click makes WinUI kill the whole test app, so the tests check SelectsOnInvoked before clicking to fail in a normal way.

Issues Fixed

Fixes #37985

WinUI cant select a data bound NavigationView item with children while it sits in the overflow menu of the top tab bar, it fails with E_BOUNDS. In the overflow menu such a tab now only expands, and the navigation happens when one of its sub tabs is picked.

Fixes dotnet#37985
@Empiree
Empiree temporarily deployed to copilot-pat-pool October 15, 2026 19:33 — with GitHub Actions Inactive
@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 -- 39412

Or

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

@azure-pipelines

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

@Empiree
Empiree temporarily deployed to copilot-pat-pool October 15, 2026 19:33 — with GitHub Actions Inactive
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Oct 15, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@Empiree! 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 @Empiree! 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 Oct 16, 2026
@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 1 findings

See inline comments for details.

// a tab with sub tabs only expands, and the navigation happens when one of its sub tabs is picked.
static void OnOverflowMenuItemPrepared(ItemsRepeater sender, ItemsRepeaterElementPreparedEventArgs args)
{
if (args.Element is NavigationViewItem item && item.DataContext is NavigationViewItemViewModel { MenuItemsSource: not null })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔍 AI-Generated Review (multi-model)

[major] Logic and Correctness — SelectsOnInvoked is updated only during ElementPrepared/ElementClearing, so an already-prepared overflow NavigationViewItem is not updated when its bound NavigationViewItemViewModel.MenuItemsSource changes at runtime. Concrete scenario: a tab initially has a single ShellContent (prepared with default selectable behavior) and later receives another ShellContent via ItemsCollectionChanged/MapMenuItems, making MenuItemsSource non-null without recycling the existing overflow container; clicking it in overflow still follows the select path that this fix is meant to avoid (E_BOUNDS repro path).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, MapMenuItems now updates SelectsOnInvoked of the overflow items that are already realized. Covered by TabBarOverflowMenuTabFollowsItsShellContentChanges.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Oct 16, 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 — 2 findings

Reviewed commit 7478a41.

See inline comments for details.

static void OnOverflowMenuItemPrepared(ItemsRepeater sender, ItemsRepeaterElementPreparedEventArgs args)
{
if (args.Element is NavigationViewItem item && item.DataContext is NavigationViewItemViewModel { MenuItemsSource: not null })
item.SelectsOnInvoked = false;

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 - Keep SelectsOnInvoked synchronized with changes to an existing overflow item's MenuItemsSource. Open overflow for an inactive tab containing two ShellContents, remove one content, then change TabBar.Title to refresh MapMenuItems while the container remains realized. SyncItems retains the existing view model, and MapMenuItems sets its MenuItemsSource to null. The template updates its children, but neither ElementPrepared nor ElementClearing runs for that property update, leaving SelectsOnInvoked=false. The now-single-content tab cannot be selected and has no children through which to navigate. Update the restriction on child-source changes as well as container preparation, and cover this transition in the regression test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed the same way, the new test also checks the other direction (sub tab removed, the tab is selectable again and navigates)


// The tab only expands to show its sub tabs, the current page stays the same
Assert.True(nestedItem.IsExpanded);
Assert.NotEqual(nestedTab, shell.CurrentItem.CurrentItem);

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 - Add a negative-case assertion for an ordinary single-content tab in the overflow menu. The fixture creates seven such tabs but never invokes one; selecting Sub B exercises a child container, not a top-level container prepared by the overflow ItemsRepeater. Setting SelectsOnInvoked=false for every top-level overflow item would therefore still satisfy this test while preventing ordinary overflow tabs from navigating. That working case is an explicit counter-check in #37985. Invoke a single-content tab from the same overflow menu and assert that Shell switches to it, so the test distinguishes selective suppression from disabling all overflow selection.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added, the test now opens Tab 7 from the overflow menu first and checks the navigation.

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

Looks good, but could you please check the ai's suggestions?

Applying the NavigationView template again creates a new overflow menu, the new test checks that the handler follows it.
@Empiree

Empiree commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@kubaflo thanks for running it again. This time the review had no findings on the code, only the reviewer candidate with an extra template check in the test.

I added that check, but as its own test TabWithSeveralShellContentsOnlyExpandsInNewTabBarOverflowMenuAfterTemplateIsAppliedAgain. It opens the overflow menu, applies the NavigationView template again and checks that Nested in the new overflow menu only expands. I didnt put it into the leaving overflow test like the candidate did. It looks like after the template is applied again WinUI stops reusing the overflow container for the bar, so that test passes even without the reset in ElementClearing, and the reset is what it was added for.

Checked each part on my side. Without the reset only the leaving overflow test fails, without following the new template only the new test fails, with the full fix all four pass.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 20, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@Empiree — test-failure analysis for commit e930ff5.

Scope CI failures Commit e930ff5


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests

No failures found.


🧪 maui-pr-uitests

All five main history samples are partial; unmatched failures remain unresolved.


🧭 Follow-up — actions and refresh

Next action: Inspect the MenuBar click target and unmatched screenshots; restore provisioning diagnostics and compare identical-setup outcomes.

Maintainers: comment /review tests to refresh this report.

@kubaflo
kubaflo changed the base branch from main to inflight/current October 21, 2026 11:23
Preserve the overflow-menu regression tests and helpers alongside the independent dynamically-added disabled-tab appearance test.

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

kubaflo commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Resolved and pushed the conflict with inflight/current in merge commit 7219dc7744, on the original fix/windows-shell-overflow-subtabs branch.

The only conflict was overlapping additions in ShellTabBarTests.Windows.cs. The resolution preserves all four overflow-menu regression tests and their helpers, plus the target branch's independently added disabled-tab appearance test and helpers. ShellItemHandler.Windows.cs merged automatically, retaining both the overflow fix and upstream appearance changes; MauiNavigationView.cs is unchanged from the PR head.

Validation: scoped dotnet format whitespace verification and git diff --check passed for the resolved file. The managed Shell unit-test assembly compiled; the initial test run could not start because the repo-local SDK has only the .NET 11 runtime. Rerunning with explicit DOTNET_ROLL_FORWARD=Major passed all 93 selected Shell tests. These managed tests do not compile or execute the Windows-specific code. Native Windows builds and device tests were not run on this macOS host and remain for Windows CI. No UI automation or XCTest was launched.

@kubaflo
kubaflo merged commit c47eea0 into dotnet:inflight/current Oct 21, 2026
2 of 3 checks passed
kubaflo added a commit that referenced this pull request Oct 21, 2026
…bBar overflow menu (#39412)

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

### Description of Change

On Windows, clicking a Shell tab with more than one ShellContent in the
overflow menu of the top tab bar (the ... button) crashed the app with
E_BOUNDS (invalid vector subscript).

The crash is inside WinUI NavigationView. From what I see in the WinUI
code, in Top mode it cant find the container of a data bound item that
sits in the overflow menu, so the clicked item never gets IsSelected,
only IsChildSelected, and when it expands right after the click WinUI
reads past the end of the selected index path. MAUI always fills the tab
bar through MenuItemsSource, so every tab with sub tabs runs into it. A
plain WinUI NavigationView with MenuItemsSource and a similar item
template crashes the same way.

Fixing up the selection state after the click only helps for the first
click, other overflow bugs in WinUI show up after that (for example
picking a sub tab from the overflow menu and closing the menu later
crashes again). So now ShellItemHandler sets SelectsOnInvoked to false
on overflow menu containers that have sub tabs, and clears it when the
container leaves the overflow menu. MapMenuItems also updates the items
that are already in the overflow menu, because a tab can get or lose sub
tabs while it sits there. A click on such a tab just expands it, picking
one of its sub tabs navigates like before and WinUI moves the tab into
the bar. Tabs in the bar work like before.

There are four device tests. The first one opens a tab with one
ShellContent from the overflow menu, then clicks the tab with sub tabs,
picks Sub B and checks the navigation. The second one adds and removes a
sub tab of a tab that already sits in the open overflow menu and checks
the item follows. The third one moves a tab with sub tabs from the
overflow menu back into the bar and checks it gets selected there like
before. The fourth one applies the NavigationView template again and
checks the new overflow menu behaves the same. Without the fix the click
makes WinUI kill the whole test app, so the tests check SelectsOnInvoked
before clicking to fail in a normal way.

### Issues Fixed

Fixes #37985

---------

Co-authored-by: Empiree <Empiree@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 25, 2026
…bBar overflow menu (#39412)

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

### Description of Change

On Windows, clicking a Shell tab with more than one ShellContent in the
overflow menu of the top tab bar (the ... button) crashed the app with
E_BOUNDS (invalid vector subscript).

The crash is inside WinUI NavigationView. From what I see in the WinUI
code, in Top mode it cant find the container of a data bound item that
sits in the overflow menu, so the clicked item never gets IsSelected,
only IsChildSelected, and when it expands right after the click WinUI
reads past the end of the selected index path. MAUI always fills the tab
bar through MenuItemsSource, so every tab with sub tabs runs into it. A
plain WinUI NavigationView with MenuItemsSource and a similar item
template crashes the same way.

Fixing up the selection state after the click only helps for the first
click, other overflow bugs in WinUI show up after that (for example
picking a sub tab from the overflow menu and closing the menu later
crashes again). So now ShellItemHandler sets SelectsOnInvoked to false
on overflow menu containers that have sub tabs, and clears it when the
container leaves the overflow menu. MapMenuItems also updates the items
that are already in the overflow menu, because a tab can get or lose sub
tabs while it sits there. A click on such a tab just expands it, picking
one of its sub tabs navigates like before and WinUI moves the tab into
the bar. Tabs in the bar work like before.

There are four device tests. The first one opens a tab with one
ShellContent from the overflow menu, then clicks the tab with sub tabs,
picks Sub B and checks the navigation. The second one adds and removes a
sub tab of a tab that already sits in the open overflow menu and checks
the item follows. The third one moves a tab with sub tabs from the
overflow menu back into the bar and checks it gets selected there like
before. The fourth one applies the NavigationView template again and
checks the new overflow menu behaves the same. Without the fix the click
makes WinUI kill the whole test app, so the tests check SelectsOnInvoked
before clicking to fail in a normal way.

### Issues Fixed

Fixes #37985

---------

Co-authored-by: Empiree <Empiree@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 26, 2026
…bBar overflow menu (#39412)

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

### Description of Change

On Windows, clicking a Shell tab with more than one ShellContent in the
overflow menu of the top tab bar (the ... button) crashed the app with
E_BOUNDS (invalid vector subscript).

The crash is inside WinUI NavigationView. From what I see in the WinUI
code, in Top mode it cant find the container of a data bound item that
sits in the overflow menu, so the clicked item never gets IsSelected,
only IsChildSelected, and when it expands right after the click WinUI
reads past the end of the selected index path. MAUI always fills the tab
bar through MenuItemsSource, so every tab with sub tabs runs into it. A
plain WinUI NavigationView with MenuItemsSource and a similar item
template crashes the same way.

Fixing up the selection state after the click only helps for the first
click, other overflow bugs in WinUI show up after that (for example
picking a sub tab from the overflow menu and closing the menu later
crashes again). So now ShellItemHandler sets SelectsOnInvoked to false
on overflow menu containers that have sub tabs, and clears it when the
container leaves the overflow menu. MapMenuItems also updates the items
that are already in the overflow menu, because a tab can get or lose sub
tabs while it sits there. A click on such a tab just expands it, picking
one of its sub tabs navigates like before and WinUI moves the tab into
the bar. Tabs in the bar work like before.

There are four device tests. The first one opens a tab with one
ShellContent from the overflow menu, then clicks the tab with sub tabs,
picks Sub B and checks the navigation. The second one adds and removes a
sub tab of a tab that already sits in the open overflow menu and checks
the item follows. The third one moves a tab with sub tabs from the
overflow menu back into the bar and checks it gets selected there like
before. The fourth one applies the NavigationView template again and
checks the new overflow menu behaves the same. Without the fix the click
makes WinUI kill the whole test app, so the tests check SelectsOnInvoked
before clicking to fail in a normal way.

### Issues Fixed

Fixes #37985

---------

Co-authored-by: Empiree <Empiree@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
github-actions Bot pushed a commit that referenced this pull request Oct 28, 2026
…bBar overflow menu (#39412)

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

### Description of Change

On Windows, clicking a Shell tab with more than one ShellContent in the
overflow menu of the top tab bar (the ... button) crashed the app with
E_BOUNDS (invalid vector subscript).

The crash is inside WinUI NavigationView. From what I see in the WinUI
code, in Top mode it cant find the container of a data bound item that
sits in the overflow menu, so the clicked item never gets IsSelected,
only IsChildSelected, and when it expands right after the click WinUI
reads past the end of the selected index path. MAUI always fills the tab
bar through MenuItemsSource, so every tab with sub tabs runs into it. A
plain WinUI NavigationView with MenuItemsSource and a similar item
template crashes the same way.

Fixing up the selection state after the click only helps for the first
click, other overflow bugs in WinUI show up after that (for example
picking a sub tab from the overflow menu and closing the menu later
crashes again). So now ShellItemHandler sets SelectsOnInvoked to false
on overflow menu containers that have sub tabs, and clears it when the
container leaves the overflow menu. MapMenuItems also updates the items
that are already in the overflow menu, because a tab can get or lose sub
tabs while it sits there. A click on such a tab just expands it, picking
one of its sub tabs navigates like before and WinUI moves the tab into
the bar. Tabs in the bar work like before.

There are four device tests. The first one opens a tab with one
ShellContent from the overflow menu, then clicks the tab with sub tabs,
picks Sub B and checks the navigation. The second one adds and removes a
sub tab of a tab that already sits in the open overflow menu and checks
the item follows. The third one moves a tab with sub tabs from the
overflow menu back into the bar and checks it gets selected there like
before. The fourth one applies the NavigationView template again and
checks the new overflow menu behaves the same. Without the fix the click
makes WinUI kill the whole test app, so the tests check SelectsOnInvoked
before clicking to fail in a normal way.

### Issues Fixed

Fixes #37985

---------

Co-authored-by: Empiree <Empiree@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…l test reopens it (#40359)

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

This is a test-only fix for the SR2 candidate validation in #40116, so
it targets `candidate/11.0.1xx-sr2`, like the earlier candidate test
fixes.

### Description of Change

On candidate head `888db82bd5`, Windows device-test build 1686840 failed
`ShellTests.TabWithSeveralShellContentsOpensFromTabBarOverflowMenu` (run
47076696, result 102198) at `ShellTabBarTests.Windows.cs:276` with `The
overflow menu did not open again`. That test came in with #39412.

**Root cause (test timing):**
1. The test clicks "Tab 7", and later "Sub B", in the tab bar overflow
menu. Both tabs select on invoke, so the click hides the menu.
2. Hiding only closes the flyout's popup. WinUI keeps the `MenuFlyout`
registered as open until its presenter unloads and raises `Closed`.
Until then, `ShowAt` on the same flyout and target is ignored.
3. The test waits for navigation and then reopens the menu with
`ShowAt`. Navigation is usually observed after the presenter has
unloaded, but not always. When it's observed first, `ShowAt` is a no-op
and `IsOpen` never becomes true.

**Fix:** a new helper, `ClickOverflowMenuItemThatClosesMenu`, waits for
`Flyout.Closed` after the two clicks that close the menu, before the
menu is reopened. The diff is +21/−2 in `ShellTabBarTests.Windows.cs`
only. Assertions, messages, deadlines and test cases are unchanged. No
product code changes.

**Causal evidence (Helix `Windows.11.Amd64.Client.Open`, Controls device
tests, Shell category):**

A temporary, uncommitted probe (`OverflowProbe*`, never committed) runs
alongside the real tests:
- **A (trigger):** clicks "Sub B" and calls `ShowAt` at once, as when
navigation is observed before the presenter unloads.
- **B (trigger + fix):** the same, but clicks with this PR's helper.
- **C (real test):**
`TabWithSeveralShellContentsOpensFromTabBarOverflowMenu`, 20 iterations.
- **D (trigger removed):** the original order, which waits for
navigation before reopening.

| Leg | Helper wait present | A trigger | B trigger + helper | C real
test | D no trigger | Real overflow tests |
| --- | --- | --- | --- | --- | --- | --- |
| fix | yes | red 10/10 | **green 10/10** | green 20/20 | green 10/10 |
4/4 pass |
| reverted (r1) | no | — | — | — | — | not run: the probe edit failed to
build (CS0219) |
| reverted (r2) | no | red 10/10 | **red 10/10** | green 20/20 | green
10/10 | 4/4 pass |
| restored (r1) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |
| restored (r2) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |

Each leg's payload records `variant.json` with `fixWaitPresent` and
SHA-256s of the test and probe files.
- Helix jobs: `509c2c0a-230d-4310-9524-199f5d1858e9` (r1) and
`c16a74fd-9a5b-4979-b7a9-22d0519b5755` (r2).
- r1's reverted leg failed to compile, so r2 repeated the matrix with a
corrected revert.
- A shows the trigger reproduces `did not open again` every time without
the wait.
- B flips red when only the helper's `Closed` wait is removed, and green
again when it's restored.
- C and D show the original race is rare. The real test passes in these
legs, consistent with a single CI failure.

I found no duplicate open or merged PR for this test or mechanism.

### Issues Fixed

No issue filed. Found during SR2 candidate validation (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…l test reopens it (#40359)

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

This is a test-only fix for the SR2 candidate validation in #40116, so
it targets `candidate/11.0.1xx-sr2`, like the earlier candidate test
fixes.

### Description of Change

On candidate head `888db82bd5`, Windows device-test build 1686840 failed
`ShellTests.TabWithSeveralShellContentsOpensFromTabBarOverflowMenu` (run
47076696, result 102198) at `ShellTabBarTests.Windows.cs:276` with `The
overflow menu did not open again`. That test came in with #39412.

**Root cause (test timing):**
1. The test clicks "Tab 7", and later "Sub B", in the tab bar overflow
menu. Both tabs select on invoke, so the click hides the menu.
2. Hiding only closes the flyout's popup. WinUI keeps the `MenuFlyout`
registered as open until its presenter unloads and raises `Closed`.
Until then, `ShowAt` on the same flyout and target is ignored.
3. The test waits for navigation and then reopens the menu with
`ShowAt`. Navigation is usually observed after the presenter has
unloaded, but not always. When it's observed first, `ShowAt` is a no-op
and `IsOpen` never becomes true.

**Fix:** a new helper, `ClickOverflowMenuItemThatClosesMenu`, waits for
`Flyout.Closed` after the two clicks that close the menu, before the
menu is reopened. The diff is +21/−2 in `ShellTabBarTests.Windows.cs`
only. Assertions, messages, deadlines and test cases are unchanged. No
product code changes.

**Causal evidence (Helix `Windows.11.Amd64.Client.Open`, Controls device
tests, Shell category):**

A temporary, uncommitted probe (`OverflowProbe*`, never committed) runs
alongside the real tests:
- **A (trigger):** clicks "Sub B" and calls `ShowAt` at once, as when
navigation is observed before the presenter unloads.
- **B (trigger + fix):** the same, but clicks with this PR's helper.
- **C (real test):**
`TabWithSeveralShellContentsOpensFromTabBarOverflowMenu`, 20 iterations.
- **D (trigger removed):** the original order, which waits for
navigation before reopening.

| Leg | Helper wait present | A trigger | B trigger + helper | C real
test | D no trigger | Real overflow tests |
| --- | --- | --- | --- | --- | --- | --- |
| fix | yes | red 10/10 | **green 10/10** | green 20/20 | green 10/10 |
4/4 pass |
| reverted (r1) | no | — | — | — | — | not run: the probe edit failed to
build (CS0219) |
| reverted (r2) | no | red 10/10 | **red 10/10** | green 20/20 | green
10/10 | 4/4 pass |
| restored (r1) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |
| restored (r2) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |

Each leg's payload records `variant.json` with `fixWaitPresent` and
SHA-256s of the test and probe files.
- Helix jobs: `509c2c0a-230d-4310-9524-199f5d1858e9` (r1) and
`c16a74fd-9a5b-4979-b7a9-22d0519b5755` (r2).
- r1's reverted leg failed to compile, so r2 repeated the matrix with a
corrected revert.
- A shows the trigger reproduces `did not open again` every time without
the wait.
- B flips red when only the helper's `Closed` wait is removed, and green
again when it's restored.
- C and D show the original race is rare. The real test passes in these
legs, consistent with a single CI failure.

I found no duplicate open or merged PR for this test or mechanism.

### Issues Fixed

No issue filed. Found during SR2 candidate validation (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…l test reopens it (#40359)

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

This is a test-only fix for the SR2 candidate validation in #40116, so
it targets `candidate/11.0.1xx-sr2`, like the earlier candidate test
fixes.

### Description of Change

On candidate head `888db82bd5`, Windows device-test build 1686840 failed
`ShellTests.TabWithSeveralShellContentsOpensFromTabBarOverflowMenu` (run
47076696, result 102198) at `ShellTabBarTests.Windows.cs:276` with `The
overflow menu did not open again`. That test came in with #39412.

**Root cause (test timing):**
1. The test clicks "Tab 7", and later "Sub B", in the tab bar overflow
menu. Both tabs select on invoke, so the click hides the menu.
2. Hiding only closes the flyout's popup. WinUI keeps the `MenuFlyout`
registered as open until its presenter unloads and raises `Closed`.
Until then, `ShowAt` on the same flyout and target is ignored.
3. The test waits for navigation and then reopens the menu with
`ShowAt`. Navigation is usually observed after the presenter has
unloaded, but not always. When it's observed first, `ShowAt` is a no-op
and `IsOpen` never becomes true.

**Fix:** a new helper, `ClickOverflowMenuItemThatClosesMenu`, waits for
`Flyout.Closed` after the two clicks that close the menu, before the
menu is reopened. The diff is +21/−2 in `ShellTabBarTests.Windows.cs`
only. Assertions, messages, deadlines and test cases are unchanged. No
product code changes.

**Causal evidence (Helix `Windows.11.Amd64.Client.Open`, Controls device
tests, Shell category):**

A temporary, uncommitted probe (`OverflowProbe*`, never committed) runs
alongside the real tests:
- **A (trigger):** clicks "Sub B" and calls `ShowAt` at once, as when
navigation is observed before the presenter unloads.
- **B (trigger + fix):** the same, but clicks with this PR's helper.
- **C (real test):**
`TabWithSeveralShellContentsOpensFromTabBarOverflowMenu`, 20 iterations.
- **D (trigger removed):** the original order, which waits for
navigation before reopening.

| Leg | Helper wait present | A trigger | B trigger + helper | C real
test | D no trigger | Real overflow tests |
| --- | --- | --- | --- | --- | --- | --- |
| fix | yes | red 10/10 | **green 10/10** | green 20/20 | green 10/10 |
4/4 pass |
| reverted (r1) | no | — | — | — | — | not run: the probe edit failed to
build (CS0219) |
| reverted (r2) | no | red 10/10 | **red 10/10** | green 20/20 | green
10/10 | 4/4 pass |
| restored (r1) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |
| restored (r2) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |

Each leg's payload records `variant.json` with `fixWaitPresent` and
SHA-256s of the test and probe files.
- Helix jobs: `509c2c0a-230d-4310-9524-199f5d1858e9` (r1) and
`c16a74fd-9a5b-4979-b7a9-22d0519b5755` (r2).
- r1's reverted leg failed to compile, so r2 repeated the matrix with a
corrected revert.
- A shows the trigger reproduces `did not open again` every time without
the wait.
- B flips red when only the helper's `Closed` wait is removed, and green
again when it's restored.
- C and D show the original race is rare. The real test passes in these
legs, consistent with a single CI failure.

I found no duplicate open or merged PR for this test or mechanism.

### Issues Fixed

No issue filed. Found during SR2 candidate validation (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…l test reopens it (#40359)

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

This is a test-only fix for the SR2 candidate validation in #40116, so
it targets `candidate/11.0.1xx-sr2`, like the earlier candidate test
fixes.

### Description of Change

On candidate head `888db82bd5`, Windows device-test build 1686840 failed
`ShellTests.TabWithSeveralShellContentsOpensFromTabBarOverflowMenu` (run
47076696, result 102198) at `ShellTabBarTests.Windows.cs:276` with `The
overflow menu did not open again`. That test came in with #39412.

**Root cause (test timing):**
1. The test clicks "Tab 7", and later "Sub B", in the tab bar overflow
menu. Both tabs select on invoke, so the click hides the menu.
2. Hiding only closes the flyout's popup. WinUI keeps the `MenuFlyout`
registered as open until its presenter unloads and raises `Closed`.
Until then, `ShowAt` on the same flyout and target is ignored.
3. The test waits for navigation and then reopens the menu with
`ShowAt`. Navigation is usually observed after the presenter has
unloaded, but not always. When it's observed first, `ShowAt` is a no-op
and `IsOpen` never becomes true.

**Fix:** a new helper, `ClickOverflowMenuItemThatClosesMenu`, waits for
`Flyout.Closed` after the two clicks that close the menu, before the
menu is reopened. The diff is +21/−2 in `ShellTabBarTests.Windows.cs`
only. Assertions, messages, deadlines and test cases are unchanged. No
product code changes.

**Causal evidence (Helix `Windows.11.Amd64.Client.Open`, Controls device
tests, Shell category):**

A temporary, uncommitted probe (`OverflowProbe*`, never committed) runs
alongside the real tests:
- **A (trigger):** clicks "Sub B" and calls `ShowAt` at once, as when
navigation is observed before the presenter unloads.
- **B (trigger + fix):** the same, but clicks with this PR's helper.
- **C (real test):**
`TabWithSeveralShellContentsOpensFromTabBarOverflowMenu`, 20 iterations.
- **D (trigger removed):** the original order, which waits for
navigation before reopening.

| Leg | Helper wait present | A trigger | B trigger + helper | C real
test | D no trigger | Real overflow tests |
| --- | --- | --- | --- | --- | --- | --- |
| fix | yes | red 10/10 | **green 10/10** | green 20/20 | green 10/10 |
4/4 pass |
| reverted (r1) | no | — | — | — | — | not run: the probe edit failed to
build (CS0219) |
| reverted (r2) | no | red 10/10 | **red 10/10** | green 20/20 | green
10/10 | 4/4 pass |
| restored (r1) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |
| restored (r2) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |

Each leg's payload records `variant.json` with `fixWaitPresent` and
SHA-256s of the test and probe files.
- Helix jobs: `509c2c0a-230d-4310-9524-199f5d1858e9` (r1) and
`c16a74fd-9a5b-4979-b7a9-22d0519b5755` (r2).
- r1's reverted leg failed to compile, so r2 repeated the matrix with a
corrected revert.
- A shows the trigger reproduces `did not open again` every time without
the wait.
- B flips red when only the helper's `Closed` wait is removed, and green
again when it's restored.
- C and D show the original race is rare. The real test passes in these
legs, consistent with a single CI failure.

I found no duplicate open or merged PR for this test or mechanism.

### Issues Fixed

No issue filed. Found during SR2 candidate validation (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…l test reopens it (#40359)

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

This is a test-only fix for the SR2 candidate validation in #40116, so
it targets `candidate/11.0.1xx-sr2`, like the earlier candidate test
fixes.

### Description of Change

On candidate head `888db82bd5`, Windows device-test build 1686840 failed
`ShellTests.TabWithSeveralShellContentsOpensFromTabBarOverflowMenu` (run
47076696, result 102198) at `ShellTabBarTests.Windows.cs:276` with `The
overflow menu did not open again`. That test came in with #39412.

**Root cause (test timing):**
1. The test clicks "Tab 7", and later "Sub B", in the tab bar overflow
menu. Both tabs select on invoke, so the click hides the menu.
2. Hiding only closes the flyout's popup. WinUI keeps the `MenuFlyout`
registered as open until its presenter unloads and raises `Closed`.
Until then, `ShowAt` on the same flyout and target is ignored.
3. The test waits for navigation and then reopens the menu with
`ShowAt`. Navigation is usually observed after the presenter has
unloaded, but not always. When it's observed first, `ShowAt` is a no-op
and `IsOpen` never becomes true.

**Fix:** a new helper, `ClickOverflowMenuItemThatClosesMenu`, waits for
`Flyout.Closed` after the two clicks that close the menu, before the
menu is reopened. The diff is +21/−2 in `ShellTabBarTests.Windows.cs`
only. Assertions, messages, deadlines and test cases are unchanged. No
product code changes.

**Causal evidence (Helix `Windows.11.Amd64.Client.Open`, Controls device
tests, Shell category):**

A temporary, uncommitted probe (`OverflowProbe*`, never committed) runs
alongside the real tests:
- **A (trigger):** clicks "Sub B" and calls `ShowAt` at once, as when
navigation is observed before the presenter unloads.
- **B (trigger + fix):** the same, but clicks with this PR's helper.
- **C (real test):**
`TabWithSeveralShellContentsOpensFromTabBarOverflowMenu`, 20 iterations.
- **D (trigger removed):** the original order, which waits for
navigation before reopening.

| Leg | Helper wait present | A trigger | B trigger + helper | C real
test | D no trigger | Real overflow tests |
| --- | --- | --- | --- | --- | --- | --- |
| fix | yes | red 10/10 | **green 10/10** | green 20/20 | green 10/10 |
4/4 pass |
| reverted (r1) | no | — | — | — | — | not run: the probe edit failed to
build (CS0219) |
| reverted (r2) | no | red 10/10 | **red 10/10** | green 20/20 | green
10/10 | 4/4 pass |
| restored (r1) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |
| restored (r2) | yes | red 10/10 | **green 10/10** | green 20/20 |
green 10/10 | 4/4 pass |

Each leg's payload records `variant.json` with `fixWaitPresent` and
SHA-256s of the test and probe files.
- Helix jobs: `509c2c0a-230d-4310-9524-199f5d1858e9` (r1) and
`c16a74fd-9a5b-4979-b7a9-22d0519b5755` (r2).
- r1's reverted leg failed to compile, so r2 repeated the matrix with a
corrected revert.
- A shows the trigger reproduces `did not open again` every time without
the wait.
- B flips red when only the helper's `Closed` wait is removed, and green
again when it's restored.
- C and D show the original race is rare. The real test passes in these
legs, consistent with a single CI failure.

I found no duplicate open or merged PR for this test or mechanism.

### Issues Fixed

No issue filed. Found during SR2 candidate validation (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-review-in-progress AI review is currently running for this PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Crash (E_BOUNDS / invalid vector subscript) when selecting a Tab with nested ShellContent from the TabBar overflow menu

4 participants