Commit e39fe7c
[iOS] Fix for ScrollView SafeAreaEdges="Container" Double Safe-Area Reservation Causing Phantom Scroll Range (#37765)
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
### Issue Description
On iOS, a ScrollView configured with SafeAreaEdges="Container"
incorrectly reserves the safe area twice, resulting in an additional
phantom scroll range. When the content is smaller than the viewport, the
ScrollView becomes unnecessarily scrollable. The extra scrollable area
corresponds exactly to the combined safe-area insets (for example, 82 pt
on an iPhone 11: 48 pt for the status bar and 34 pt for the home
indicator).
When the content is taller than the viewport, the same issue causes an
unnecessary dead over-scroll space at the end of the content.
### Root Cause
The issue occurs because MauiScrollView.CrossPlatformArrange always pads
the scroll content's measured size by the safe-area thickness when
ContentInsetAdjustmentBehavior is not Automatic, without checking
whether UIKit has already reserved the same space through
AdjustedContentInset.
As a result, when SafeAreaEdges="Container" is set and the native inset
is active, the safe area is accounted for twice—once by UIKit and once
by the manual padding. This inflates the content size beyond its actual
bounds and produces a phantom scrollable range, even when the content
should not be scrollable.
### Description of Change
The fix narrows the manual-padding condition so that it applies only
when the native inset is genuinely inactive—that is, when
SystemAdjustedContentInset is zero or ContentInsetAdjustmentBehavior is
Never. In all other cases, UIKit's own inset is trusted to reserve the
safe area, and the content size is left unchanged.
This removes the double reservation for SafeAreaEdges="Container" while
preserving the existing None and Automaticbehaviors.
Tested the behavior in the following platforms.
- [x] iOS
- [x] Android
- [ ] Mac
- [ ] Windows
### Issues Fixed
Fixes #36800
### Output
|Before Fix|After Fix|
|--|--|
<video
src="https://github.com/user-attachments/assets/19c064e4-4622-4d1d-992c-340a56fb948f">
|<video
src="https://github.com/user-attachments/assets/57fa7cae-6e95-4573-885d-8f2979750f38">|
---------
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>1 parent daa4c3c commit e39fe7c
6 files changed
Lines changed: 126 additions & 2 deletions
File tree
- src
- Controls/tests
- TestCases.HostApp/Issues
- Core/src/Platform/iOS
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
| 191 | + | |
190 | 192 | | |
191 | 193 | | |
192 | 194 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
650 | | - | |
| 650 | + | |
651 | 651 | | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
652 | 660 | | |
653 | 661 | | |
654 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
655 | 667 | | |
656 | 668 | | |
657 | 669 | | |
| |||
0 commit comments