Skip to content

[iOS] Fix NavigationPage and Shell: Respect back-button handling for interactive pop gestures - #38071

Merged
kubaflo merged 8 commits into
dotnet:inflight/currentfrom
Dhivya-SF4094:fix-37781
Sep 4, 2026
Merged

kubaflo merged 8 commits into
dotnet:inflight/currentfrom
Dhivya-SF4094:fix-37781

Conversation

@Dhivya-SF4094

@Dhivya-SF4094 Dhivya-SF4094 commented Sep 1, 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!

Issue Detail:

  • On iOS, the interactive edge-swipe back gesture can pop a page even when the page overrides OnBackButtonPressed() and returns true to handle the back navigation.
  • This regression occurs when a page is hosted in a NavigationPage with its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from the left edge can begin the native interactive pop gesture without first consulting the current page. As a result:
  • OnBackButtonPressed() is not invoked.
  • Application-specific back-navigation logic is bypassed.
  • The page is popped from the native navigation stack even though the page intended to handle and cancel the back operation.
  • This behavior differs from the navigation bar's back button, which already respects SendBackButtonPressed() and prevents the native navigation when the page handles the back request.

Root Cause

Navigation Page:
The iOS interactive-pop gesture delegate always returned true. For pages with a hidden navigation bar, UIKit therefore started the swipe-back gesture without invoking SendBackButtonPressed(), preventing the page from vetoing navigation.

Shell Page:

  • On iOS, Shell’s interactive swipe-back gesture was allowed based only on ProposeNavigation(). The managed back-button pipeline was not invoked before UIKit started the native pop transition.

  • As a result, Shell.OnBackButtonPressed() and the visible page’s OnBackButtonPressed() could not handle or cancel the swipe-back gesture. This also affected pages with Shell.NavBarIsVisible="False", since hiding the navigation bar does not disable UIKit’s interactive-pop gesture.

  • Handling the callback later in SendPop() was too late because the native pop transition had already started.

Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks handled navigation requests, preserves lifecycle tracking, and avoids duplicate callbacks for pages with visible navigation bars.

Shell Page:

The iOS interactive-pop gesture delegate now runs the Shell back-button pipeline before allowing the native transition:

  • Invoke Shell.OnBackButtonPressed().
  • If Shell does not handle the action, invoke the visible page’s OnBackButtonPressed().
  • Cancel the gesture if either callback handles the back action.
  • Otherwise, call ProposeNavigation() to validate the navigation and allow UIKit to continue the interactive pop.
  • A gesture-specific Shell dispatch prevents the base Shell implementation from calling PopAsync(), which would otherwise start a managed pop while UIKit is already performing the interactive transition.
  • The accepted gesture is also tracked so the back-button callbacks are not invoked again when UIKit completes the pop.
  • This keeps the callback order consistent with Android’s Shell-first behavior and ensures the fix works for both visible and hidden navigation bars.

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed:

Fixes #37781

Screenshots

Before  After 
37781_BeforeFix.mov
37781_AfterFix.mov

@github-actions

github-actions Bot commented Sep 1, 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 -- 38071

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Sep 1, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@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 Sep 1, 2026

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

See inline comments for details.

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-failed AI could not verify tests catch the bug s/agent-fix-win AI found a better alternative fix than the PR 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 Sep 2, 2026
@Dhivya-SF4094 Dhivya-SF4094 changed the title [WIP] [iOS] Fix Interactive pop gesture is now always allowed on NavigationPage [iOS] Fix Interactive pop gesture is now always allowed on NavigationPage Sep 2, 2026
@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 Sep 2, 2026

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

@kubaflo
kubaflo changed the base branch from main to inflight/current September 4, 2026 16:26

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

AI Review Summary

@Dhivya-SF4094 — new AI review results are available based on commit d7ad295.

Gate Passed Confidence Medium Platform iOS


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: IOS · Base: main · Merge base: 7d9efcdc

