Skip to content

Commit 71639d1

Browse files
Addressed copilot concerns.
1 parent 77c1980 commit 71639d1

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/Controls/src/Core/Handlers/Items2/iOS/LayoutFactory2.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ public static UICollectionViewLayout CreateCarouselLayout(
276276
{
277277
// Keep the typed layout around so the final layout selection can opt vertical carousels
278278
// into the custom snap-aware compositional layout.
279-
var linearItemsLayout = weakItemsView.TryGetTarget(out var itemsView)
280-
? itemsView.ItemsLayout as LinearItemsLayout
279+
var linearItemsLayout = weakItemsView.TryGetTarget(out var carouselView)
280+
? carouselView.ItemsLayout as LinearItemsLayout
281281
: null;
282282

283283
NSCollectionLayoutDimension itemWidth = NSCollectionLayoutDimension.CreateFractionalWidth(1);
@@ -426,9 +426,12 @@ public static UICollectionViewLayout CreateCarouselLayout(
426426
return section;
427427
});
428428

429-
// Route vertical CarouselView layouts through the custom compositional layout so
430-
// MandatorySingle snapping uses the existing TargetContentOffset pipeline.
429+
// Route vertical CarouselView layouts with snap points through the custom compositional
430+
// layout so MandatorySingle snapping uses the existing TargetContentOffset pipeline.
431+
// Vertical carousels without snap points continue to use the standard layout to avoid
432+
// unintended behavior changes.
431433
var layout = linearItemsLayout?.Orientation == ItemsLayoutOrientation.Vertical
434+
&& linearItemsLayout.SnapPointsType != SnapPointsType.None
432435
? new CustomUICollectionViewCompositionalLayout(
433436
new LayoutSnapInfo
434437
{

src/Controls/tests/TestCases.HostApp/Issues/Issue33308.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public Issue33308()
1515
var cardsCarousel = new CarouselView
1616
{
1717
Loop = false,
18+
AutomationId = "CardsCarousel",
1819
ItemsSource = cards,
1920
VerticalScrollBarVisibility = ScrollBarVisibility.Never,
2021
ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Vertical)

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if TEST_FAILS_ON_WINDOWS // Windows does not consistently capture the same item on scroll down, so this test may be flaky and is skipped on Windows.
12
using NUnit.Framework;
23
using UITest.Appium;
34
using UITest.Core;
@@ -16,10 +17,13 @@ public Issue33308(TestDevice device) : base(device)
1617
[Category(UITestCategories.CarouselView)]
1718
public void VerticalCarouselMandatorySingleSnapAdvancesOneCard()
1819
{
19-
App.WaitForElement("Card 1");
20+
App.WaitForElement("CardsCarousel");
2021

21-
App.ScrollDown("Card 1", ScrollStrategy.Gesture, 0.99, swipeSpeed: 50, withInertia: true);
22+
App.ScrollDown("CardsCarousel", ScrollStrategy.Gesture, 0.99, swipeSpeed: 500, withInertia: true);
23+
24+
App.WaitForElement("Card 2");
2225

2326
VerifyScreenshot(retryTimeout: TimeSpan.FromSeconds(2));
2427
}
2528
}
29+
#endif

0 commit comments

Comments
 (0)