Skip to content

[iOS, Mac] Fix OnBackButtonPressed not invoked for NavigationPage and Shell#35072

Merged
kubaflo merged 9 commits into
dotnet:inflight/currentfrom
Dhivya-SF4094:fix-8296
May 5, 2026
Merged

[iOS, Mac] Fix OnBackButtonPressed not invoked for NavigationPage and Shell#35072
kubaflo merged 9 commits into
dotnet:inflight/currentfrom
Dhivya-SF4094:fix-8296

Conversation

@Dhivya-SF4094

@Dhivya-SF4094 Dhivya-SF4094 commented Apr 22, 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 Details:

#8296 - ContentPage.OnBackButtonPressed not invoked on iOS/MacCatalyst when the native navigation bar back button is tapped inside a NavigationPage.

#9095 - Shell.OnBackButtonPressed not invoked when the toolbar back button is tapped on Android and iOS Shell pages

Root Cause

#8296

  • ShouldPopItem in NavigationRenderer.cs (the navigationBar:shouldPopItem: UIKit delegate callback) fires when the user taps the native iOS back button.
  • Previously it unconditionally set _uiRequestedPop = true and returned true, allowing the native pop without ever notifying MAUI's page model. As a result, ContentPage.OnBackButtonPressed was never called on iOS when the native back button was tapped inside a NavigationPage.

#9095 - iOS (ShellSectionRenderer.cs)

  • Same issue — tracker.Value.Page?.SendBackButtonPressed() skipped the Shell chain and went directly to the ContentPage.

Description of change

#8296 NavigationRenderer.cs

  • In ShouldPopItem, call NavPage?.CurrentPage?.SendBackButtonPressed() before allowing the native pop. If it returns true (the page handled/cancelled back navigation), reset _uiRequestedPop and return false to prevent the native pop.

#9095 ShellSectionRenderer.cs (iOS Shell)

  • Route through _context.Shell?.SendBackButtonPressed() instead of tracker.Value.Page?.SendBackButtonPressed(), so the Shell back button tap goes through the same chain as the system back button.

Note on _sendPopPending = false in the BackButtonBehavior command path: On iOS 26+, _sendPopPending is set to true unconditionally at the start of SendPop(), before any BackButtonBehavior checks. When a BackButtonBehavior.Command executes and returns false (preventing navigation), ViewDidDisappear never fires — so without an explicit reset, the flag stays true permanently and silently blocks all subsequent back presses. The _sendPopPending = false after command execution (line 188) is therefore an intentional and necessary fix to prevent the back button becoming permanently unresponsive after a command-handled back press on iOS 26+.

Test results