Test Without Fix (expect FAIL) With Fix (expect PASS)
📱 NavigationPageTests (InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarHidden, InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarVisible) Category=NavigationPage ⚠️ ENV ERROR ⚠️ ENV ERROR
📱 ShellTests (InteractivePopGestureRespectsBackButtonPressed, InteractivePopGestureStateIsResetWhenRendererDisappears) Category=Shell ⚠️ ENV ERROR ⚠️ ENV ERROR
🖥️ Issue37781 Issue37781 ✅ FAIL — 200s ✅ PASS — 138s
🔴 Without fix — 📱 NavigationPageTests (InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarHidden, InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarVisible): ⚠️ ENV ERROR · 247s

No log file found

🟢 With fix — 📱 NavigationPageTests (InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarHidden, InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarVisible): ⚠️ ENV ERROR · 73s

No log file found

🔴 Without fix — 📱 ShellTests (InteractivePopGestureRespectsBackButtonPressed, InteractivePopGestureStateIsResetWhenRendererDisappears): ⚠️ ENV ERROR · 152s

No log file found

🟢 With fix — 📱 ShellTests (InteractivePopGestureRespectsBackButtonPressed, InteractivePopGestureStateIsResetWhenRendererDisappears): ⚠️ ENV ERROR · 123s

No log file found

🔴 Without fix — 🖥️ Issue37781: FAIL ✅ · 200s

Error-relevant lines (filtered from the build log):

     at Microsoft.Maui.TestCases.Tests.Issues.Issue37781.EdgeSwipePopsPageWhenBackButtonPressedReturnsFalse() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue37781.cs:line 44
     at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2757
   at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2784
   at UITest.Appium.HelperExtensions.WaitForElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 793
   at Microsoft.Maui.TestCases.Tests.Issues.Issue37781.EdgeSwipeRemainsOnPageWhenBackButtonPressedReturnsTrue() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue37781.cs:line 28
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
🟢 With fix — 🖥️ Issue37781: PASS ✅ · 138s

(no coded error found; showing last 1200 chars)

rk/1/s/artifacts/bin/Controls.TestCases.iOS.Tests/Debug/net10.0/Controls.TestCases.iOS.Tests.dll
   NUnit3TestExecutor discovered 2 of 2 NUnit test cases using Current Discovery mode, Non-Explicit run
>>>>> 9/4/2026 8:17:20 AM EdgeSwipePopsPageWhenBackButtonPressedReturnsFalse Start
>>>>> 9/4/2026 8:17:20 AM FixtureSetup for EdgeSwipePopsPageWhenBackButtonPressedReturnsFalse
>>>>> 9/4/2026 8:17:29 AM EdgeSwipePopsPageWhenBackButtonPressedReturnsFalse Stop
  Passed EdgeSwipePopsPageWhenBackButtonPressedReturnsFalse [13 s]
>>>>> 9/4/2026 8:17:34 AM EdgeSwipeRemainsOnPageWhenBackButtonPressedReturnsTrue Start
>>>>> 9/4/2026 8:17:34 AM FixtureSetup for EdgeSwipeRemainsOnPageWhenBackButtonPressedReturnsTrue
>>>>> 9/4/2026 8:17:42 AM EdgeSwipeRemainsOnPageWhenBackButtonPressedReturnsTrue Stop
  Passed EdgeSwipeRemainsOnPageWhenBackButtonPressedReturnsTrue [12 s]
NUnit Adapter 4.5.0.0: Test execution complete
Results File: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue37781.trx
Test Run Successful.
Total tests: 2
     Passed: 2
 Total time: 38.2722 Seconds
>>> TRX_RESULT_FILE: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/UITests/TestResults/Issue37781.trx

