Fix keyboard overlap on Android when SoftInput.AdjustResize is set#32405
Fix keyboard overlap on Android when SoftInput.AdjustResize is set#32405
Conversation
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
|
|
||
| [Test] | ||
| [Category(UITestCategories.SafeAreaEdges)] | ||
| public void VerifyKeyboardDoesNotOverlapEntryWithAdjustResize() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
|
@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. |
c036163 to
c004621
Compare
jsuarezruiz
left a comment
There was a problem hiding this comment.
@copilot Fix current conflict.
|
/rebase |
e93315f to
756a5f5
Compare
|
@copilot i have rebased this pr can you asses if your changes on this pr still seem correct? |
- Wrapped 'using Android.Views;' with #if ANDROID in Issue28986_FlyoutPage.cs - Wrapped 'using Android.Views;' with #if ANDROID in Issue28986_NavigationPage.cs - Wrapped 'using Android.Views;' with #if ANDROID in Issue28986_Shell.cs - Fixes cross-platform build errors where Android.Views is not available on iOS, Windows, and MacCatalyst Co-authored-by: NirmalKumarYuvaraj <97871636+NirmalKumarYuvaraj@users.noreply.github.com>
…d padding behavior - Removed duplicated AdjustPan check in ApplyAdjustedSafeAreaInsetsPx (lines 117-132) - Removed duplicated keyboard inset logic in GetSafeAreaForEdge (lines 313-322) - Ensured keyboard padding only applies when keyboard is actually showing - Fixed indentation and formatting issues - All existing SafeArea unit tests pass (45/45) Co-authored-by: NirmalKumarYuvaraj <97871636+NirmalKumarYuvaraj@users.noreply.github.com>
… is only SoftInput - Moved SafeAreaRegions.None check to the top of the method - Added check for when keyboard is NOT showing and SafeAreaEdges is ONLY SoftInput to return 0 - Ensures that when keyboard is hidden, views with SafeAreaEdges=SoftInput don't get unnecessary padding - All existing SafeArea unit tests pass (45/45) Co-authored-by: NirmalKumarYuvaraj <97871636+NirmalKumarYuvaraj@users.noreply.github.com>
- SafeAreaExtensions: Check AdjustResize BEFORE SafeAreaRegions.None This ensures keyboard insets are applied even when page has no explicit SafeAreaEdges set, fixing the regression where AdjustResize was ignored - Issue32041 test: Measure bottom marker position instead of container height ContentPage's Grid height doesn't change when padding is applied to wrapper, but the bottom marker's Y position correctly reflects the upward movement when keyboard appears. This tests actual user-visible behavior. Fixes the failing VerifyContainerResizesWithAdjustResize test while maintaining compatibility with FlyoutPage, Shell, and TabbedPage tests.
17fda3d to
6673467
Compare
PureWeen
left a comment
There was a problem hiding this comment.
based on our chats
-
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
-
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
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
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.AdjustResizein MainActivity, breaking the standard Android resize behavior that worked in .NET 9.Root Cause:
WindowCompat.SetDecorFitsSystemWindows(Window, false)inMauiAppCompatActivitydisabled automatic window resizing. The inset handler only applied keyboard padding whenSafeAreaRegions.SoftInputwas explicitly set, ignoring the window'sSoftInputMode.Changes Made:
SafeAreaExtensions.cs - Enhanced to detect window's
SoftInputModeand apply keyboard insets whenAdjustResizeis set, regardless ofSafeAreaRegionssettingsAdjustResizeis setApplyAdjustedSafeAreaInsetsPxGetSafeAreaForEdgeto return 0 for SoftInput-only regions when keyboard is hiddenUI Tests - Added comprehensive test coverage:
Cross-platform build fixes - Wrapped
using Android.Views;with#if ANDROIDin 14 test files to fix build errors on iOS, Windows, and MacCatalystKey Behavior:
SoftInput.AdjustResizeis set: Keyboard insets are applied to push content up, avoiding overlapSoftInput.AdjustPanis set: No insets applied (Android natively pans the window)SafeAreaEdges=SoftInputonly 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
💡 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.