Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

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!

Description of Change

Fixed a regression in .NET 10 RC2 where the keyboard overlaps Entry controls when developers set SoftInput.AdjustResize in MainActivity, breaking the standard Android resize behavior that worked in .NET 9.

Root Cause: WindowCompat.SetDecorFitsSystemWindows(Window, false) in MauiAppCompatActivity disabled automatic window resizing. The inset handler only applied keyboard padding when SafeAreaRegions.SoftInput was explicitly set, ignoring the window's SoftInputMode.

Changes Made:

  1. SafeAreaExtensions.cs - Enhanced to detect window's SoftInputMode and apply keyboard insets when AdjustResize is set, regardless of SafeAreaRegions settings

    • Apply keyboard insets to all container types (drawer layouts, coordinator layouts, etc.) when AdjustResize is set
    • Replaced magic numbers (0, 1, 2, 3) with named constants (EdgeLeft, EdgeTop, EdgeRight, EdgeBottom) for better code readability
    • Refactored duplicated inset consumption logic in ApplyAdjustedSafeAreaInsetsPx
    • Fixed GetSafeAreaForEdge to return 0 for SoftInput-only regions when keyboard is hidden
    • Ensured keyboard-related padding only applies when keyboard is actually visible
  2. UI Tests - Added comprehensive test coverage:

    • Issue32041.xaml/.cs: Tests AdjustResize mode - verifies keyboard insets ARE applied when keyboard shows
    • Issue32041AdjustPan.xaml/.cs: Tests AdjustPan mode - verifies keyboard insets are NOT applied (Android handles panning)
  3. Cross-platform build fixes - Wrapped using Android.Views; with #if ANDROID in 14 test files to fix build errors on iOS, Windows, and MacCatalyst

Key Behavior:

  • When SoftInput.AdjustResize is set: Keyboard insets are applied to push content up, avoiding overlap
  • When SoftInput.AdjustPan is set: No insets applied (Android natively pans the window)
  • When SafeAreaEdges=SoftInput only and keyboard is hidden: Returns 0 padding (no unnecessary safe area insets)

All existing unit tests pass (45/45 SafeArea tests).

Issues Fixed

Fixes #32041

Original prompt

This section details on the original issue you should resolve

<issue_title>net 10 rc2 keyboard overlap android</issue_title>
<issue_description>### Description

if you have an entry at the bottom of the screen , the keyboards ovelarps it and you cannot see anything, as you can imagine we have applications where a user is asked to input lots of data and all the entries are overlapped!

Steps to Reproduce

  1. Create a page in maui .net 10 rc2
  2. Place an entry at the bottom of the screen
  3. Start typing.. and the keyboard will overlap the entry
  4. Add below to MainActivity
  5. I have attached both repo - net 9 and 10
protected override void OnCreate(Bundle? savedInstanceState)
       {
           base.OnCreate(savedInstanceState);
           Window?.SetSoftInputMode(SoftInput.AdjustResize | SoftInput.StateUnspecified);

       }
  1. Works in .net 9 but not in .net 10See below net 9 on the left and .net 10 RC2 on the right!

Image

MauiAppNe10Overlap.zip
MauiNet9Overlap.zip

Link to public reproduction project repository

No response

Version with bug

10.0.0-rc.2

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.111 SR11.1

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

none

Relevant log output

