Skip to content

[Windows] Prevent duplicate Shell startup navigation from stale tab selection events - #39887

Merged
kubaflo merged 1 commit into
dotnet:mainfrom
sheiksyedm:fix/windows-shell-startup-navigation-39859
Nov 4, 2026
Merged

kubaflo merged 1 commit into
dotnet:mainfrom
sheiksyedm:fix/windows-shell-startup-navigation-39859

Conversation

@sheiksyedm

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!

Issue details

When the initial page redirects to another implicit tab from its NavigatedTo handler, with the tab bar hidden, Shell can navigate back to the initial page unexpectedly. This invokes the initial page's NavigatedTo handler twice and leaves the application on the wrong route.

Root cause

WinUI can deliver an earlier NavigationView.SelectionChanged event after a reentrant navigation has already changed the selected tab. In the reproduced sequence, the event's SelectedItem still references GettingStartedPage, while the NavigationView's current SelectedItem and Shell route already reference SplashPage.

ShellItemHandler.OnNavigationTabChanged previously processed that obsolete event as a new selection, navigating Shell back to GettingStartedPage.

A controlled comparison on current main isolates the interaction with #38637, which avoids redundant PaneDisplayMode assignments to preserve the tab indicator animation. Reversing that optimization avoids the startup symptom but reintroduces the interrupted indicator behavior from #38422. This comparison is not a full historical commit bisect.

Fix

Ignore selection events when args.SelectedItem no longer matches sender.SelectedItem by reference. Events matching the live native selection continue through the existing navigation logic.

The PaneDisplayMode optimization from #38637 remains unchanged, preserving the original animation fix rather than reverting it.

Issues Fixed

Fixes #39859

Copilot AI balanced review requested due to automatic review settings November 4, 2026 11:26
@github-actions

github-actions Bot commented Nov 4, 2026

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

Or

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

@azure-pipelines

This comment has been minimized.

@sheiksyedm
sheiksyedm marked this pull request as draft November 4, 2026 11:27
@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 4, 2026
@github-actions github-actions Bot added area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/windows labels Nov 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The fix relies on native WinUI reentrant event ordering and animation timing that require Windows device tests and manual tab-transition verification beyond this source snapshot.

No open issues 🎉

What changed in this PR

Prevents stale Windows tab-selection events from undoing Shell startup redirects, addressing #39859 while preserving the tab-indicator animation optimization from #38637.

Changes:

  • Ignores selection events whose selected item no longer matches the live native selection.
  • Adds Windows device tests for startup redirects with tabs shown or hidden.
  • Adds indicator-animation coverage for programmatic and invoked tab selection.
File Description
src/​Controls/​tests/​DeviceTests/​Elements/​Shell/​ShellTabBarTests.Windows.cs Adds startup redirect and tab-indicator regression tests.
src/​Controls/​src/​Core/​Handlers/​Shell/​ShellItemHandler.Windows.cs Filters stale selection events before processing navigation.

Review effort: Balanced

@kubaflo

This comment has been minimized.

@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 4, 2026
@azure-pipelines

This comment has been minimized.

@sheiksyedm
sheiksyedm marked this pull request as ready for review November 4, 2026 11:53

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

@MauiBot

MauiBot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@sheiksyedm — existing-test verification for commit 4fd39d58.

Result PASSED Platform Windows Commit 4fd39d58


🧪 Gate analysis — click to expand

✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence.

📱 Device tests
Test group Without fix With fix
ShellTests (InitialPageRedirectKeepsSelectedTab, TabBarSelectionKeepsDestinationIndicatorVisible) ✅ Failed as expected (461s) ✅ Passed (205s)
Execution log excerpts

Without fix ShellTests (InitialPageRedirectKeepsSelectedTab, TabBarSelectionKeepsDestinationIndicatorVisible)

ss the warning by specifying `x:SuppressXamlTrimWarnings=True` within the closest element. If not, the property path might be trimmed and will not be AOT compatible. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net11.0-windows10.0.19041.0]
Platform\Windows\TabbedPage\TabbedPageStyle.xaml(19,21): XamlCompiler warning WMC1510: Ensure the property path is trimming and AOT compatible by making use of 'Compiled Bindings (x:bind)' if possible or by specifying the 'x:DataType' directive with the respective binding data context and marking the type declaration with the 'WinRT.GeneratedBindableCustomProperty' attribute or the 'Microsoft.UI.Xaml.Data.Bindable' attribute. If you are unable to do either but can ensure the data type is attributed correctly, then you can also suppress the warning by specifying `x:SuppressXamlTrimWarnings=True` within the closest element. If not, the property path might be trimmed and will not be AOT compatible. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net11.0-windows10.0.19041.0]
    0 Error(s)
Time Elapsed 00:05:22.72
  Passed: 3
  Failed: 1
  Skipped: 0
  Total: 4
  Tests completed with exit code: 1

