From d54d1c389bf84a57d4d38f51327022573469b4d8 Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:11:27 +0530 Subject: [PATCH 1/9] fix for 23608 --- src/Controls/src/Core/Toolbar/Toolbar.Windows.cs | 2 +- .../tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs b/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs index e229095e5899..780ec612dd22 100644 --- a/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs +++ b/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs @@ -28,7 +28,7 @@ partial void OnHandlerChanging(IElementHandler oldHandler, IElementHandler newHa internal void UpdateMenu() { - if (Handler.PlatformView is not MauiToolbar wh) + if (Handler?.PlatformView is not MauiToolbar wh) return; var commandBar = wh.CommandBar; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs index 8676241cce08..10a2349e5959 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs @@ -1,5 +1,4 @@ -#if TEST_FAILS_ON_WINDOWS //App Crashes on windows, Issue: https://github.com/dotnet/maui/issues/26803 -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -23,4 +22,3 @@ public void TestIssue9419() } } } -#endif \ No newline at end of file From 5c20e870ce9dfc460c73103cd326ae30e088be8e Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Thu, 2 Jan 2025 17:37:32 +0530 Subject: [PATCH 2/9] Update Toolbar.Windows.cs --- src/Controls/src/Core/Toolbar/Toolbar.Windows.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs b/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs index 780ec612dd22..272974e9d402 100644 --- a/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs +++ b/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs @@ -28,7 +28,7 @@ partial void OnHandlerChanging(IElementHandler oldHandler, IElementHandler newHa internal void UpdateMenu() { - if (Handler?.PlatformView is not MauiToolbar wh) + if (Handler.PlatformView is not MauiToolbar wh) return; var commandBar = wh.CommandBar; @@ -88,7 +88,7 @@ internal void UpdateMenu() internal void OnToolbarItemPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (Handler.PlatformView is not MauiToolbar wh) + if (Handler?.PlatformView is not MauiToolbar wh) return; var commandBar = wh.CommandBar; From 3eab101fed6eee6019d73ff88295b823e415d112 Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:22:04 +0530 Subject: [PATCH 3/9] Commit for 23698 --- .../Handlers/Items/Android/MauiRecyclerView.cs | 11 ++--------- .../Core/Handlers/Items/iOS/ItemsViewLayout.cs | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs b/src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs index ab43bb156c0a..4bae74e49e5c 100644 --- a/src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs +++ b/src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs @@ -374,15 +374,8 @@ protected virtual void UpdateItemsUpdatingScrollMode() if (ItemsViewAdapter == null || ItemsView == null) return; - if (ItemsView.ItemsUpdatingScrollMode == ItemsUpdatingScrollMode.KeepItemsInView) - { - // Keeping the current items in view is the default, so we don't need to watch for data changes - _itemsUpdateScrollObserver.Stop(ItemsViewAdapter); - } - else - { - _itemsUpdateScrollObserver.Start(ItemsViewAdapter); - } + // We need to observe the adapter for changes for the ItemsUpdatingScrollMode. + _itemsUpdateScrollObserver.Start(ItemsViewAdapter); } public virtual void ScrollTo(ScrollToRequestEventArgs args) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs index a5665d054e9d..abc5bb4d30de 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs @@ -114,7 +114,7 @@ internal virtual bool UpdateConstraints(CGSize size) ClearCellSizeCache(); EstimatedItemSize = CGSize.Empty; - + _currentSize = size; var newSize = new CGSize(Math.Floor(size.Width), Math.Floor(size.Height)); @@ -500,6 +500,10 @@ public override void FinalizeCollectionViewUpdates() { ForceScrollToLastItem(CollectionView, _itemsLayout); } + else if (ItemsUpdatingScrollMode == ItemsUpdatingScrollMode.KeepItemsInView) + { + ForceScrollToFirstItem(CollectionView, _itemsLayout); + } } void TrackOffsetAdjustment() @@ -591,6 +595,16 @@ static void ForceScrollToLastItem(UICollectionView collectionView, ItemsLayout i } } + //Fix Added for ItemsUpdatingScrollMode.KeepItemsInView + void ForceScrollToFirstItem(UICollectionView collectionView, ItemsLayout itemsLayout) + { + if (collectionView.NumberOfItemsInSection(0) > 0) + { + var indexPath = NSIndexPath.FromItemSection(0, 0); + collectionView.ScrollToItem(indexPath, UICollectionViewScrollPosition.Top, true); + + } + } public override bool ShouldInvalidateLayoutForBoundsChange(CGRect newBounds) { if (newBounds.Size.IsCloseTo(_currentSize)) From 03b6c314c7bb85add0562d5f43877e0d1e76ecaf Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:29:51 +0530 Subject: [PATCH 4/9] unwanted changes --- src/Controls/src/Core/Toolbar/Toolbar.Windows.cs | 2 +- .../tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs b/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs index 272974e9d402..e229095e5899 100644 --- a/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs +++ b/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs @@ -88,7 +88,7 @@ internal void UpdateMenu() internal void OnToolbarItemPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (Handler?.PlatformView is not MauiToolbar wh) + if (Handler.PlatformView is not MauiToolbar wh) return; var commandBar = wh.CommandBar; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs index 10a2349e5959..8676241cce08 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if TEST_FAILS_ON_WINDOWS //App Crashes on windows, Issue: https://github.com/dotnet/maui/issues/26803 +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -22,3 +23,4 @@ public void TestIssue9419() } } } +#endif \ No newline at end of file From 59ef9f846038dcdbfa0749c9fc8c5dd09df3f2b2 Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:04:15 +0530 Subject: [PATCH 5/9] Commit for unwanted changes --- .../Core/Handlers/Items/Android/MauiRecyclerView.cs | 11 +++++++++-- .../src/Core/Handlers/Items/iOS/ItemsViewLayout.cs | 4 ---- src/Controls/src/Core/Toolbar/Toolbar.Windows.cs | 2 +- .../TestCases.Shared.Tests/Tests/Issues/Issue9419.cs | 6 ++---- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs b/src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs index 4bae74e49e5c..ab43bb156c0a 100644 --- a/src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs +++ b/src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs @@ -374,8 +374,15 @@ protected virtual void UpdateItemsUpdatingScrollMode() if (ItemsViewAdapter == null || ItemsView == null) return; - // We need to observe the adapter for changes for the ItemsUpdatingScrollMode. - _itemsUpdateScrollObserver.Start(ItemsViewAdapter); + if (ItemsView.ItemsUpdatingScrollMode == ItemsUpdatingScrollMode.KeepItemsInView) + { + // Keeping the current items in view is the default, so we don't need to watch for data changes + _itemsUpdateScrollObserver.Stop(ItemsViewAdapter); + } + else + { + _itemsUpdateScrollObserver.Start(ItemsViewAdapter); + } } public virtual void ScrollTo(ScrollToRequestEventArgs args) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs index abc5bb4d30de..f2bbb00d1916 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs @@ -500,10 +500,6 @@ public override void FinalizeCollectionViewUpdates() { ForceScrollToLastItem(CollectionView, _itemsLayout); } - else if (ItemsUpdatingScrollMode == ItemsUpdatingScrollMode.KeepItemsInView) - { - ForceScrollToFirstItem(CollectionView, _itemsLayout); - } } void TrackOffsetAdjustment() diff --git a/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs b/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs index e229095e5899..272974e9d402 100644 --- a/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs +++ b/src/Controls/src/Core/Toolbar/Toolbar.Windows.cs @@ -88,7 +88,7 @@ internal void UpdateMenu() internal void OnToolbarItemPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (Handler.PlatformView is not MauiToolbar wh) + if (Handler?.PlatformView is not MauiToolbar wh) return; var commandBar = wh.CommandBar; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs index 8676241cce08..cdb4a664b96e 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs @@ -1,5 +1,4 @@ -#if TEST_FAILS_ON_WINDOWS //App Crashes on windows, Issue: https://github.com/dotnet/maui/issues/26803 -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -22,5 +21,4 @@ public void TestIssue9419() App.WaitForElementTillPageNavigationSettled(OkResult); } } -} -#endif \ No newline at end of file +} \ No newline at end of file From b7be2b83984090176ecf5eac9c97fc940f225561 Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:05:51 +0530 Subject: [PATCH 6/9] Update ItemsViewLayout.cs --- src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs index f2bbb00d1916..03e266c005e7 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs @@ -114,7 +114,6 @@ internal virtual bool UpdateConstraints(CGSize size) ClearCellSizeCache(); EstimatedItemSize = CGSize.Empty; - _currentSize = size; var newSize = new CGSize(Math.Floor(size.Width), Math.Floor(size.Height)); From f428f5e7a95461c0d02a693bb0c3a07a6382742e Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:10:41 +0530 Subject: [PATCH 7/9] Update ItemsViewLayout.cs --- .../src/Core/Handlers/Items/iOS/ItemsViewLayout.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs index 03e266c005e7..c6f8473b629d 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs @@ -114,6 +114,7 @@ internal virtual bool UpdateConstraints(CGSize size) ClearCellSizeCache(); EstimatedItemSize = CGSize.Empty; + _currentSize = size; var newSize = new CGSize(Math.Floor(size.Width), Math.Floor(size.Height)); @@ -590,16 +591,6 @@ static void ForceScrollToLastItem(UICollectionView collectionView, ItemsLayout i } } - //Fix Added for ItemsUpdatingScrollMode.KeepItemsInView - void ForceScrollToFirstItem(UICollectionView collectionView, ItemsLayout itemsLayout) - { - if (collectionView.NumberOfItemsInSection(0) > 0) - { - var indexPath = NSIndexPath.FromItemSection(0, 0); - collectionView.ScrollToItem(indexPath, UICollectionViewScrollPosition.Top, true); - - } - } public override bool ShouldInvalidateLayoutForBoundsChange(CGRect newBounds) { if (newBounds.Size.IsCloseTo(_currentSize)) From 67ea1dd53736cb0af55db80356a872149206b293 Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:20:45 +0530 Subject: [PATCH 8/9] Update ItemsViewLayout.cs --- src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs index c6f8473b629d..a5665d054e9d 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewLayout.cs @@ -114,7 +114,7 @@ internal virtual bool UpdateConstraints(CGSize size) ClearCellSizeCache(); EstimatedItemSize = CGSize.Empty; - + _currentSize = size; var newSize = new CGSize(Math.Floor(size.Width), Math.Floor(size.Height)); From 923a3da1aebfe2bc3c1096a66cf0ae05ee02e9b3 Mon Sep 17 00:00:00 2001 From: SuthiYuvaraj <92777079+SuthiYuvaraj@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:21:08 +0530 Subject: [PATCH 9/9] Update Issue9419.cs --- .../tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs index cdb4a664b96e..10a2349e5959 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue9419.cs @@ -21,4 +21,4 @@ public void TestIssue9419() App.WaitForElementTillPageNavigationSettled(OkResult); } } -} \ No newline at end of file +}