Shell — OnBackButtonPressed (fixes #9095)

Platform Navigation OnBackButtonPressed
iOS / MacCatalyst GoToAsync ✅ Triggered
Android GoToAsync ✅ Triggered (app back button and emulator back button)
Windows GoToAsync ✅ Triggered

OnBackButtonPressed is triggered for both the Shell and the contained ContentPage.

NavigationPage — OnBackButtonPressed (fixes #8296)

Platform Navigation OnBackButtonPressed Notes
iOS / MacCatalyst PushAsync ✅ Triggered
iOS / MacCatalyst PushModalAsync Back button not visible in modal navigation
Android PushAsync ✅ Triggered (app back button and emulator back button)
Android PushModalAsync ✅ Triggered Called on the modal ContentPage
Windows PushAsync ✅ Triggered
Windows PushModalAsync Back button not visible in modal navigation

On Android and Windows, OnBackButtonPressed is triggered for both the NavigationPage and the contained ContentPage.

TabbedPage — OnBackButtonPressed

Platform Navigation OnBackButtonPressed Notes
iOS / MacCatalyst PushAsync ✅ Triggered
iOS / MacCatalyst PushModalAsync Back button not visible in modal navigation
Android PushAsync ✅ Triggered
Android PushModalAsync ✅ Triggered
Windows PushAsync ✅ Triggered
Windows PushModalAsync Back button not visible in modal navigation

FlyoutPage — OnBackButtonPressed

Platform Navigation OnBackButtonPressed Notes
iOS / MacCatalyst PushAsync ✅ Triggered
iOS / MacCatalyst PushModalAsync Back button not visible in modal navigation
Android PushAsync ✅ Triggered
Android PushModalAsync ✅ Triggered
Windows PushAsync ✅ Triggered
Windows PushModalAsync Back button not visible in modal navigation

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issue Fixes

Fixes #8296

Screenshots

Before  After 
8296  
BeforeFix-8296.mov
  
AfterFix-8296.mov
9095  
9095_BeforeFix_iOS.mov
  
9095_AfterFix_iOS.mov

@github-actions

github-actions Bot commented Apr 22, 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 -- 35072

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 22, 2026
@NirmalKumarYuvaraj NirmalKumarYuvaraj added the community ✨ Community Contribution label Apr 22, 2026
@sheiksyedm sheiksyedm added area-navigation NavigationPage area-controls-shell Shell Navigation, Routes, Tabs, Flyout labels Apr 22, 2026
@Dhivya-SF4094 Dhivya-SF4094 changed the title Fix OnBackButtonPressed not invoked on iOS/MacCatalyst for NavigationPage and Shell [Android, iOS, Mac] Fix OnBackButtonPressed not invoked for NavigationPage and Shell Apr 22, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review April 22, 2026 13:36
Copilot AI review requested due to automatic review settings April 22, 2026 13:36
@sheiksyedm sheiksyedm added this to the .NET 10 SR7 milestone Apr 22, 2026
@sheiksyedm

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes cases where tapping the UI back button (navigation bar/toolbar) bypasses MAUI’s back-press pipeline, so OnBackButtonPressed overrides were not invoked for Shell (Android/iOS/Mac) and NavigationPage (iOS/Mac). Adds corresponding HostApp repro pages and Appium UI tests.

Changes:

  • iOS Shell: route navigation-bar back taps through Shell.SendBackButtonPressed() and fix _sendPopPending reset on iOS 26+ when back is canceled.
  • Android Shell: route toolbar back taps through Shell.SendBackButtonPressed() instead of going straight to the current Page.
  • Add new HostApp issue pages + Appium UI tests for issues #8296 and #9095.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs Ensures Shell back-button interception runs for nav-bar back, and prevents iOS 26+ _sendPopPending from getting stuck when back is canceled.
src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarTracker.cs Routes toolbar back through Shell’s back pipeline before popping navigation.
src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs Attempts to intercept iOS native back taps and invoke MAUI back-press handling before allowing the pop.
src/Controls/tests/TestCases.HostApp/Issues/Issue9095.cs Adds Shell-based HostApp repro for toolbar back vs OnBackButtonPressed (true/false paths).
src/Controls/tests/TestCases.HostApp/Issues/Issue8296.cs Adds NavigationPage-based HostApp repro for iOS/macOS native back button calling OnBackButtonPressed (true/false paths).
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9095.cs Adds UI test coverage for Shell toolbar back behavior.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue8296.cs Adds UI test coverage for NavigationPage native back behavior.

Comment thread src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9095.cs
Comment thread src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue8296.cs

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please review the ai's summary?

@dotnet dotnet deleted a comment from MauiBot May 5, 2026
@dotnet dotnet deleted a comment from MauiBot May 5, 2026
@dotnet dotnet deleted a comment from MauiBot May 5, 2026
@dotnet dotnet deleted a comment from MauiBot May 5, 2026
@dotnet dotnet deleted a comment from MauiBot May 5, 2026
@dotnet dotnet deleted a comment from MauiBot May 5, 2026
@dotnet dotnet deleted a comment from MauiBot May 5, 2026
@kubaflo kubaflo added the s/agent-fix-implemented PR author implemented the agent suggested fix label May 5, 2026
@kubaflo kubaflo merged commit 7023635 into dotnet:inflight/current May 5, 2026
39 checks passed
github-actions Bot pushed a commit that referenced this pull request May 6, 2026
… Shell (#35072)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

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

### Issue Details:
#8296 - ContentPage.OnBackButtonPressed not invoked on iOS/MacCatalyst
when the native navigation bar back button is tapped inside a
NavigationPage.

#9095 - Shell.OnBackButtonPressed not invoked when the toolbar back
button is tapped on Android and iOS Shell pages

### Root Cause
#8296
- ShouldPopItem in NavigationRenderer.cs (the
navigationBar:shouldPopItem: UIKit delegate callback) fires when the
user taps the native iOS back button.
- Previously it unconditionally set _uiRequestedPop = true and returned
true, allowing the native pop without ever notifying MAUI's page model.
As a result, ContentPage.OnBackButtonPressed was never called on iOS
when the native back button was tapped inside a NavigationPage.

#9095 -  iOS (ShellSectionRenderer.cs)
- Same issue — tracker.Value.Page?.SendBackButtonPressed() skipped the
Shell chain and went directly to the ContentPage.

### Description of change

#8296  **NavigationRenderer.cs**
- In ShouldPopItem, call NavPage?.CurrentPage?.SendBackButtonPressed()
before allowing the native pop. If it returns true (the page
handled/cancelled back navigation), reset _uiRequestedPop and return
false to prevent the native pop.

#9095 **ShellSectionRenderer.cs** (iOS Shell)

- Route through _context.Shell?.SendBackButtonPressed() instead of
tracker.Value.Page?.SendBackButtonPressed(), so the Shell back button
tap goes through the same chain as the system back button.

**Note** on _sendPopPending = false in the BackButtonBehavior command
path: On iOS 26+, _sendPopPending is set to true unconditionally at the
start of SendPop(), before any BackButtonBehavior checks. When a
BackButtonBehavior.Command executes and returns false (preventing
navigation), ViewDidDisappear never fires — so without an explicit
reset, the flag stays true permanently and silently blocks all
subsequent back presses. The _sendPopPending = false after command
execution (line 188) is therefore an intentional and necessary fix to
prevent the back button becoming permanently unresponsive after a
command-handled back press on iOS 26+.

### Test results 
#### Shell — `OnBackButtonPressed` (fixes #9095)

| Platform | Navigation | `OnBackButtonPressed` |
|---|---|---|
| iOS / MacCatalyst | `GoToAsync` | ✅ Triggered |
| Android | `GoToAsync` | ✅ Triggered (app back button and emulator back
button) |
| Windows | `GoToAsync` | ✅ Triggered |

>`OnBackButtonPressed` is triggered for both the `Shell` and the
contained `ContentPage`.


#### NavigationPage — `OnBackButtonPressed` (fixes #8296)

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered (app back button and emulator back
button) | |
| Android | `PushModalAsync` | ✅ Triggered | Called on the modal
ContentPage |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |

> On Android and Windows, `OnBackButtonPressed` is triggered for both
the `NavigationPage` and the contained `ContentPage`.

#### TabbedPage — `OnBackButtonPressed`

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered | |
| Android | `PushModalAsync` | ✅ Triggered | |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |

#### FlyoutPage — `OnBackButtonPressed`

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered | |
| Android | `PushModalAsync` | ✅ Triggered | |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |


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

### Issue Fixes
Fixes #8296 

### Screenshots
|  | Before  | After |
|--|---------|--------|
|8296|  <video
src="https://github.com/user-attachments/assets/13887369-e9e9-42df-a2a0-db88f0e6b38f">
|   <video
src="https://github.com/user-attachments/assets/d0ccfb01-59e8-44bc-8878-54c5d0f6fb7e"> 
|
|9095 |  <video
src="https://github.com/user-attachments/assets/664e0b7f-3964-4a1b-a4f6-46b1db758b48">
|   <video
src="https://github.com/user-attachments/assets/3ff159ec-93b0-4a91-854a-ca23211ff204"> 
|

---------

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

MauiBot commented May 6, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

@kubaflo

kubaflo commented May 13, 2026

Copy link
Copy Markdown
Contributor

/backport to release/10.0.1xx-sr7

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.1xx-sr7 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@kubaflo backporting to release/10.0.1xx-sr7 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix: ContentPage.OnBackButtonPressed not invoked on iOS native back button
Applying: Updated Fix
Using index info to reconstruct a base tree...
M	src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs
Applying: test: add UITest for #9095 - Shell.OnBackButtonPressed invoked via toolbar back button
Using index info to reconstruct a base tree...
M	src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs
A	src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9095.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs
CONFLICT (modify/delete): src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9095.cs deleted in HEAD and modified in test: add UITest for #9095 - Shell.OnBackButtonPressed invoked via toolbar back button.  Version test: add UITest for #9095 - Shell.OnBackButtonPressed invoked via toolbar back button of src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9095.cs left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0003 test: add UITest for #9095 - Shell.OnBackButtonPressed invoked via toolbar back button
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

PureWeen pushed a commit that referenced this pull request May 15, 2026
… for NavigationPage and Shell (#35434)

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

Manual backport of #35072 to `release/10.0.1xx-sr7`.

## Why this is a manual backport

The automated `/backport` workflow ([failed
run](https://github.com/dotnet/maui/actions/runs/25818135030)) hit a
`modify/delete` conflict on
`src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9095.cs`.
The file is added by #35150 (already backported as #35430, currently
OPEN) and modified by #35072. Because #35430 is not yet merged into
`release/10.0.1xx-sr7`, the file does not exist on the target branch and
the patch could not apply cleanly.

## Resolution

Cherry-picked the squashed merge commit
`7023635baac2524ab02f602e56fd7608142984a1` of #35072 onto
`release/10.0.1xx-sr7`. Resolved the conflict by keeping the post-merge
version of `Issue9095.cs` (verified byte-identical to
`inflight/current`, which contains both #35150's added content and
#35072's tweaks).

## ⚠️ Dependency on #35430

This PR's diff currently shows `Issue9095.cs` as a new file because it
includes content originally introduced by #35150. Recommended merge
order:

1. Merge #35430 (Android backport of #35150) first.
2. This PR will then auto-rebase to show only #35072's incremental delta
(a 2-line change to `Issue9095.cs` and the `ShellSectionRenderer.cs` /
`NavigationRenderer.cs` / `Issue8296.cs` changes).

Alternatively, this PR can be merged first, but #35430 will then need a
manual conflict resolution (the file would already exist).

Fixes #8296 in `release/10.0.1xx-sr7`.

---------

Co-authored-by: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PureWeen pushed a commit that referenced this pull request Jun 2, 2026
… Shell (#35072)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

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

### Issue Details:
#8296 - ContentPage.OnBackButtonPressed not invoked on iOS/MacCatalyst
when the native navigation bar back button is tapped inside a
NavigationPage.

#9095 - Shell.OnBackButtonPressed not invoked when the toolbar back
button is tapped on Android and iOS Shell pages

### Root Cause
#8296
- ShouldPopItem in NavigationRenderer.cs (the
navigationBar:shouldPopItem: UIKit delegate callback) fires when the
user taps the native iOS back button.
- Previously it unconditionally set _uiRequestedPop = true and returned
true, allowing the native pop without ever notifying MAUI's page model.
As a result, ContentPage.OnBackButtonPressed was never called on iOS
when the native back button was tapped inside a NavigationPage.

#9095 -  iOS (ShellSectionRenderer.cs)
- Same issue — tracker.Value.Page?.SendBackButtonPressed() skipped the
Shell chain and went directly to the ContentPage.

### Description of change

#8296  **NavigationRenderer.cs**
- In ShouldPopItem, call NavPage?.CurrentPage?.SendBackButtonPressed()
before allowing the native pop. If it returns true (the page
handled/cancelled back navigation), reset _uiRequestedPop and return
false to prevent the native pop.

#9095 **ShellSectionRenderer.cs** (iOS Shell)

- Route through _context.Shell?.SendBackButtonPressed() instead of
tracker.Value.Page?.SendBackButtonPressed(), so the Shell back button
tap goes through the same chain as the system back button.

**Note** on _sendPopPending = false in the BackButtonBehavior command
path: On iOS 26+, _sendPopPending is set to true unconditionally at the
start of SendPop(), before any BackButtonBehavior checks. When a
BackButtonBehavior.Command executes and returns false (preventing
navigation), ViewDidDisappear never fires — so without an explicit
reset, the flag stays true permanently and silently blocks all
subsequent back presses. The _sendPopPending = false after command
execution (line 188) is therefore an intentional and necessary fix to
prevent the back button becoming permanently unresponsive after a
command-handled back press on iOS 26+.

### Test results 
#### Shell — `OnBackButtonPressed` (fixes #9095)

| Platform | Navigation | `OnBackButtonPressed` |
|---|---|---|
| iOS / MacCatalyst | `GoToAsync` | ✅ Triggered |
| Android | `GoToAsync` | ✅ Triggered (app back button and emulator back
button) |
| Windows | `GoToAsync` | ✅ Triggered |

>`OnBackButtonPressed` is triggered for both the `Shell` and the
contained `ContentPage`.


#### NavigationPage — `OnBackButtonPressed` (fixes #8296)

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered (app back button and emulator back
button) | |
| Android | `PushModalAsync` | ✅ Triggered | Called on the modal
ContentPage |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |

> On Android and Windows, `OnBackButtonPressed` is triggered for both
the `NavigationPage` and the contained `ContentPage`.

#### TabbedPage — `OnBackButtonPressed`

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered | |
| Android | `PushModalAsync` | ✅ Triggered | |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |

#### FlyoutPage — `OnBackButtonPressed`

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered | |
| Android | `PushModalAsync` | ✅ Triggered | |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |


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

### Issue Fixes
Fixes #8296 

### Screenshots
|  | Before  | After |
|--|---------|--------|
|8296|  <video
src="https://github.com/user-attachments/assets/13887369-e9e9-42df-a2a0-db88f0e6b38f">
|   <video
src="https://github.com/user-attachments/assets/d0ccfb01-59e8-44bc-8878-54c5d0f6fb7e"> 
|
|9095 |  <video
src="https://github.com/user-attachments/assets/664e0b7f-3964-4a1b-a4f6-46b1db758b48">
|   <video
src="https://github.com/user-attachments/assets/3ff159ec-93b0-4a91-854a-ca23211ff204"> 
|

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PureWeen added a commit that referenced this pull request Jun 11, 2026
…xx-sr8 (#35810)

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

## Cut-then-merge step 2 of 2

SR8 was cut from `main` at
[`e02d6b6dc2`](e02d6b6)
(commit "Add gh-aw rerun review scanner (#35685)"). This PR pulls the
SR7 stabilization work into SR8 so SR8 contains everything that's in
SR7.

- **Base:** `release/10.0.1xx-sr8` @
[`e02d6b6dc2`](e02d6b6)
- **Merging in:** `release/10.0.1xx-sr7` @
[`9da598b4a1`](9da598b)
(PatchVersion bump to 71)
- **Merge base:**
[`f8cb875e`](f8cb875eee)
("[Testing] The Windows WebView category is removed from CI…" #35335)
- **Strategy:** non-fast-forward merge commit (preserves both branches'
history)

## Conflict resolution

Two trivial conflicts, both resolved by taking the SR8 (`HEAD`) side:

| File | Why it conflicted | Resolution |
| --- | --- | --- |
|
[`eng/Versions.props`](https://github.com/dotnet/maui/blob/release/10.0.1xx-sr8/eng/Versions.props)
| SR7 bumped `PatchVersion` 70→71 (#35786); SR8 starts at 80 | Keep
`PatchVersion=80` (SR8 is the higher patch band) |
|
`src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs`
| Whitespace-only difference (`false; //` vs `false; //`) in two
comments | Keep SR8's whitespace |

No semantic conflicts.

## Inherited from SR7

26 SR7-only commits land in SR8 via this merge. The source PRs are:

<details>
<summary>Source PRs (43, deduped by commit)</summary>

#35020, #35072, #35092, #35150, #35223, #35299, #35305, #35347, #35356,
#35359, #35360, #35421, #35423, #35424, #35425, #35426, #35427, #35428,
#35430, #35434, #35441, #35447, #35461, #35480, #35503, #35520, #35521,
#35559, #35566, #35585, #35625, #35642, #35664, #35689, #35690, #35691,
#35692, #35693, #35694, #35703, #35744, #35768, #35786

Includes the SR7 revert chain:
- #35689 — Revert PR #30068 (FontImageSource centering on Windows)
- #35694 — Revert TalkBack RadioButton fix
- #35703 — Revert Shell.NavBarIsVisible fix
- #35744 — Revert HybridWebView WebView fix
- #35461, #35503 — additional Android reverts
</details>

After this lands, the release-readiness tracker can survey
`release/10.0.1xx-sr8` directly instead of using `-Candidate
-InheritFromPriorSr` mode against SR7.
PureWeen pushed a commit that referenced this pull request Jun 11, 2026
… Shell (#35072)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

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

### Issue Details:
#8296 - ContentPage.OnBackButtonPressed not invoked on iOS/MacCatalyst
when the native navigation bar back button is tapped inside a
NavigationPage.

#9095 - Shell.OnBackButtonPressed not invoked when the toolbar back
button is tapped on Android and iOS Shell pages

### Root Cause
#8296
- ShouldPopItem in NavigationRenderer.cs (the
navigationBar:shouldPopItem: UIKit delegate callback) fires when the
user taps the native iOS back button.
- Previously it unconditionally set _uiRequestedPop = true and returned
true, allowing the native pop without ever notifying MAUI's page model.
As a result, ContentPage.OnBackButtonPressed was never called on iOS
when the native back button was tapped inside a NavigationPage.

#9095 -  iOS (ShellSectionRenderer.cs)
- Same issue — tracker.Value.Page?.SendBackButtonPressed() skipped the
Shell chain and went directly to the ContentPage.

### Description of change

#8296  **NavigationRenderer.cs**
- In ShouldPopItem, call NavPage?.CurrentPage?.SendBackButtonPressed()
before allowing the native pop. If it returns true (the page
handled/cancelled back navigation), reset _uiRequestedPop and return
false to prevent the native pop.

#9095 **ShellSectionRenderer.cs** (iOS Shell)

- Route through _context.Shell?.SendBackButtonPressed() instead of
tracker.Value.Page?.SendBackButtonPressed(), so the Shell back button
tap goes through the same chain as the system back button.

**Note** on _sendPopPending = false in the BackButtonBehavior command
path: On iOS 26+, _sendPopPending is set to true unconditionally at the
start of SendPop(), before any BackButtonBehavior checks. When a
BackButtonBehavior.Command executes and returns false (preventing
navigation), ViewDidDisappear never fires — so without an explicit
reset, the flag stays true permanently and silently blocks all
subsequent back presses. The _sendPopPending = false after command
execution (line 188) is therefore an intentional and necessary fix to
prevent the back button becoming permanently unresponsive after a
command-handled back press on iOS 26+.

### Test results 
#### Shell — `OnBackButtonPressed` (fixes #9095)

| Platform | Navigation | `OnBackButtonPressed` |
|---|---|---|
| iOS / MacCatalyst | `GoToAsync` | ✅ Triggered |
| Android | `GoToAsync` | ✅ Triggered (app back button and emulator back
button) |
| Windows | `GoToAsync` | ✅ Triggered |

>`OnBackButtonPressed` is triggered for both the `Shell` and the
contained `ContentPage`.


#### NavigationPage — `OnBackButtonPressed` (fixes #8296)

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered (app back button and emulator back
button) | |
| Android | `PushModalAsync` | ✅ Triggered | Called on the modal
ContentPage |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |

> On Android and Windows, `OnBackButtonPressed` is triggered for both
the `NavigationPage` and the contained `ContentPage`.

#### TabbedPage — `OnBackButtonPressed`

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered | |
| Android | `PushModalAsync` | ✅ Triggered | |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |

#### FlyoutPage — `OnBackButtonPressed`

| Platform | Navigation | `OnBackButtonPressed` | Notes |
|---|---|---|---|
| iOS / MacCatalyst | `PushAsync` | ✅ Triggered | |
| iOS / MacCatalyst | `PushModalAsync` | — | Back button not visible in
modal navigation |
| Android | `PushAsync` | ✅ Triggered | |
| Android | `PushModalAsync` | ✅ Triggered | |
| Windows | `PushAsync` | ✅ Triggered | |
| Windows | `PushModalAsync` | — | Back button not visible in modal
navigation |


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

### Issue Fixes
Fixes #8296 

### Screenshots
|  | Before  | After |
|--|---------|--------|
|8296|  <video
src="https://github.com/user-attachments/assets/13887369-e9e9-42df-a2a0-db88f0e6b38f">
|   <video
src="https://github.com/user-attachments/assets/d0ccfb01-59e8-44bc-8878-54c5d0f6fb7e"> 
|
|9095 |  <video
src="https://github.com/user-attachments/assets/664e0b7f-3964-4a1b-a4f6-46b1db758b48">
|   <video
src="https://github.com/user-attachments/assets/3ff159ec-93b0-4a91-854a-ca23211ff204"> 
|

---------

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

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout area-navigation NavigationPage community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-implemented PR author implemented the agent suggested fix 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ContentPage's OnBackButtonPressed not invoked on iOS and MacCatalyst On Screen Back Button Does Not Fire OnBackButtonPressed in Android

7 participants