Skip to content

Conversation

@jsuarezruiz
Copy link
Contributor

Description of Change

When setting SafeAreaEdges to Container on all sides and SoftInput on bottom, the padding calculation is incorrect when the keyboard appears and causes the window to pan.

The code performs position-based overlap calculations by checking if the view extends into safe area regions. However, when the window is in AdjustPan mode:

  • Android shifts the entire window upward when keyboard appears
  • View's GetLocationOnScreen returns negative Y coordinates (view pushed above visible screen) and then condition viewTop >= 0 at line 114 fails, causing top padding to be set to 0
  • For that, the content overlaps with system bars/notch despite Container being configured

Modified SafeAreaExtensions.cs to detect AdjustPan mode and skip unreliable position-based calculations. Detect if window is in AdjustPan mode when keyboard shows. When in AdjustPan mode with keyboard showing, bypass position-based overlap logic.

Issues Fixed

Fixes #31871

Copilot AI review requested due to automatic review settings October 15, 2025 10:29
@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/android area-keyboard Keyboard, soft keyboard labels Oct 15, 2025
Copy link
Contributor

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 a bug in Android SafeArea padding calculation when using Container SafeAreaEdges with SoftInput on the bottom edge in AdjustPan window mode. When the keyboard appears and causes the window to pan, the existing position-based overlap calculations fail because view coordinates become unreliable (negative Y values), incorrectly removing top padding and causing content to overlap with system UI.

Key changes:

  • Added detection for AdjustPan mode when keyboard is showing
  • Skip position-based overlap calculations in AdjustPan mode to prevent incorrect padding removal
  • Added comprehensive UI test to validate the fix

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Core/src/Platform/Android/SafeAreaExtensions.cs Core fix: detects AdjustPan mode and bypasses unreliable position calculations
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28986.cs Adds UI test to validate Container+SoftInput behavior with keyboard
Comments suppressed due to low confidence (1)

src/Core/src/Platform/Android/SafeAreaExtensions.cs:1

  • Removed unused import Google.Android.Material.AppBar which is good for maintainability, but verify that this import isn't used elsewhere in the file that wasn't shown in the diff.
using System;

@dotnet dotnet deleted a comment from azure-pipelines bot Oct 16, 2025
@PureWeen PureWeen added this to the .NET 10.0 GA milestone Oct 16, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Oct 16, 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.

this one isn't working for me

I'm running 28986 and it's not resizing

Image

@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Oct 17, 2025
@rmarinho rmarinho modified the milestones: .NET 10.0 GA, .NET 10 SR1 Oct 25, 2025
@PureWeen PureWeen changed the base branch from net10.0 to main October 29, 2025 12:02
@PureWeen
Copy link
Member

/rebase

@NirmalKumarYuvaraj
Copy link
Contributor

this one isn't working for me

I'm running 28986 and it's not resizing

Image

@PureWeen , #32146 - Check with this PR changes once.

// and there isn't a bottom inset to apply then just don't touch anything
var softInputMode = attr.SoftInputMode;
if (softInputMode == SoftInput.AdjustPan
&& bottom == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

@jsuarezruiz , Is the bottom == 0 check actually needed?
Consider this scenario: the user sets the SoftInputMode to Pan, deploys the host app, and navigates to Issue28986_ContentPage.xaml. By default, the content page’s SafeAreaEdges property is set to All.
Now, click the Entry control. Notice that the window gets resized.

This happens because when the content page’s SafeAreaEdges is set to All, or when the bottom edge is configured for the SoftInput, the ApplyAdjustedSafeAreaInsetsPx() method processes the visual tree. Initially, the ContentPage is processed, and the bottom value is not 0—it’s 883 (the keyboard inset value). As a result, the condition softInputMode == SoftInput.AdjustPan && bottom == 0 fails, and instead of panning, the window gets resized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-keyboard Keyboard, soft keyboard platform/android t/bug Something isn't working

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

[Android] Setting layout to container and SoftInput on bottom causes padding to not calculate quite right

5 participants