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 @@ -924,6 +924,12 @@ internal virtual void CellDisplayingEndedFromDelegate(UICollectionViewCell cell,
!Equals(itemsSource[indexPath], bindingContext))
{
templatedCell.Unbind();

if (CollectionView is MauiCollectionView collectionView)
{
// When removing a cell, we need to trigger a layout update in order to sync the footer position
collectionView.NeedsCellLayout = true;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
x:Class=" Maui.Controls.Sample.CollectionViewGalleries.HeaderFooterGalleries.HeaderFooterView">
<ContentPage.Content>

<CollectionView x:Name="CollectionView" ItemsSource="{Binding Items}">
<CollectionView x:Name="CollectionView" AutomationId="CV" ItemsSource="{Binding Items}">

<CollectionView.Header>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ public HeaderFooterViewModel(int count = 50, Func<string, CollectionViewGalleryT
{
}

public ICommand AddCommand => new Command(async () => await AddItemsAsync());
public ICommand AddCommand => new Command(AddItemsAsync);

public ICommand ClearCommand => new Command(() => Items.Clear());

public string HeaderText => "This Is A Header";

public string FooterText => "This Is A Footer";

async Task AddItemsAsync()
void AddItemsAsync()
{
await Task.Delay(TimeSpan.FromSeconds(1));
AddItems(Items, 2);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using NUnit.Framework.Legacy;
using UITest.Appium;
using UITest.Core;

Expand Down Expand Up @@ -31,7 +32,7 @@ public void HeaderFooterStringWorks()
#if IOS || ANDROID
[Test]
[Category(UITestCategories.CollectionView)]
public void HeaderFooterViewWorks()
public async Task HeaderFooterViewWorks()
{
// Navigate to the selection galleries
VisitInitialGallery("Header Footer");
Expand All @@ -41,6 +42,20 @@ public void HeaderFooterViewWorks()

App.WaitForElement("This Is A Header");
App.WaitForElement("This Is A Footer");

// Now let's add items until the footer goes out of the screen
// and then remove them all and verify the footer is visible again (#29137)
var i = 5;
while (--i > 0)
{
App.WaitForElement("Add 2 Items").Tap();
App.ScrollDownTo("Add 2 Items", "CV");
}

App.WaitForElement("Clear All Items").Tap();
await Task.Delay(300);

ClassicAssert.IsTrue(App.WaitForElement("This Is A Footer").IsDisplayed());
}

[Test]
Expand Down
Loading