From a15dc6e109c9d9cb796234fff3322b209218c33f Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Thu, 16 Apr 2026 09:48:45 +0530 Subject: [PATCH 1/2] Fix and test update --- .../Tests/Issues/Issue28986_ContentPage.cs | 31 +++++++++++++++++++ src/Core/src/Platform/iOS/MauiView.cs | 10 ++++++ 2 files changed, 41 insertions(+) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28986_ContentPage.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28986_ContentPage.cs index a893469f5c75..49e23c22f925 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28986_ContentPage.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28986_ContentPage.cs @@ -130,5 +130,36 @@ public void SafeAreaPerEdgeValidation() Assert.That(containerPositionWithoutSoftInput.Height, Is.EqualTo(containerPosition.Height), "ContentGrid height should return to original when Soft Input is dismissed with Container edges"); }); } + + [Test] + [Category(UITestCategories.SafeAreaEdges)] + public void SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle() + { + App.WaitForElement("ContentGrid"); + + App.Tap("GridResetAllButton"); + var baselinePosition = App.WaitForElement("ContentGrid").GetRect(); + + App.Tap("SoftInputTestEntry"); + App.RetryAssert(() => + { + var withKeyboard = App.WaitForElement("ContentGrid").GetRect(); + Assert.That(withKeyboard.Height, Is.LessThan(baselinePosition.Height), + "ContentGrid should shrink when keyboard is showing with SafeAreaEdges=All"); + }); + + App.Tap("GridSetContainerButton"); + App.DismissKeyboard(); + App.Tap("GridResetAllButton"); + + App.RetryAssert(() => + { + var finalPosition = App.WaitForElement("ContentGrid").GetRect(); + Assert.That(finalPosition.Height, Is.EqualTo(baselinePosition.Height).Within(1), + "ContentGrid height should match baseline after toggling edges with keyboard dismiss — no white space (#34846)"); + Assert.That(finalPosition.Y, Is.EqualTo(baselinePosition.Y).Within(1), + "ContentGrid Y should match baseline after toggling edges with keyboard dismiss"); + }); + } } #endif diff --git a/src/Core/src/Platform/iOS/MauiView.cs b/src/Core/src/Platform/iOS/MauiView.cs index addbaed6dac8..0a7a03ecb465 100644 --- a/src/Core/src/Platform/iOS/MauiView.cs +++ b/src/Core/src/Platform/iOS/MauiView.cs @@ -323,6 +323,16 @@ void UnsubscribeFromKeyboardNotifications() NSNotificationCenter.DefaultCenter.RemoveObserver(hideObserver); _keyboardWillHideObserver = null; } + + // Clear stale keyboard state so that re-subscribing later doesn't + // pick up a phantom keyboard frame from a previous session (#34846). + if (_isKeyboardShowing) + { + _isKeyboardShowing = false; + _keyboardFrame = CGRect.Empty; + _safeAreaInvalidated = true; + SetNeedsLayout(); + } } void UpdateKeyboardSubscription() From 6b178bcba0bdf22481898f424757028ba576864f Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Thu, 16 Apr 2026 10:03:06 +0530 Subject: [PATCH 2/2] fix update --- src/Core/src/Platform/iOS/MauiView.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Core/src/Platform/iOS/MauiView.cs b/src/Core/src/Platform/iOS/MauiView.cs index 0a7a03ecb465..abea7f814163 100644 --- a/src/Core/src/Platform/iOS/MauiView.cs +++ b/src/Core/src/Platform/iOS/MauiView.cs @@ -328,10 +328,7 @@ void UnsubscribeFromKeyboardNotifications() // pick up a phantom keyboard frame from a previous session (#34846). if (_isKeyboardShowing) { - _isKeyboardShowing = false; - _keyboardFrame = CGRect.Empty; - _safeAreaInvalidated = true; - SetNeedsLayout(); + ClearKeyboardState(); } } @@ -363,7 +360,9 @@ void OnKeyboardWillShow(NSNotification notification) } } - void OnKeyboardWillHide(NSNotification notification) + void OnKeyboardWillHide(NSNotification notification) => ClearKeyboardState(); + + void ClearKeyboardState() { _safeAreaInvalidated = true; _keyboardFrame = CGRect.Empty;