Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public ReorderableItemsViewController(TItemsView reorderableItemsView, ItemsView
// For some reason it only seemed to work when the CollectionView was inside the Flyout section of a FlyoutPage.
// The UILongPressGestureRecognizer is simple enough to set up so let's just add our own.
InstallsStandardGestureForInteractiveMovement = false;
#if MACCATALYST
// On Mac Catalyst, the default normal press and drag interactions occur, causing the CanMixGroups = false logic to not work.
// Since all reordering logic is handled exclusively by UILongPressGestureRecognizer, we can set DragInteractionEnabled to false, ensuring that only the long press gesture is used.
CollectionView.DragInteractionEnabled = false;
#endif
}

public override bool CanMoveItem(UICollectionView collectionView, NSIndexPath indexPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public ReorderableItemsViewController2(TItemsView reorderableItemsView, UICollec
// For some reason it only seemed to work when the CollectionView was inside the Flyout section of a FlyoutPage.
// The UILongPressGestureRecognizer is simple enough to set up so let's just add our own.
InstallsStandardGestureForInteractiveMovement = false;
#if MACCATALYST
// On Mac Catalyst, the default normal press and drag interactions occur, causing the CanMixGroups = false logic to not work.
// Since all reordering logic is handled exclusively by UILongPressGestureRecognizer, we can set DragInteractionEnabled to false, ensuring that only the long press gesture is used.
CollectionView.DragInteractionEnabled = false;
#endif
}

public override bool CanMoveItem(UICollectionView collectionView, NSIndexPath indexPath)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue28530.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue28530">

<VerticalStackLayout Padding="10">
<CollectionView
ItemsSource="{Binding GroupedItems}"
IsGrouped="true"
CanReorderItems="true"
CanMixGroups="false"
AutomationId="CollectionViewControl">
<CollectionView.GroupHeaderTemplate>
<DataTemplate>
<Label Text="{Binding GroupHeaderName}"
FontAttributes="Bold"
FontSize="14"
Padding="5"/>
</DataTemplate>
</CollectionView.GroupHeaderTemplate>
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Name}"
AutomationId="{Binding .}"
FontSize="12"
Padding="5"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</VerticalStackLayout>

</ContentPage>
56 changes: 56 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue28530.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace Maui.Controls.Sample.Issues;
[Issue(IssueTracker.Github, 28530, "[Catalyst] CanMixGroups Set to False Still Allows Reordering Between Groups in CollectionView", PlatformAffected.macOS)]
public partial class Issue28530 : ContentPage
{
public Issue28530()
{
InitializeComponent();
BindingContext = new Issue28530CollectionViewViewModel();
}
}

public class Issue28530CollectionViewViewModel : INotifyPropertyChanged
{
public ObservableCollection<Issue28530GroupedItem> GroupedItems { get; set; }
public event PropertyChangedEventHandler PropertyChanged;

public Issue28530CollectionViewViewModel()
{
GroupedItems = new ObservableCollection<Issue28530GroupedItem>
{
new Issue28530GroupedItem("Group 1")
{
new Issue28530Item { Name = "Item 1" },
new Issue28530Item { Name = "Item 2" }
},
new Issue28530GroupedItem("Group 2")
{
new Issue28530Item { Name = "Item 3" },
new Issue28530Item { Name = "Item 4" }
}
};
}

protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

public class Issue28530GroupedItem : ObservableCollection<Issue28530Item>
{
public string GroupHeaderName { get; set; }

public Issue28530GroupedItem(string groupHeaderName)
{
GroupHeaderName = groupHeaderName;
}
}

public class Issue28530Item
{
public string Name { get; set; }
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#if TEST_FAILS_ON_WINDOWS
// https://github.com/dotnet/maui/issues/13027 In windows, .NET MAUI CollectionView does not reorder when grouped
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue28530 : _IssuesUITest
{
public Issue28530(TestDevice device) : base(device) { }

public override string Issue => "[Catalyst] CanMixGroups Set to False Still Allows Reordering Between Groups in CollectionView";

[Test]
[Category(UITestCategories.CollectionView)]
public void ReorderBetweenGroupsShouldNotOccurWhenCanMixGroupsIsFalse()
{
App.WaitForElement("CollectionViewControl");
App.DragAndDrop("Item 2", "Item 3");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshot on some platforms.

For example, Android:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have committed the pending images for other platforms. @jsuarezruiz

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails on iOS:
Snapshot different than baseline: ReorderBetweenGroupsShouldNotOccurWhenCanMixGroupsIsFalse.png (1.44% difference)
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have resaved the iOS image from CI. Could you please verify it now? @jsuarezruiz

}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.