With fix ShellTests (InitialPageRedirectKeepsSelectedTab, TabBarSelectionKeepsDestinationIndicatorVisible)

uppress the warning by specifying `x:SuppressXamlTrimWarnings=True` within the closest element. If not, the property path might be trimmed and will not be AOT compatible. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net11.0-windows10.0.19041.0]
Platform\Windows\TabbedPage\TabbedPageStyle.xaml(19,21): XamlCompiler warning WMC1510: Ensure the property path is trimming and AOT compatible by making use of 'Compiled Bindings (x:bind)' if possible or by specifying the 'x:DataType' directive with the respective binding data context and marking the type declaration with the 'WinRT.GeneratedBindableCustomProperty' attribute or the 'Microsoft.UI.Xaml.Data.Bindable' attribute. If you are unable to do either but can ensure the data type is attributed correctly, then you can also suppress the warning by specifying `x:SuppressXamlTrimWarnings=True` within the closest element. If not, the property path might be trimmed and will not be AOT compatible. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net11.0-windows10.0.19041.0]
    0 Error(s)
Time Elapsed 00:02:30.16
  Passed: 4
  Failed: 0
  Skipped: 0
  Total: 4
  Tests completed successfully

PR head: 4fd39d58.

Without-fix baseline: 43540f6a.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Nov 4, 2026
@sheiksyedm
sheiksyedm requested a review from kubaflo November 4, 2026 12:43
@sheiksyedm sheiksyedm added the community ✨ Community Contribution label Nov 4, 2026
@kubaflo
kubaflo merged commit a547425 into dotnet:main Nov 4, 2026
25 of 57 checks passed
kubaflo added a commit that referenced this pull request Nov 13, 2026
…on backports (#40217)

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

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

**Explicit release-target exception:** this PR intentionally targets the
new `release/10.0.1xx-sr14` branch. `main`, `net11` and the inflight
lanes are now .NET 11, so .NET 10 SR14 is cut from the SR13 release head
(`release/10.0.1xx-sr14` was created at `54d76458e0`, the tip of
`release/10.0.1xx-sr13`, which already includes all post-cut SR13 fixes
#39830, #39855, #39879, #39891 and the servicing/stable configuration
from #39774).

This PR brings the .NET 10 changes needed since SR13:

1. **Backport #39887** – `[Windows] Prevent duplicate Shell startup
navigation from stale tab selection events`. Fixes #39859 (regressed in
10.0.120); it was merged only to `main`. Clean `cherry-pick -x`.
2. **Backport #40132** – `Fix custom Shape.PathForBounds dispatch
regression`. Fixes #40129 (regressed in 10.0.130); it was merged only to
`candidate/11.0.1xx-sr2`. The unrelated .NET 11
`eng/release-rollover.json` change from that commit is excluded (file
does not exist on the .NET 10 line).
3. **Version bump** – `PatchVersion` 130 → 140 in `eng/Versions.props`.
Servicing label and `StabilizePackageVersion=true` are inherited from
SR13.

Reviewed and intentionally **not** included:

- #40136 (`net10.0` Publish-Build-Assets cleanup): SR13 has no
`Publish-Build-Assets` references, so nothing to remove.
- #39882 (re-land of the CollectionView2 height fix): SR13 already
carries the revert #39855 that fixed #39847; re-landing is a
fix-forward, not a regression fix.
- #40213 (`[net10.0][XSG]` CA2252 suppression, issue #40045): still
open/unmerged; can be backported once approved.
- Other `regressed-in-10.0.1x0` issues closed since the SR13 cut
(#38622, #39557/#39681, #39722) are already fixed on SR13 or were fixed
outside MAUI.

Keep in draft pending review and CI. This PR does not tag, publish, or
authorize a release; the internal dnceng mirror of
`release/10.0.1xx-sr14` has not been created.

#### Validation

Using the pinned SDK `10.0.113` provisioned by `eng/common/dotnet.sh`:

- `dotnet msbuild eng/Versions.props
-getProperty:PatchVersion,SdkBandVersion,PreReleaseVersionLabel,StabilizePackageVersion,DotNetFinalVersionKind`
→ `140`, `10.0.100`, `servicing`, `true`, `release`. `xmllint --noout
eng/Versions.props` passed.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -f
net10.0 --filter FullyQualifiedName~StrokeShapeTests` (platform TFMs
disabled): **passed 59/59**. With `Shape.cs` reverted to SR13: **failed
3/59** (the new `CustomShapeReimplementingIShape*` tests); restored:
**passed 59/59**.
- #39887 is Windows-only (`ShellItemHandler.Windows.cs` + Windows device
test) and was not built locally on macOS; it relies on CI.

### Issues Fixed

Fixes #39859
Fixes #40129

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 4fd39d58 Deployed Nov 4, 2026 by sheiksyedm via conclusion #2689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell Navigates to Initial page twice in Microsoft.Maui.Controls Version 10.0.120

4 participants