From 4d697ec64b66d1e4c94e44df5360e06dd82dcd6c Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Fri, 10 Apr 2026 12:40:54 +0530 Subject: [PATCH 1/2] Add fix --- .../ScrollingFeature/CollectionViewScrollPage.xaml.cs | 4 ++++ src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs | 5 +++++ .../FeatureMatrix/CollectionView_ScrollingFeatureTests.cs | 4 +--- .../tests/TestCases.Shared.Tests/Tests/Issues/Issue33614.cs | 2 -- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs b/src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs index 8c365b127e99..cc7a13d95edc 100644 --- a/src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs +++ b/src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs @@ -18,6 +18,10 @@ private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e) BindingContext = _viewModel = new CollectionViewViewModel(isScrollingFeatureTest: true); _viewModel.ItemsSourceType = ItemsSourceType.ObservableCollectionT3; _viewModel.ScrollToPosition = ScrollToPosition.MakeVisible; + // Wait for any deferred DispatcherQueue.TryEnqueue callbacks from OnItemsVectorChanged + // (introduced by the fix in ItemsViewHandler.Windows.cs) to fire before resetting the + // scroll event labels, so the reset isn't overwritten by the deferred scroll. + await Task.Delay(300); ResetScrollEventLabels(); await Navigation.PushAsync(new ScrollBehaviorOptionsPage(_viewModel)); } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs index cde932b66b16..6cf3214a18d1 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue33614.cs @@ -71,6 +71,11 @@ private void OnCollectionViewScrolled(object sender, ItemsViewScrolledEventArgs private void OnScrollToButtonClicked(object sender, EventArgs e) { +#if WINDOWS + // Disable animation on Windows to avoid flaky test results + _collectionView.ScrollTo(15, position: ScrollToPosition.Start, animate: false); +#else _collectionView.ScrollTo(15, position: ScrollToPosition.Start, animate: true); +#endif } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/CollectionView_ScrollingFeatureTests.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/CollectionView_ScrollingFeatureTests.cs index a7b1196499a1..8c77653bd5fd 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/CollectionView_ScrollingFeatureTests.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/CollectionView_ScrollingFeatureTests.cs @@ -1223,7 +1223,7 @@ public void VerifyKeepLastItemInViewWithGroupedListWhenHorizontalGrid() #endif #endif -#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS // In windows, related issue: https://github.com/dotnet/maui/issues/34772 +#if TEST_FAILS_ON_ANDROID //[Android] KeepScrollOffset doesn't not works as expected when new items are added in CollectionView Issue Link: https://github.com/dotnet/maui/issues/29131 [Test] [Category(UITestCategories.CollectionView)] @@ -1577,7 +1577,6 @@ public void VerifyDefaultScrollToRequested() } // ScrollTo By Index Tests -#if TEST_FAILS_ON_WINDOWS // Related issue: https://github.com/dotnet/maui/issues/34772 [Test] [Category(UITestCategories.CollectionView)] public void VerifyScrollToByIndexWithMakeVisiblePositionAndVerticalList_Carrot() @@ -1790,7 +1789,6 @@ public void VerifyScrollToByItemWithEndPositionAndVerticalList_Carrot() Assert.That(App.WaitForElement("ItemLabel").GetText(), Is.EqualTo("Carrot")); VerifyScreenshot(); } -#endif // Grouped ScrollTo By Index Tests #if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_IOS // Issue - https://github.com/dotnet/maui/issues/17664 diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33614.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33614.cs index 569a45fc7a54..5e687f2b049c 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33614.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33614.cs @@ -1,4 +1,3 @@ -#if TEST_FAILS_ON_WINDOWS // Related issue: https://github.com/dotnet/maui/issues/34772 using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -21,4 +20,3 @@ public void FirstVisibleItemIndexShouldBeCorrectAfterScrollTo() Assert.That(firstIndexText, Is.EqualTo("FirstVisibleItemIndex: 15")); } } -#endif \ No newline at end of file From db23dc8f0aca35df3f6787c2643f8a27e755faca Mon Sep 17 00:00:00 2001 From: HarishwaranVijayakumar Date: Wed, 15 Apr 2026 12:12:00 +0530 Subject: [PATCH 2/2] Address copilot concern --- .../ScrollingFeature/CollectionViewScrollPage.xaml.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs b/src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs index cc7a13d95edc..29501e9b7034 100644 --- a/src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs +++ b/src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/ScrollingFeature/CollectionViewScrollPage.xaml.cs @@ -18,10 +18,12 @@ private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e) BindingContext = _viewModel = new CollectionViewViewModel(isScrollingFeatureTest: true); _viewModel.ItemsSourceType = ItemsSourceType.ObservableCollectionT3; _viewModel.ScrollToPosition = ScrollToPosition.MakeVisible; +#if WINDOWS // Wait for any deferred DispatcherQueue.TryEnqueue callbacks from OnItemsVectorChanged // (introduced by the fix in ItemsViewHandler.Windows.cs) to fire before resetting the // scroll event labels, so the reset isn't overwritten by the deferred scroll. await Task.Delay(300); +#endif ResetScrollEventLabels(); await Navigation.PushAsync(new ScrollBehaviorOptionsPage(_viewModel)); }