Skip to content

Pop one page per '..' segment on absolute Shell routes - #40101

Merged
kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr2from
MykhailoDav:fix-15166-shell-dotdot-route
Nov 10, 2026
Merged

kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr2from
MykhailoDav:fix-15166-shell-dotdot-route

Conversation

@MykhailoDav

Copy link
Copy Markdown
Contributor

Description of Change

When an absolute Shell route is prefixed with .. segments — e.g. GoToAsync("//../../Page2") while two registered-route pages are pushed on the current tab — the .. segments are silently lost. ShellUriHandler.FormatUri only handles .. on fully relative routes, so for //-prefixed routes the dots reach ConvertToStandardFormat, where standard Uri dot-segment normalization deletes them. The request degrades to a plain //Page2 tab switch and the pages stay on the previous tab's navigation stack, so re-selecting that tab shows the old detail page instead of its root.

Because the navigation target is a different ShellSection, the pop cannot be expressed in the rewritten URI (stack diffing only applies to the target section) — the pages have to be removed from the section being navigated away from.

Fix

Capture the number of leading .. segments before the request is resolved (ShellUriHandler.CountLeadingDotDotSegments) and, once the navigation is accepted and the shell element switch has completed, remove one page per .. from the top of the previous section's stack — the same RemovePage pattern the modal cleanup in ShellNavigationManager.GoToAsync already uses. The removal is clamped at the section root, runs only when the section actually changed (same-section absolute routes already reset their stack), and never runs when navigation is cancelled or deferred.

Tests

Added to ShellNavigatingTests using the issue's exact scenario (tabs Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

Without fix With fix
GoToAsync("//../../Page2") Switches to Page2; Page4 and Page5 remain on Page3's stack Switches to Page2; Page3's stack back to its root
GoToAsync("//../Page2") Switches to Page2; both pages remain Switches to Page2; only Page5 popped
Existing Shell suites — 566/566 pass; full Core.UnitTests has no new failures

Issues Fixed

Fixes #15166

@github-actions

github-actions Bot commented Nov 9, 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 -- 40101

Or

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

@azure-pipelines

This comment has been minimized.

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

Copy link
Copy Markdown
Contributor

Hey there @@MykhailoDav! 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 @MykhailoDav! 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 9, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@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 — 1 finding

Reviewed commit 2368bd3.

See inline comments for details.

await shell.GoToAsync("Page5");
Assert.Equal(3, page3Section.Stack.Count);

await shell.GoToAsync("//../Page2");

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 - Both added tests switch to a different section, leaving the new same-section exclusion untested. With the same Page3 -> Page4 -> Page5 fixture, navigate to `(redacted) and assert that Page4 remains the current page and the stack retains it. The destination stack is rebuilt before the new removal loop; removing its section-identity guard would therefore remove the retained Page4 while both added tests still succeed. Add this negative case so the tests distinguish popping the departed section from deleting the rebuilt destination.

@MauiBot

MauiBot commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@MykhailoDav — existing-test verification for commit 2368bd39.

Result PASSED Platform Android Commit 2368bd39


🧪 Gate analysis — click to expand

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

🧪 Unit tests
Test group Without fix With fix
ShellNavigatingTests ✅ Failed as expected (82s) ✅ Passed (69s)
Execution log excerpts

Without fix ShellNavigatingTests

     at Microsoft.Maui.Controls.Core.UnitTests.ShellNavigatingTests.AbsoluteRoutePrefixedWithDotDotSegmentsPopsPagesFromPreviousSection() in /_/src/Controls/tests/Core.UnitTests/ShellNavigatingTests.cs:line 470
     at Microsoft.Maui.Controls.Core.UnitTests.ShellNavigatingTests.EachDotDotSegmentOnAbsoluteRoutePopsOnePageFromPreviousSection() in /_/src/Controls/tests/Core.UnitTests/ShellNavigatingTests.cs:line 493

With fix ShellNavigatingTests

sed CancelledPushRestoresDisplacedImplicitRoute [1 ms]
  Passed PopToRootWithMultipleFlyoutItems [1 ms]
  Passed GlobalRoutesRegisteredHierarchicallyNavigateCorrectlyWithAdditionalItems [3 ms]
  Passed ShellContentOnlyWithGlobalEdit [1 ms]
  Passed GlobalRoutesRegisteredHierarchicallyWithDoublePop [2 ms]
  Passed NavigationPushAndPopBasic [2 ms]
  Passed AbsoluteRoutingToPage [4 ms]
  Passed CancelledPushRemovesOnlyPushedPageImplicitRoute [1 ms]
  Passed CancelNavigationOccurringOutsideGotoAsyncWithoutDelay [1 ms]
  Passed RoutingToContentThatIsNotAPageThrows(route: "catdetails/dogdetails") [4 ms]
  Passed RoutingToContentThatIsNotAPageThrows(route: "catdetails") [< 1 ms]
[xUnit.net 00:00:05.30]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed CancelNavigationOccurringOutsideGotoAsync [106 ms]
  Passed ShellSectionWithGlobalRouteAbsolute [1 ms]
  Passed HierarchicalNavigationWithBackNavigation [1 ms]
  Passed GlobalRoutesRegisteredHierarchicallyWithDoubleSplash [1 ms]
  Passed MultiplePopsRemoveMiddlePagesBeforeFinalPop [1 ms]
  Passed SwappingOutVisiblePageDoesntRevealPreviousPage [1 ms]
Test Run Successful.
Total tests: 59
     Passed: 59
 Total time: 5.8088 Seconds

PR head: 2368bd39.

Without-fix baseline: c7e8239c.

@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 9, 2026
@kubaflo
kubaflo changed the base branch from main to candidate/11.0.1xx-sr2 November 10, 2026 21:38
@kubaflo
kubaflo merged commit b082718 into dotnet:candidate/11.0.1xx-sr2 Nov 10, 2026
172 of 185 checks passed
kubaflo added a commit that referenced this pull request Nov 11, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 13, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 17, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.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
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes dotnet#15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 2368bd39 Deployed Nov 9, 2026 by MykhailoDav via conclusion #2848
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution 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.

Using ".." in route definition doesn't remove last navigated page(s) from nav stack

3 participants