Skip to content

[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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jun 18, 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 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

Screenshot 2025-06-18 at 16 41 33

#29458 (comment)

Before After
Screen.Recording.2025-06-18.at.16.34.17.mov
Screen.Recording.2025-06-18.at.16.33.26.mov

@Copilot Copilot AI review requested due to automatic review settings June 18, 2025 14:47
@kubaflo kubaflo requested a review from a team as a code owner June 18, 2025 14:47
@kubaflo kubaflo requested review from jfversluis and rmarinho June 18, 2025 14:47
@kubaflo kubaflo self-assigned this Jun 18, 2025
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 18, 2025
@kubaflo kubaflo added area-controls-scrollview ScrollView and removed community ✨ Community Contribution labels Jun 18, 2025
Copy link
Contributor

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.

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 18, 2025
Copy link
Contributor

@Copilot 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 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 ContentOffset to 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.Tests and TestCases.HostApp to verify that ContentOffset is reset when switching the FlowDirection, ensuring this behavior is covered by automated tests.
						ContentOffset = new CGPoint(0, 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant