Skip to content

[iOS] ScrollView content offset RTL - fix #29469

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

Merged
merged 2 commits into from
May 15, 2025

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented May 13, 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!

Issues Fixed

Fixes #29458

Before After
Screen.Recording.2025-05-13.at.15.46.46.mov
Screen.Recording.2025-05-13.at.15.45.31.mov

@Copilot Copilot AI review requested due to automatic review settings May 13, 2025 13:48
@kubaflo kubaflo requested a review from a team as a code owner May 13, 2025 13:48
@kubaflo kubaflo changed the title [iOS] ScrollView content offset RTL fix [iOS] ScrollView content offset RTL - fix May 13, 2025
@kubaflo kubaflo self-assigned this May 13, 2025
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label May 13, 2025
@kubaflo kubaflo added platform/ios area-controls-scrollview ScrollView community ✨ Community Contribution and removed community ✨ Community Contribution labels May 13, 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 addresses an RTL (right-to-left) scrolling offset issue in iOS by introducing a conditional layout rearrangement when the UI direction is RTL.

  • Added conditional block in LayoutSubviews to adjust content arrangement and offset based on EffectiveUserInterfaceLayoutDirection
  • Sets the content offset to ensure correct scrolling behavior in RTL environments

Comment on lines 56 to 60
crossPlatformLayout.CrossPlatformArrange(new Rect(new Point(crossPlatformBounds.Width - contentSize.Width, 0), crossPlatformBounds));
SetContentOffset(new CGPoint(contentSize.Width - crossPlatformBounds.Width, 0), false);
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the expression 'crossPlatformBounds.Width - contentSize.Width' into a variable to avoid duplication and enhance readability.

Suggested change
crossPlatformLayout.CrossPlatformArrange(new Rect(new Point(crossPlatformBounds.Width - contentSize.Width, 0), crossPlatformBounds));
SetContentOffset(new CGPoint(contentSize.Width - crossPlatformBounds.Width, 0), false);
var horizontalOffset = crossPlatformBounds.Width - contentSize.Width;
crossPlatformLayout.CrossPlatformArrange(new Rect(new Point(horizontalOffset, 0), crossPlatformBounds));
SetContentOffset(new CGPoint(-horizontalOffset, 0), false);

Copilot uses AI. Check for mistakes.

@kubaflo kubaflo force-pushed the fix-29458 branch 2 times, most recently from 5e146c9 to 0a3f75a Compare May 13, 2025 14:02
@PureWeen PureWeen added this to the .NET 9 SR8 milestone May 13, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing May 13, 2025
Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there was a "Asking a question" button, but I have to pick an option or the bots bug me to pick something.

But, it appears the layout for RTL uses the right of the visible area, so a negative left offset will move the content or move the start and show the content?

@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing May 14, 2025
@mattleibow
Copy link
Member

/rebase

@github-project-automation github-project-automation bot moved this from Changes Requested to Approved in MAUI SDK Ongoing May 15, 2025
@mattleibow mattleibow changed the base branch from main to inflight/current May 15, 2025 20:33
@mattleibow mattleibow merged commit 3e1db52 into dotnet:inflight/current May 15, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing May 15, 2025
PureWeen pushed a commit that referenced this pull request May 21, 2025
* [iOS] ScrollView content offset RTL fix

* Added a UITest
PureWeen pushed a commit that referenced this pull request May 21, 2025
* [iOS] ScrollView content offset RTL fix

* Added a UITest
github-actions bot pushed a commit that referenced this pull request May 22, 2025
* [iOS] ScrollView content offset RTL fix

* Added a UITest
github-actions bot pushed a commit that referenced this pull request May 30, 2025
* [iOS] ScrollView content offset RTL fix

* Added a UITest
github-actions bot pushed a commit that referenced this pull request May 30, 2025
* [iOS] ScrollView content offset RTL fix

* Added a UITest
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: Done
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