```</issue_description>

<agent_instructions>If the user has set the Android Window's SoftInput mode to AdjustResize then we should inset the top level view on the android app if the softinput is open . I'm not sure the best fix here, what we might do is set the inset listener on the container view at the top level and then pad that if the softinput is open and they've set the window to adjust resize, or we add the inset listener to the DecorView. Not sure, need to test out a few scenarios</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@jsuarezruiz</author><body>
@NirmalKumarYuvaraj I have seen Shane assigned you to review it. My thoughts:
- I think the regression comes from https://github.com/dotnet/maui/pull/31798/files
- The issue occurs because `WindowCompat.SetDecorFitsSystemWindows(Window, false)` was being called in `MauiAppCompatActivity.OnCreate()`. When set to false, this tells Android that the app will handle all window insets manually, which disables the default `SoftInput.AdjustResize` behavior.</body></comment_new>
<comment_new><author>@PureWeen</author><body>
@TedMobile as a workaround

I think you can set SafeAreaEdges on your ContentPages to "Container" and that should fix for now</body></comment_new>
<comment_new><author>@NirmalKumarYuvaraj</author><body>
@TedMobile , You can set SafeAreaEdges on your ContentPages to "All". This will fix the issue, I have attached a video reference.

https://github.com/user-attachments/assets/6d11a017-0c30-46d8-bccf-d9188329e00f

</body></comment_new>
<comment_new><author>@PureWeen</author><body>
> [@NirmalKumarYuvaraj](https://github.com/NirmalKumarYuvaraj) [@PureWeen](https://github.com/PureWeen) well, Adding SafeAreasEdges.All I have noticed that creates an overlap in iOS on many of my screens but fixes android.

do you have a repro on iOS by chance?</body></comment_new>
</comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix keyboard overlap issue in .NET 10 RC2 Fix keyboard overlap on Android when SoftInput.AdjustResize is set Nov 5, 2025
Copilot AI requested a review from PureWeen November 5, 2025 15:30
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.


[Test]
[Category(UITestCategories.SafeAreaEdges)]
public void VerifyKeyboardDoesNotOverlapEntryWithAdjustResize()
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test for AdjustPan Mode. Current test validates AdjustResize; adding a pan-mode assertion ensures no regressions where pan doesn't apply insets incorrectly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added AdjustPan test in commit ff901a2. The new test verifies that when SoftInput.AdjustPan is set, no keyboard insets are applied (the window pans instead).

@NirmalKumarYuvaraj
Copy link
Contributor

@copilot , Add a test for AdjustPan Mode. Current test validates AdjustResize; adding a pan-mode assertion ensures no regressions where pan doesn't apply insets incorrectly.

Copy link
Contributor Author

Copilot AI commented Nov 6, 2025

@copilot , Add a test for AdjustPan Mode. Current test validates AdjustResize; adding a pan-mode assertion ensures no regressions where pan doesn't apply insets incorrectly.

Added AdjustPan test in commit ff901a2. Created Issue32041AdjustPan test page and test case that verifies no insets are applied when AdjustPan mode is set.

@github-actions github-actions bot force-pushed the copilot/improve-copilot-agent-strategies branch from c036163 to c004621 Compare November 6, 2025 22:22
Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

@copilot Fix current conflict.

Copy link
Contributor Author

Copilot AI commented Nov 7, 2025

@copilot Fix current conflict.

Merged main into branch in commit e93315f. The merge completed successfully with no conflicts.

Copilot AI requested a review from jsuarezruiz November 7, 2025 08:07
Base automatically changed from copilot/improve-copilot-agent-strategies to main November 7, 2025 20:00
@PureWeen
Copy link
Member

PureWeen commented Nov 8, 2025

/rebase

@PureWeen PureWeen added this to the .NET 10.0 SR1 milestone Nov 8, 2025
@PureWeen PureWeen added the p/0 Current heighest priority issues that we are targeting for a release. label Nov 8, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Nov 8, 2025
@PureWeen PureWeen force-pushed the copilot/fix-keyboard-overlap-issue branch from e93315f to 756a5f5 Compare November 9, 2025 00:09
@PureWeen
Copy link
Member

PureWeen commented Nov 9, 2025

@copilot i have rebased this pr

can you asses if your changes on this pr still seem correct?

@github-actions github-actions bot force-pushed the copilot/fix-keyboard-overlap-issue branch from 17fda3d to 6673467 Compare December 11, 2025 01:37
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.

based on our chats

  1. we need to fix adjustresize here so it works at the root level of the view, not just on the layouts inside the page. For example, if a page has bottom tabs those tabs should also resize up

  2. I do still think there's a bug here to fix around the timing of the keyboad though because I think this issue will still happen if you were to set the layout itself to SafeAreaEdges.All

Can you create a new PR for a different implementation of AdjustResize to cover the first point and then lets keep working on this one to fix the timing. I still think there's a possible solution here that doesn't involve the magic 500px number check

Copilot AI requested a review from PureWeen December 12, 2025 14:51
Copilot AI added a commit that referenced this pull request Dec 12, 2025
@PureWeen PureWeen modified the milestones: .NET 10.0 SR2, .NET 10.0 SR3 Dec 13, 2025
@PureWeen
Copy link
Member

#33145

@PureWeen PureWeen closed this Dec 24, 2025
@github-project-automation github-project-automation bot moved this from Changes Requested to Done in MAUI SDK Ongoing Dec 24, 2025
@IeuanWalker
Copy link

  1. I do still think there's a bug here to fix around the timing of the keyboad though because I think this issue will still happen if you were to set the layout itself to SafeAreaEdges.All

@PureWeen there is also a timing issue on iOS - #25185

PureWeen pushed a commit that referenced this pull request Dec 29, 2025
Co-authored-by: PureWeen <[email protected]>

# Conflicts:
#	.gitignore
NirmalKumarYuvaraj pushed a commit that referenced this pull request Dec 30, 2025
Co-authored-by: PureWeen <[email protected]>

# Conflicts:
#	.gitignore
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

p/0 Current heighest priority issues that we are targeting for a release.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

net 10 rc2 keyboard overlap android

7 participants