Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,41 @@ public Issue28986(TestDevice device) : base(device)
{
}

#if ANDROID
[Test]
[Category(UITestCategories.SafeAreaEdges)]
public void SoftInputDoesNotApplyBottomPaddingWhenKeyboardHidden()
{
// This test validates the fix for issue #31870
// When SafeAreaEdges.Bottom is set to SoftInput and the keyboard is NOT showing,
// there should be NO bottom padding from the navigation bar.
App.WaitForElement("ContentGrid");

// First, set to None to get the baseline position (no safe area padding)
App.Tap("GridResetNoneButton");
var noneRect = App.WaitForElement("MainGrid").GetRect();

// Now set bottom edge to SoftInput (keyboard is still hidden)
App.Tap("GridSetBottomSoftInputButton");

// Wait for layout to update
App.WaitForElement("MainGrid");

// Get the current settings to verify SoftInput is set
var currentSettings = App.FindElement("CurrentSettings").GetText();
Assert.That(currentSettings, Does.Contain("Bottom:SoftInput"),
"Bottom edge should be set to SoftInput");

// Get the rect after setting SoftInput
var softInputRect = App.WaitForElement("MainGrid").GetRect();

// Verify that the bottom position is the same as None (no padding applied)
// The height should be the same because SoftInput should not add padding when keyboard is hidden
Assert.That(softInputRect.Height, Is.EqualTo(noneRect.Height).Within(5),
"MainGrid height should be the same with SoftInput as with None when keyboard is hidden (no bottom padding)");
}
#endif

[Test]
[Category(UITestCategories.SafeAreaEdges)]
public void SafeAreaMainGridBasicFunctionality()
Expand Down
20 changes: 13 additions & 7 deletions src/Core/src/Platform/Android/SafeAreaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,20 @@ internal static double GetSafeAreaForEdge(SafeAreaRegions safeAreaRegion, double
}

// Handle SoftInput specifically - only apply keyboard insets for bottom edge when keyboard is showing
if (isKeyboardShowing && edge == 3)
if (edge == 3)
{
if (SafeAreaEdges.IsSoftInput(safeAreaRegion))
return keyBoardInsets.Bottom;

// if they keyboard is showing then we will just return 0 for the bottom inset
// because that part of the view is covered by the keyboard so we don't want to pad the view
return 0;
if (SafeAreaEdges.IsSoftInput(safeAreaRegion))
{
// SoftInput only applies padding when keyboard is showing
return isKeyboardShowing ? keyBoardInsets.Bottom : 0;
}

if (isKeyboardShowing)
{
// if the keyboard is showing then we will just return 0 for the bottom inset
// because that part of the view is covered by the keyboard so we don't want to pad the view
return 0;
}
}

// All other regions respect safe area in some form
Expand Down
Loading