⚠️ Failure Details

  • ⚠️ NavigationPageTests (InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarHidden, InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarVisible) without fix: XHarness did not produce the expected fresh result 'testResults.xml' for requested class(es) 'Microsoft.Maui.DeviceTests.NavigationPageTests' (the target tests did not run).
  • ⚠️ ShellTests (InteractivePopGestureRespectsBackButtonPressed, InteractivePopGestureStateIsResetWhenRendererDisappears) without fix: XHarness did not produce the expected fresh result 'testResults.xml' for requested class(es) 'Microsoft.Maui.DeviceTests.ShellTests' (the target tests did not run).
  • ⚠️ NavigationPageTests (InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarHidden, InteractivePopGestureRespectsBackButtonPressedWhenNavigationBarVisible) with fix: XHarness did not produce the expected fresh result 'testResults.xml' for requested class(es) 'Microsoft.Maui.DeviceTests.NavigationPageTests' (the target tests did not run).
  • ⚠️ ShellTests (InteractivePopGestureRespectsBackButtonPressed, InteractivePopGestureStateIsResetWhenRendererDisappears) with fix: XHarness did not produce the expected fresh result 'testResults.xml' for requested class(es) 'Microsoft.Maui.DeviceTests.ShellTests' (the target tests did not run).
📁 Fix files reverted (3 files)
  • src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs
  • src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs
  • src/Controls/src/Core/Shell/Shell.cs

📋 Pre-Flight — Context & Validation

PR #38071 Pre-Flight

Scope

  • PR: [iOS] Fix NavigationPage and Shell: Respect back-button handling for interactive pop gestures
  • Base: main at merge base 7d9efcdc06
  • Materialized review commit: b3e8a4e6a5
  • Issue: #37781, an iOS regression introduced after 10.0.51 in which the edge-swipe interactive pop gesture is admitted without consulting managed back handling.
  • Expected behavior: A page or Shell override that handles OnBackButtonPressed() must veto the native interactive pop. An unhandled request must still pop and preserve navigation lifecycle events.

Existing PR Approach

The PR evaluates managed back handling from the gesture recognizer's ShouldBegin callback, before UIKit starts the interactive transition:

  • NavigationRenderer replaces the unconditional gesture delegate with ShouldBeginInteractivePop(), calls the current page's back callback, and tracks an accepted gesture so ShouldPopItem does not call the callback twice.
  • ShellSectionRenderer centralizes back-button behavior/command handling, invokes a gesture-specific Shell back pipeline before ProposeNavigation(), and tracks an accepted gesture so SendPop() does not repeat callbacks.
  • Shell adds a gesture-scoped flag so its default OnBackButtonPressed() implementation does not start a managed PopAsync() while UIKit is already preparing the native interactive pop.
  • Pending gesture state is cleared during disappearance, disposal, and navigation completion.

Diff Inspected

Production files:

  • src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs
  • src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs
  • src/Controls/src/Core/Shell/Shell.cs

Test files:

  • src/Controls/tests/DeviceTests/Elements/NavigationPage/NavigationPageTests.iOS.cs
  • src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.iOS.cs
  • src/Controls/tests/TestCases.HostApp/Issues/Issue37781.cs
  • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue37781.cs

The candidate modification boundary is the three production files recorded by EstablishBrokenBaseline.ps1; test additions remain as the verification contract.

Targeted Test Contract

Run only these iOS tests for each candidate:

  1. Primary UI regression:
    pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform ios -TestFilter "Issue37781"
  2. NavigationPage device regressions:
    pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=NavigationPage"
  3. Shell device regressions:
    pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=Shell"

Do not rerun gate verification and do not run a broader suite.

Candidate Constraints

  • Each attempt must use a root-cause mechanism different from the PR and from prior candidates.
  • One implementation/test pass is allowed, followed by at most one focused correction/retest.
  • The inline expert self-review required by try-fix is sufficient; no reviewer sub-agent may be launched.
  • Preserve all pre-existing worktree changes and restore candidate edits only with pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore.

🔬 Code Review — Deep Analysis

Code Review — PR #38071

Independent Assessment

What this changes: The iOS NavigationRenderer and ShellSectionRenderer now consult managed back-button handling before admitting UIKit's interactive pop gesture. Both renderers remember an admitted gesture long enough to avoid invoking the managed callback again from the later navigation-bar/native-pop path. Shell adds a narrowly scoped dispatch mode that runs the Shell/page back pipeline without allowing the base implementation to initiate a competing managed PopAsync().

Inferred motivation: UIKit can begin an edge-swipe pop independently of the navigation-bar back-button delegate, so checking SendBackButtonPressed() only after the transition starts cannot reliably veto the native pop.

