Skip to content

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)

Fixes #31322

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

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
@dotnet-policy-service
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 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);

@jfversluis
Copy link
Member

@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

@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis jfversluis added this to the .NET 9 SR11 milestone Aug 7, 2025
jfversluis
jfversluis previously approved these changes Aug 7, 2025
@PureWeen PureWeen changed the base branch from main to inflight/current August 7, 2025 21:00
@PureWeen PureWeen changed the base branch from inflight/current to main August 7, 2025 21:06
@PureWeen PureWeen dismissed jfversluis’s stale review August 7, 2025 21:06

The base branch was changed.

@PureWeen
Copy link
Member

PureWeen commented Aug 7, 2025

/rebase

@github-actions github-actions bot force-pushed the ScrollView-content-offset-shifts-unexpectedly-when-FlowDirection-is-set-to-RightToLeft-iOS/MacCatalyst] branch from e61e9e8 to 45c06ed Compare August 7, 2025 21:06
@jfversluis
Copy link
Member

/rebase

@github-actions github-actions bot force-pushed the ScrollView-content-offset-shifts-unexpectedly-when-FlowDirection-is-set-to-RightToLeft-iOS/MacCatalyst] branch from 45c06ed to e373acb Compare August 25, 2025 08:00
@jfversluis
Copy link
Member

/azp run MAUI-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 9 SR11, .NET 10 SR1 Sep 10, 2025
@PureWeen PureWeen modified the milestones: .NET 10 SR1, .NET 10.0 SR2 Nov 4, 2025
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.

ScrollView content offset shifts unexpectedly when FlowDirection is set to RightToLeft [iOS/MacCatalyst]

3 participants