-
Couldn't load subscription status.
- Fork 1.9k
[NET10] [iOS] Fix SafeArea does not correctly account for the view area under the soft input #31352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NET10] [iOS] Fix SafeArea does not correctly account for the view area under the soft input #31352
Conversation
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this 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 |
src/Controls/tests/TestCases.HostApp/Elements/KeyboardScrollingEditorsPage.xaml
Outdated
Show resolved
Hide resolved
10dcf62 to
68c11d3
Compare
| // Bottom edge is most commonly affected by keyboard | ||
| var bottomEdgeRegion = safeAreaPage.GetSafeAreaRegionsForEdge(3); // 3 = bottom edge | ||
| if (SafeAreaEdges.IsSoftInput(bottomEdgeRegion)) | ||
| if (SafeAreaEdges.IsSoftInput(bottomEdgeRegion) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run MAUI-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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
Screenshots
Before-Fix.mov
After-Fix.mov
Issues Fixed
Fixes #31191