diff --git a/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs b/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs index 3856fc89ac52..1f716b58f0c1 100644 --- a/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs +++ b/src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs @@ -337,7 +337,7 @@ public static UICollectionViewLayout CreateCarouselLayout( return; } - var page = (offset.X + sectionMargin) / env.Container.ContentSize.Width; + var page = (offset.X + sectionMargin) / (env.Container.ContentSize.Width - sectionMargin * 2); if (Math.Abs(page % 1) > (double.Epsilon * 100) || cv2Controller.ItemsSource.ItemCount <= 0) { diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue28524.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue28524.xaml new file mode 100644 index 000000000000..364efea4a6e5 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue28524.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + Baboon + Capuchin Monkey + Blue Monkey + + + + + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue28524.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue28524.xaml.cs new file mode 100644 index 000000000000..d3f80d7d0591 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue28524.xaml.cs @@ -0,0 +1,10 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 28524, "[iOS] CurrentItem does not work when PeekAreaInsets is set", PlatformAffected.iOS)] +public partial class Issue28524 : ContentPage +{ + public Issue28524() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28524.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28524.cs new file mode 100644 index 000000000000..393ed703fc20 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28524.cs @@ -0,0 +1,24 @@ +#if ANDROID || IOS +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue28524 : _IssuesUITest +{ + public Issue28524(TestDevice device) : base(device) { } + + public override string Issue => "[iOS] CurrentItem does not work when PeekAreaInsets is set"; + + [Test] + [Category(UITestCategories.CarouselView)] + public void CurrentItemShouldWork() + { + App.WaitForElement("CarouselView"); + App.ScrollRight("CarouselView"); + App.ScrollRight("CarouselView"); + App.WaitForElement("Blue Monkey"); + } +} +#endif \ No newline at end of file