Approach: Sound. Admission-time vetoing is the correct layer for an interactive UIKit gesture. The accepted-gesture latches have explicit completion/lifecycle reset paths (DidShowViewController, ViewDidDisappear, and Shell disposal), and the Shell try/finally scope prevents the gesture-only suppression mode from leaking into later back requests.

Reconciliation with PR Narrative

The title and description accurately explain the NavigationPage and Shell failure mechanisms and match the submitted implementation. The only nuance is that NavigationPage intentionally calls the current page directly rather than a NavigationPage subclass override; the description's statement that it follows the existing ShouldPopItem policy is accurate.

Prior Review Reconciliation

Prior finding Source Status Evidence
The compatibility NavigationRenderer is not the default iOS handler, so the fix/test misses the real path MauiBot on earlier commits 🔄 Obsolete / disproven The current test setup resolves NavigationRenderer, and the real Issue37781 Appium swipe test fails without the submitted fix and passes with it.
NavigationPage device tests exercise the wrong handler MauiBot on current head 🔄 Obsolete / disproven Same handler-resolution evidence plus the end-to-end UI test proves the submitted production path is active.
Shell's accepted-gesture latch survives lifecycle exit and bypasses later back handling MauiBot on current head ✅ Fixed Current HEAD clears _interactivePopGesturePending in ViewDidDisappear, Dispose, and NavDelegate.DidShowViewController; a focused lifecycle test covers the disappearance path.
Shell's recognizer delegate is not explicitly cleared before _context is nulled Copilot reviewer on current head Non-blocking, pre-existing The recognizer delegate and its callback into ShouldPop predate this PR, and pre-PR ShouldPop already dereferenced _context. The submitted diff does not introduce the callback lifetime. The dedicated expert pass found no actionable finding against the changed lines.

Blast Radius Assessment

  • Runs for all instances: The new policy executes only when an iOS NavigationPage or Shell interactive-pop recognizer asks to begin, plus the existing native completion path for a gesture that was admitted.
  • Startup impact: None.
  • Static/shared state: None. State is renderer- or Shell-instance scoped.
  • Lifecycle behavior: Accepted state is cleared after successful or canceled UIKit transitions through DidShowViewController, when the renderer disappears, and during Shell disposal.
  • Adjacent scenarios: Navigation bars visible and hidden, handled and unhandled page callbacks, Shell-first callback order, and repeated native callback suppression are covered. The UI regression covers an actual edge swipe with both handled and unhandled outcomes.

Validation Evidence

  • Trusted Gate: passed; the Issue37781 UI regression failed without the fix and passed with it (2/2).
  • The Gate's two synthetic device-test invocations were environment-blocked, but STEP 5a attempt 1 subsequently ran the unchanged submitted PR through the exact required commands: Issue37781 2/2, NavigationPage 22/22, and Shell 210/210.
  • Regression cross-reference: CLEAN.
  • The public GitHub check snapshot is still mixed/in progress; it does not supersede the explicitly supplied trusted Gate for this candidate comparison.

Findings

No actionable file:line findings. inline-findings.json contains [].

Failure-Mode Probing

  • Handled callback: ShouldBegin returns false, so UIKit never starts the native transition.
  • Unhandled callback: admission sets the pending latch; the later native pop path skips only the already-delivered callback and performs the managed/native stack synchronization.
  • Canceled interactive transition: UIKit's DidShowViewController clears the latch when the original controller is shown again.
  • Renderer disappearance/disposal: lifecycle exits clear the Shell latch; NavigationPage also clears on disappearance and native completion.
  • Shell callback ordering: Shell dispatch runs first; the base Shell implementation then invokes the visible page. Gesture mode returns before the normal managed NavigationPop, preventing competing transitions.
  • BackButtonBehavior: disabled behavior and configured commands veto the gesture consistently with the existing navigation-bar path.

External Output Contract

Not applicable.

Trim/AOT Evidence Chain

Not applicable.

Verdict: LGTM

Confidence: medium

Summary: The submitted iOS fix is coherent with UIKit's admission lifecycle, preserves one managed callback per gesture, and has direct regression evidence. Confidence is capped at medium because this is platform-specific navigation plumbing, but there are no blocking errors or unresolved discussion items in the submitted diff.


