Skip to content

Conversation

@Tamilarasan-Paranthaman
Copy link
Contributor

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman commented Aug 26, 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

This PR modifies the SafeArea logic to better handle scenarios involving the soft keyboard.

1. #31191

  • Updated the logic to calculate how much of the InputView is covered by the keyboard and adjust the SafeArea accordingly, ensuring the view is brought above the keyboard. Additionally, added a check to prevent double insets when SafeAreaEdges="SoftInput" is applied to both a parent and child. The logic now verifies whether the parent already handles the inset, and applies it only once

Screenshots

Before Fix After Fix
Before-Fix.mov
After-Fix.mov

Issues Fixed

Fixes #31191

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Aug 26, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis jfversluis added this to the .NET 10.0-rc2 milestone Sep 2, 2025
@jfversluis jfversluis requested a review from PureWeen September 2, 2025 08:37
@PureWeen
Copy link
Member

PureWeen commented Sep 9, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review September 9, 2025 13:29
Copilot AI review requested due to automatic review settings September 9, 2025 13:29
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman requested a review from a team as a code owner September 9, 2025 13:29
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 SafeArea keyboard handling on iOS to better manage soft input behavior and prevent conflicts between keyboard auto-scroll and SafeAreaEdges.SoftInput settings.

Key changes:

  • Improved SafeArea calculation to account for input view overlap with keyboard
  • Restricted keyboard auto-scroll to only occur when InputView is inside a ScrollView
  • Updated test cases to wrap input controls in ScrollViews for proper testing

Reviewed Changes

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

Show a summary per file
File Description
src/Core/src/Platform/iOS/MauiView.cs Enhanced SafeArea logic with overlap calculation and parent check to prevent double insets
src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs Added parent SafeAreaView2 check to restrict auto-scroll behavior
src/Controls/tests/TestCases.HostApp/Issues/Issue24977.cs Wrapped Entry and Editor controls in ScrollViews for proper keyboard testing
src/Controls/tests/TestCases.HostApp/Issues/Issue19214_2.xaml Added ScrollView wrappers around input controls
Multiple keyboard test pages Updated test UI to wrap input controls in ScrollViews

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman force-pushed the Safe-Area-SoftInput-Auto-Scroll branch from 10dcf62 to 68c11d3 Compare September 11, 2025 05:52
// Bottom edge is most commonly affected by keyboard
var bottomEdgeRegion = safeAreaPage.GetSafeAreaRegionsForEdge(3); // 3 = bottom edge
if (SafeAreaEdges.IsSoftInput(bottomEdgeRegion))
if (SafeAreaEdges.IsSoftInput(bottomEdgeRegion)
Copy link
Contributor

Choose a reason for hiding this comment

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

This parent check logic is repeated in: KeyboardAutoManagerScroll.cs

Could you extract it to a method and reuse it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz yes, I extracted a new method and reused it.

var inputBottomY = 0.0;
if (Window is not null)
{
var viewFrameInWindow = this.Superview?.ConvertRectToView(this.Frame, Window) ?? this.Frame;
Copy link
Contributor

Choose a reason for hiding this comment

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

viewFrameInWindow could be null, can include a validation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz, in this case, viewFrameInWindow can’t be null because if the Superview is null, it falls back to this.Frame, which is always a valid rectangle. So, a null check is not required here, correct?. Please let me know if I have overlooked any scenarios or if you have further thoughts.

{
if (View.FindParent(x => x is MauiView mv
&& mv.View is ISafeAreaView2 safeAreaView2
&& SafeAreaEdges.IsSoftInput(safeAreaView2.GetSafeAreaRegionsForEdge(3))) is not null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can include a comment explaining the parameter 3.

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 comments in the new method

@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

/azp run MAUI-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen merged commit 9de1561 into dotnet:net10.0 Sep 18, 2025
151 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants