Skip to content

Conversation

jsuarezruiz
Copy link
Contributor

Description of Change

When setting SafeAreaEdges.Bottom = SafeAreaRegions.SoftInput on Android, the bottom edge was incorrectly applying padding from the navigation bar even when the keyboard was not showing. The SoftInput region is designed to only apply padding when the soft keyboard is visible, allowing content to flow under the navigation bar when the keyboard is hidden.

image

In the screenshot above, notice the unwanted padding at the bottom (yellow area) when Bottom:SoftInput is set, even though the keyboard is not visible.

The issue was in the GetSafeAreaForEdge method in SafeAreaExtensions.cs. When the keyboard was hidden, the condition isKeyboardShowing && edge == 3 evaluated to false, causing the code to skip the SoftInput handling entirely and fall through to return originalSafeArea, which returns the navigation bar padding (~48-80px) for all regions including SoftInput.

This PR add changes to the logic to check the edge first, then check if the region is SoftInput, and only then check the keyboard state.

Added a new UITest:

  • Setting bottom edge to None as baseline
  • Setting bottom edge to SoftInput (keyboard hidden)
  • Verifying MainGrid height remains the same (no bottom padding)
image

The expected behavior would be:

Scenario Before After
SoftInput + Keyboard Hidden ❌ Navigation bar padding (~48-80px) ✅ No padding (0px)
SoftInput + Keyboard Showing ✅ Keyboard height padding ✅ Keyboard height padding
Container + Keyboard Hidden ✅ Navigation bar padding ✅ Navigation bar padding
Container + Keyboard Showing ✅ No padding ✅ No padding

Issues Fixed

Fixes #31870

@Copilot Copilot AI review requested due to automatic review settings October 9, 2025 11:27
@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/android labels Oct 9, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an Android-specific bug where SafeAreaEdges.SoftInput was incorrectly applying bottom padding from the navigation bar when the keyboard was hidden. The SoftInput region should only apply padding when the soft keyboard is visible, allowing content to flow under the navigation bar otherwise.

  • Refactored the conditional logic in GetSafeAreaForEdge to properly handle SoftInput region by checking edge first, then region type, then keyboard state
  • Added comprehensive UI test to verify SoftInput behavior when keyboard is hidden
  • Ensures SoftInput only applies keyboard height padding when keyboard is showing, otherwise returns 0

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Core/src/Platform/Android/SafeAreaExtensions.cs Fixed logic flow in GetSafeAreaForEdge to properly handle SoftInput region behavior
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28986.cs Added UI test to validate SoftInput doesn't apply bottom padding when keyboard is hidden

@PureWeen PureWeen added this to the .NET 10.0 GA milestone Oct 9, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Oct 9, 2025
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

@jsuarezruiz do we need to also account for these changes on ios?

@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/android t/bug Something isn't working

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

2 participants