Skip to content

Commit a1d2571

Browse files
authored
[iOS] ScrollView content offset RTL - fix (#30724)
* Fix Issue29458 and improve test * Update Issue29458.cs
1 parent 9509f44 commit a1d2571

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29458.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using NUnit.Framework;
1+
#if ANDROID || IOS
2+
using NUnit.Framework;
23
using UITest.Appium;
34
using UITest.Core;
45

@@ -22,7 +23,8 @@ public void ScrollViewShouldWorkInRTL()
2223
App.ScrollLeft("RTLScrollView");
2324
App.ScrollRight("LTRScrollView");
2425
}
25-
App.WaitForElement("Tab5RTL");
26-
App.WaitForElement("Tab5LTR");
26+
Assert.That(App.FindElement("Tab5LTR").GetRect().X, Is.LessThan(App.FindElement("RTLScrollView").GetRect().Width * 1.2f));
27+
Assert.That(App.FindElement("Tab5RTL").GetRect().X, Is.GreaterThan(-50f));
2728
}
28-
}
29+
}
30+
#endif

src/Core/src/Platform/iOS/MauiScrollView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public override void LayoutSubviews()
5656
// For Right-To-Left (RTL) layouts, we need to adjust the content arrangement and offset
5757
// to ensure the content is correctly aligned and scrolled. This involves a second layout
5858
// arrangement with an adjusted starting point and recalculating the content offset.
59-
if (_previousEffectiveUserInterfaceLayoutDirection is not null && _previousEffectiveUserInterfaceLayoutDirection != EffectiveUserInterfaceLayoutDirection)
59+
if (_previousEffectiveUserInterfaceLayoutDirection != EffectiveUserInterfaceLayoutDirection)
6060
{
6161
// In mac platform, Scrollbar is not updated based on FlowDirection, so resetting the scroll indicators
6262
// It's a native limitation; to maintain platform consistency, a hack fix is applied to show the Scrollbar based on the FlowDirection.
@@ -78,7 +78,7 @@ public override void LayoutSubviews()
7878
crossPlatformLayout.CrossPlatformArrange(new Rect(new Point(-horizontalOffset, 0), crossPlatformBounds));
7979
ContentOffset = new CGPoint(horizontalOffset, 0);
8080
}
81-
else
81+
else if(_previousEffectiveUserInterfaceLayoutDirection is not null)
8282
{
8383
ContentOffset = new CGPoint(0, ContentOffset.Y);
8484
}

0 commit comments

Comments
 (0)