🛠️ Try-Fix — Analysis & Comparison

Try-Fix Aggregate (PR #38071)

Aggregate Status

  • Candidates completed: 2
  • Candidates passing: 0
  • Candidates blocked: 2
  • Candidates failed: 0
  • Current overall state: Blocked — bounded maximum of 2 candidates exhausted without a safely executable candidate implementation
  • Final STEP 5a status: Complete — 0 Pass, 0 Fail, 2 Blocked; no winning alternative candidate

Candidate 1 Narrative

Candidate Metadata

  • Candidate: 1 of at most 2
  • Attempt directory: CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-1/
  • Platform: iOS
  • Final status: Blocked
  • findings_count: 0

Approach

Planned alternative mechanism: gate iOS interactive pop via navigation transition/delegate lifecycle context (transition intent/completion), not by evaluating back handling in gesture ShouldBegin and not by carrying accepted-gesture pending flags.

Mechanistic difference vs current PR

Current PR mechanism:

  1. Calls managed back handling during gesture ShouldBegin.
  2. Persists accepted-gesture state with pending booleans in renderer/Shell.
  3. Uses that state to suppress duplicate pop/callback behavior later.

Candidate-1 planned mechanism:

  1. Avoid ShouldBegin pre-admission back evaluation.
  2. Infer/coordinate pop acceptance and callback suppression from transition delegate flow.
  3. Avoid accepted-gesture pending flags entirely.

Baseline and mutation boundary outcome

Mandatory baseline setup command:

pwsh .github/scripts/EstablishBrokenBaseline.ps1

Result: failed immediately with ERROR: DIRTY WORKING DIRECTORY - Cannot establish baseline.

Observed consequence:

  • .github/.baseline-state.json was not created.
  • No RevertedFiles allow-list was available.
  • Per contract, no tracked production target files were edited.

Baseline log: CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-1/baseline.log

Complete captured candidate diff

Captured from:
CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-1/fix.diff

(No candidate code diff was produced because baseline establishment failed before safe mutation boundaries were available.)

Required test commands and results

All required commands were run in order and fully logged to:
CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-1/test-output.log

  1. pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform ios -TestFilter "Issue37781"

    • Result: Pass
    • Evidence: Test Run Successful., All tests passed, EXIT_CODE=0
    • Test summary: 2 passed, 0 failed
  2. pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=NavigationPage"

    • Result: Pass
    • Evidence: XHarness exit code 0, EXIT_CODE=0
    • Test summary: Tests run: 22 Passed: 22 ... Failed: 0
  3. pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=Shell"

    • Result: Pass
    • Evidence: XHarness exit code 0, EXIT_CODE=0
    • Test summary: Tests run: 210 Passed: 210 ... Failed: 0

Exit-code capture file: CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-1/test-exitcodes.json ({"cmd1":0,"cmd2":0,"cmd3":0})

Inline self-review result

  • Artifact: CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-1/reviewer-findings.json
  • Content: []
  • findings_count: 0 (clean self-review)

Failure analysis

Candidate status is Blocked (not Pass) because the candidate implementation itself could not be safely executed:

  • Baseline precondition failed (DIRTY WORKING DIRECTORY).
  • Without baseline state and RevertedFiles, changing tracked target files would violate restoration safety constraints.
  • Although all required validation commands passed on current head, this does not validate an alternative candidate implementation because no candidate code changes were applied.

Restore confirmation

After artifacts were captured, restore command executed:

pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore

Output: No baseline state found. Nothing to restore. (completed successfully, no active baseline state existed).


Candidate 2 Narrative

Candidate Metadata

  • Candidate: 2 of exactly 2 (final bounded candidate)
  • Attempt directory: CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-2/
  • Platform: iOS
  • Final status: Blocked
  • findings_count: 0

Approach

Planned alternative mechanism: replace the built-in edge-swipe recognizer with a renderer-owned screen-edge pan interaction so the ordinary managed back pipeline remains the sole navigation owner. At pan start, one managed back request would run; a handled request would start no transition, while an unhandled request would initiate exactly one UIKit interactive pop and drive its progress/cancellation from the pan. Existing managed-pop synchronization would deliver lifecycle events without a second callback-suppression channel.

Explicit mechanism-level distinction

The current PR keeps UIKit's built-in gesture as navigation owner, invokes managed handling in gesture ShouldBegin, stores accepted-gesture pending flags in renderers, and uses Shell.SendBackButtonPressedFromGesture() plus a gesture-scoped Shell suppression flag.

Candidate 1 also kept UIKit ownership but proposed deriving acceptance and callback suppression from transition delegate lifecycle flow, without ShouldBegin.

Candidate 2 hypothesizes instead that the bypass exists because UIKit owns the request before MAUI. It reverses ownership: a managed request would create and drive one native interactive operation. It does not use built-in gesture ShouldBegin, accepted-gesture pending flags, a gesture-scoped Shell suppression flag, or transition-delegate inference. The native UIKit interactive transition would continue, but only as the result of the single managed-owned navigation request.

Baseline and mutation boundary outcome

Mandatory baseline setup command:

pwsh .github/scripts/EstablishBrokenBaseline.ps1

Result: failed with ERROR: DIRTY WORKING DIRECTORY - Cannot establish baseline.

Observed consequence:

  • .github/.baseline-state.json was absent after the command.
  • No authoritative RevertedFiles allow-list existed.
  • Pre-existing user/harness changes were preserved.
  • No tracked production target was edited.

Baseline log: CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-2/baseline.log

Complete captured candidate diff

Captured in CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-2/fix.diff:

No candidate diff exists because safe baseline setup failed before implementation.

Required test commands and results

Full not-run record: CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-2/test-output.log

  1. pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform ios -TestFilter "Issue37781"

    • Result: Not run
    • Reason: no candidate implementation could be safely created, so this command would only retest unchanged PR code.
  2. pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=NavigationPage"

    • Result: Not run
    • Reason: no candidate implementation could be safely created, so this command would only retest unchanged PR code.
  3. pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=Shell"

    • Result: Not run
    • Reason: no candidate implementation could be safely created, so this command would only retest unchanged PR code.

Candidate 1 already ran all three commands successfully against unchanged PR code; repeating those expensive validations would not validate Candidate 2.

Inline self-review result

  • Artifact: CustomAgentLogsTmp/PRState/38071/PRAgent/try-fix/attempt-2/reviewer-findings.json
  • Content: []
  • findings_count: 0
  • Result: clean. The overarching principles and always-active Logic and Correctness, Regression Prevention, and Complexity Reduction dimensions were applied; no candidate diff existed on which to record a concrete line finding.

Failure analysis

Candidate 2 is Blocked, not Pass:

  • Baseline setup rejected the pre-existing dirty workspace.
  • Without .github/.baseline-state.json, tracked edits would violate the mutation and restoration boundary.
  • The candidate mechanism therefore remains unimplemented and unvalidated.
  • Skipping tests was required because no candidate code existed and rerunning them would not provide candidate-specific evidence.

Restore confirmation

After attempt artifacts were captured, the exact restore command ran:

pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore

It completed successfully for the verified no-state/no-edit path with:

No baseline state found. Nothing to restore.

Structured output reported Restored: False, as expected because baseline setup had created no state and Candidate 2 made no tracked edits.


🏁 Report — Final Recommendation

✅ Final Recommendation: APPROVE

Winner: pr

The raw submitted PR is the single winning candidate. It is the only distinct implemented fix, the trusted Gate proves the original Issue37781 reproduction fails without it and passes with it, all three required targeted commands later passed on the unchanged PR code, and the one permitted expert review produced no actionable findings.

Comparative Ranking

Rank Candidate Implementation Regression evidence Review result Decision
1 pr Complete submitted fix Gate: Issue37781 fails without fix and passes with fix; STEP 5a unchanged-PR run: Issue37781 2/2, NavigationPage 22/22, Shell 210/210 Expert findings []; no blocking error or discussion item Winner
2 pr-plus-reviewer Source-equivalent to pr; no reviewer patch justified Inherits the same evidence because its seven submitted source/test files are unchanged reviewer.patch is empty Equivalent behavior but adds no improvement; rank below the simpler raw PR identity
3 try-fix-1 Blocked before implementation; empty candidate diff Its three commands passed only against unchanged PR code, not an alternative implementation Self-review [] with no candidate code Cannot win because no candidate exists
4 try-fix-2 Blocked before implementation; empty candidate diff Not run because no candidate implementation existed Self-review [] with no candidate code Cannot win because no candidate exists

No candidate implementation failed regression tests. If one had, it would rank below every passing candidate as required. The two try-fix entries are lower because they were blocked and never materialized, not because their hypotheses were disproven.

Why the PR Fix Wins

  • Correct admission point: UIKit's interactive transition is vetoed in gesture ShouldBegin, before a native pop can bypass managed back handling.
  • One callback per gesture: NavigationPage and Shell record an admitted interactive gesture so the later native delegate path does not invoke the application callback twice.
  • No competing Shell pop: SendBackButtonPressedFromGesture() uses try/finally and lets Shell/page overrides run while suppressing only the base managed PopAsync() that would race UIKit.
  • Lifecycle safety: pending gesture state is cleared on native completion/cancellation and relevant disappearance/disposal paths.
  • Behavioral coverage: visible and hidden navigation bars, handled and unhandled callbacks, Shell-first callback order, lifecycle reset, and a real edge swipe are represented.
  • Regression history: the mechanical cross-reference is CLEAN.

Prior Review Reconciliation

Earlier error-level concerns about the handler selection are disproven by the real Issue37781 UI test changing from failure to pass on the submitted production diff. The stale Shell latch concern is fixed in current HEAD by resets in ViewDidDisappear, Dispose, and DidShowViewController. A later comment about clearing the Shell recognizer delegate identifies a pre-existing lifetime pattern: both the delegate and _context-using ShouldPop callback existed before this PR, so it is not a defect introduced by the submitted changes and was not reproduced by the expert reviewer.

Evidence and Uncertainty

The trusted Gate result supplied to this phase permits approval. Its synthetic device-test runs were initially environment-blocked, but STEP 5a attempt 1 subsequently recorded successful runs of the exact required commands against unchanged PR code. The public GitHub snapshot was still mixed/in progress when inspected. Its completed iOS device-test failures were unrelated—a pre-existing CollectionView memory test and a WebView network timeout—and its UI failures were Android/macOS tests outside this diff. The overall maui-pr pipeline had not completed, so this report makes a code/candidate recommendation rather than claiming that all external merge checks are green.

Expert Verdict

LGTM with medium confidence, capped because the change is platform-specific iOS navigation plumbing. There are no blocking errors, unresolved discussion items, or reviewer improvements to apply.


📱 UI Tests — Navigation,Shell

Detected UI test categories: Navigation,Shell

✅ Deep UI tests — 420 passed, 0 failed, 19 skipped across 2 categories on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
Navigation 113/116 (3 skipped) ✓ —
Shell 307/323 (16 skipped) ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

🧭 Next Steps — review latest findings

No alternative fix was selected for this run. Review the session findings and CI results before merging.

@MauiBot MauiBot added s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-gate-failed AI could not verify tests catch the bug s/agent-fix-win AI found a better alternative fix than the PR s/agent-review-in-progress AI review is currently running for this PR labels Sep 4, 2026
kubaflo and others added 2 commits September 4, 2026 19:28
Preserve the weak-reference lifecycle guard in the Shell navigation delegate while resetting interactive-pop gesture state after UIKit completes navigation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
Combine the interactive-pop fix with the newly merged DevFlow navigation registrations and Shell lifecycle tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
@kubaflo

kubaflo commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Resolved the conflicts against the latest inflight/current and pushed merge commit 750f53fec2.

The resolution preserves both sides of the overlapping Apple changes:

  • NavigationRenderer keeps the interactive-pop pending state alongside the new DevFlow native-element registrations.
  • ShellSectionRenderer.NavDelegate retains the weak-reference/disposal guard and clears the pending gesture after UIKit finishes navigation.
  • ShellTests.iOS retains the interactive-pop back-handling coverage together with the newly merged Shell lifecycle and rejected-image disposal tests.

Microsoft.Maui.BuildTasks.slnf and the iOS Controls device-test app build successfully. GitHub now reports the PR as mergeable.

@kubaflo
kubaflo merged commit a293933 into dotnet:inflight/current Sep 4, 2026
2 of 12 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR11 milestone Sep 4, 2026
kubaflo added a commit that referenced this pull request Sep 6, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 7, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 8, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 9, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 11, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 15, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 18, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 21, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 27, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Sep 27, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Oct 3, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
kubaflo added a commit that referenced this pull request Oct 3, 2026
…interactive pop gestures (#38071)

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


### Issue Detail:

- On iOS, the interactive edge-swipe back gesture can pop a page even
when the page overrides OnBackButtonPressed() and returns true to handle
the back navigation.
- This regression occurs when a page is hosted in a NavigationPage with
its navigation bar hidden. Starting with .NET MAUI 10.0.60, a swipe from
the left edge can begin the native interactive pop gesture without first
consulting the current page. As a result:
- OnBackButtonPressed() is not invoked.
- Application-specific back-navigation logic is bypassed.
- The page is popped from the native navigation stack even though the
page intended to handle and cancel the back operation.
- This behavior differs from the navigation bar's back button, which
already respects SendBackButtonPressed() and prevents the native
navigation when the page handles the back request.

### Root Cause

**Navigation Page:**
The iOS interactive-pop gesture delegate always returned true. For pages
with a hidden navigation bar, UIKit therefore started the swipe-back
gesture without invoking SendBackButtonPressed(), preventing the page
from vetoing navigation.

**Shell Page:**

- On iOS, Shell’s interactive swipe-back gesture was allowed based only
on ProposeNavigation(). The managed back-button pipeline was not invoked
before UIKit started the native pop transition.

- As a result, Shell.OnBackButtonPressed() and the visible page’s
OnBackButtonPressed() could not handle or cancel the swipe-back gesture.
This also affected pages with Shell.NavBarIsVisible="False", since
hiding the navigation bar does not disable UIKit’s interactive-pop
gesture.
- Handling the callback later in SendPop() was too late because the
native pop transition had already started.


### Description of Change

Navigation Page:

The hidden-navigation-bar gesture now uses the same back-navigation
policy as ShouldPopItem. It respects SendBackButtonPressed(), blocks
handled navigation requests, preserves lifecycle tracking, and avoids
duplicate callbacks for pages with visible navigation bars.

**Shell Page:**

The iOS interactive-pop gesture delegate now runs the Shell back-button
pipeline before allowing the native transition:
- Invoke Shell.OnBackButtonPressed().
- If Shell does not handle the action, invoke the visible page’s
OnBackButtonPressed().
- Cancel the gesture if either callback handles the back action.
- Otherwise, call ProposeNavigation() to validate the navigation and
allow UIKit to continue the interactive pop.
- A gesture-specific Shell dispatch prevents the base Shell
implementation from calling PopAsync(), which would otherwise start a
managed pop while UIKit is already performing the interactive
transition.
- The accepted gesture is also tracked so the back-button callbacks are
not invoked again when UIKit completes the pop.
- This keeps the callback order consistent with Android’s Shell-first
behavior and ensures the fix works for both visible and hidden
navigation bars.

### Validated the behaviour in the following platforms
- [ ] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Issues Fixed:
Fixes #37781 

### Screenshots
| Before  | After |
|---------|--------|
| <video
src="https://github.com/user-attachments/assets/541cbe6e-fc79-498b-9554-5a3576268633">
| <video
src="https://github.com/user-attachments/assets/897402ff-c67d-4191-9f7e-7faaffc71e8f">
|

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 169298fa-95aa-47a4-ad1c-512dc3f97871
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 5, 2026
@github-actions github-actions Bot modified the milestones: .NET 10 SR11, .NET 10 SR12 Oct 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-navigation NavigationPage community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Interactive pop gesture is now always allowed on NavigationPage — intended default change in a service release? (10.0.51 → 10.0.90)

5 participants