Skip to content

Commit 172dd41

Browse files
authored
[Revert] [iOS] CollectionView with grouped data crashes on iOS when the groups change - fix (#28246)
* Revert "CollectionView with grouped data crashes on iOS when the groups change - fix (#27991)" This reverts commit 47077b1. * - add tests to make sure we validate regression
1 parent fa2b417 commit 172dd41

File tree

11 files changed

+122
-332
lines changed

11 files changed

+122
-332
lines changed

src/Controls/src/Core/Handlers/Items/iOS/ObservableGroupedSource.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,6 @@ void Move(NotifyCollectionChangedEventArgs args)
315315

316316
int GetGroupCount(int groupIndex)
317317
{
318-
if (groupIndex < 0 || groupIndex >= _groupSource.Count)
319-
{
320-
return 0;
321-
}
322-
323318
switch (_groupSource[groupIndex])
324319
{
325320
case IList list:
@@ -339,11 +334,6 @@ int GetGroupCount(int groupIndex)
339334

340335
object GetGroupItemAt(int groupIndex, int index)
341336
{
342-
if (groupIndex < 0 || groupIndex >= _groupSource.Count)
343-
{
344-
return -1;
345-
}
346-
347337
switch (_groupSource[groupIndex])
348338
{
349339
case IList list:

src/Controls/src/Core/Handlers/Items/iOS/ObservableItemsSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void Update(Action<UICollectionView> update, NotifyCollectionChangedEventArgs ar
314314
return;
315315

316316
var collectionView = controller.CollectionView;
317-
if (collectionView.Hidden || collectionView.Window == null)
317+
if (collectionView.Hidden)
318318
{
319319
return;
320320
}
135 KB
Loading

src/Controls/tests/TestCases.HostApp/Issues/Issue27797.xaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Controls/tests/TestCases.HostApp/Issues/Issue27797.xaml.cs

Lines changed: 0 additions & 260 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue28098"
5+
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"
6+
Title="Issue28098">
7+
<ContentPage.BindingContext>
8+
<local:MainPageViewModel x:Name="_viewModel"/>
9+
</ContentPage.BindingContext>
10+
<StackLayout Margin="20">
11+
<Button Clicked="Button_Clicked"
12+
AutomationId="Button"
13+
Text="Button"/>
14+
<CarouselView WidthRequest="350"
15+
HeightRequest="570"
16+
HorizontalOptions="Fill"
17+
VerticalOptions="Fill"
18+
ItemsSource="{Binding Items}"
19+
Loop="False">
20+
<CarouselView.ItemTemplate>
21+
<DataTemplate>
22+
<StackLayout>
23+
<Image Source="dotnet_bot.png"
24+
WidthRequest="200"
25+
HeightRequest="200"
26+
Aspect="AspectFill"/>
27+
<Label Padding="10"
28+
VerticalOptions="Center"
29+
HorizontalOptions="Center"
30+
Text="{Binding Name}"/>
31+
</StackLayout>
32+
</DataTemplate>
33+
</CarouselView.ItemTemplate>
34+
</CarouselView>
35+
36+
</StackLayout>
37+
</ContentPage>

0 commit comments

Comments
 (0)