Skip to content

[release/10.0.1xx-sr7] [iOS] Fix Shell - opened keyboard on modal page shifts parent page/frame behind modal after update to 10.0.60 - #35691

Merged
PureWeen merged 2 commits into
release/10.0.1xx-sr7from
backport/pr-35559-to-release/10.0.1xx-sr7
Jun 2, 2026
Merged

[release/10.0.1xx-sr7] [iOS] Fix Shell - opened keyboard on modal page shifts parent page/frame behind modal after update to 10.0.60#35691
PureWeen merged 2 commits into
release/10.0.1xx-sr7from
backport/pr-35559-to-release/10.0.1xx-sr7

Conversation

@kubaflo

@kubaflo kubaflo commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

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!

Backport of #35559 to release/10.0.1xx-sr7.
/cc @PureWeen

…ame behind modal after update to 10.0.60 (#35559)

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

When the keyboard opens in the modal, the parent page/frame behind the
modal shifts in the shell.

### Root Cause:

PR #33958 added an OnKeyboardWillHide handler to
ShellPageRendererTracker to fix an iOS timing bug where a Shell page
view would land at Y=0 (underneath the navigation bar) when the keyboard
dismissed during a page navigation. The handler worked by detecting this
misposition and correcting the view frame. However, the observer was
registered using UIKeyboard.Notifications.ObserveWillHide — a global
notification that fires for every live ShellPageRendererTracker instance
whenever any keyboard is dismissed, regardless of which page triggered
it.

This becomes a problem when a transparent modal page is presented via
Shell.GoToAsync. In iOS, modal presentation does not push the modal onto
the navigation controller's view controller stack — it sits above the
stack as a separate presented view controller. This means
navController.TopViewController still points to the underlying Shell
page, so the existing guard ViewController ==
navController.TopViewController evaluated to true for the page behind
the modal. With _pendingKeyboardNavigation still armed from the page's
initial load, dismissing the keyboard inside the modal triggered the
frame correction on the underlying page, causing the visible vertical
offset reported in the issue.

Two secondary bugs compounded this: the SearchHandler early-return and
the hidden-nav-bar early-return both exited the method without clearing
_pendingKeyboardNavigation, leaving the flag permanently armed after
those paths — meaning any future keyboard dismissal could incorrectly
fire the frame correction long after the intended one-shot timing window
had passed.

### Description of Change:

The fix adds a single guard at the top of OnKeyboardWillHide: if
navController.PresentedViewController is not null, the method returns
immediately without clearing _pendingKeyboardNavigation. Using
PresentedViewController is the idiomatic UIKit way to detect that a
modal is covering the navigation controller, and returning without
consuming the flag ensures the original page-load correction still works
if a keyboard event fires on this page after the modal is dismissed. The
two secondary leaks are also patched both the hidden-nav-bar path and
the SearchHandler path now explicitly set _pendingKeyboardNavigation =
false before returning, so the flag is always consumed once the
correction window is definitively over.

**Tested the behavior in the following platforms:**

- [x] Android
- [ ] Windows
- [x] iOS
- [ ] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #35401

### Screenshots
| Before  | After  |
|---------|--------|
| <Video
src="https://github.com/user-attachments/assets/a9da8996-3caf-4932-a5ca-a22dc72a302c"
Width="300" Height="600"/> | <Video
src="https://github.com/user-attachments/assets/503ced7d-24de-4410-aaf2-63c684211564"
Width="300" Height="600"/> |

(cherry picked from commit 18b6947)
@github-actions

github-actions Bot commented Jun 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 -- 35691

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35691"
@github-actions github-actions Bot added area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/ios labels Jun 1, 2026
@kubaflo

kubaflo commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).
@vishnumenon2684

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).
This was referenced Jun 29, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 12, 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 platform/ios

5 participants