-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] ScrollView content offset shifts unexpectedly when FlowDirection is changed #30053
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
base: main
Are you sure you want to change the base?
Conversation
|
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
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 an issue where switching the layout direction on iOS could leave stale scroll offsets, causing misaligned content in a ScrollView. It explicitly resets ContentOffset to (0,0) before rearranging and then reapplies the correct horizontal offset for RTL layouts.
- Reset
ContentOffsetto zero before re-arranging content in RTL - Compute and apply the correct horizontal offset after layout
Comments suppressed due to low confidence (1)
src/Core/src/Platform/iOS/MauiScrollView.cs:64
- Consider adding a UI or unit test in
TestCases.Shared.TestsandTestCases.HostAppto verify thatContentOffsetis reset when switching the FlowDirection, ensuring this behavior is covered by automated tests.
ContentOffset = new CGPoint(0, 0);
|
@KishoreJey would you be able to test the resulting NuGets from this PR and see if that resolves it for you? See the instructions all the way at the top |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
e61e9e8 to
45c06ed
Compare
|
/rebase |
45c06ed to
e373acb
Compare
|
/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 addresses an issue where switching the layout direction from Right-to-Left (RTL) to Left-to-Right (LTR) could result in incorrect content positioning due to stale or inconsistent scroll offsets.
To ensure layout consistency, we now explicitly reset the ContentOffset to (0,0) before performing layout adjustments. This prevents any residual offset from affecting the new layout direction.
Issues Fixed
This PR fixes a problem addressed here
#29458 (comment)
Fixes #31322
Screen.Recording.2025-06-18.at.16.34.17.mov
Screen.Recording.2025-06-18.at.16.33.26.mov