diff --git a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs index 02ea6ccb1486..e2146956cbb5 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs @@ -270,7 +270,7 @@ void InvalidateMeasureIfContentSizeChanged() } - internal Size? GetSize() + internal virtual Size? GetSize() { if (_emptyViewDisplayed) { diff --git a/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs b/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs index dd20aa44174e..784df8e5cd3b 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs @@ -1,6 +1,7 @@ #nullable disable using System; using CoreGraphics; +using Microsoft.Maui.Graphics; using ObjCRuntime; using UIKit; @@ -240,6 +241,12 @@ protected override void HandleFormsElementMeasureInvalidated(VisualElement forms UpdateHeaderFooterPosition(); } + internal override Size? GetSize() + { + var size = base.GetSize(); + return new Size(size.Value.Width, size.Value.Height + (_headerUIView?.Frame.Height ?? 0) + (_footerUIView?.Frame.Height ?? 0)); + } + internal void UpdateLayoutMeasurements() { if (_headerViewFormsElement != null) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue27808.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue27808.xaml new file mode 100644 index 000000000000..1d704e83a3ba --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue27808.xaml @@ -0,0 +1,34 @@ + + + + + + + item1 + item2 + item3 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue27808.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue27808.xaml.cs new file mode 100644 index 000000000000..ed76b7737767 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue27808.xaml.cs @@ -0,0 +1,10 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 27808, "CollectionView with header or footer has incorrect height", PlatformAffected.iOS)] +public partial class Issue27808 : ContentPage +{ + public Issue27808() + { + InitializeComponent(); + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27808.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27808.cs new file mode 100644 index 000000000000..081d1180e62d --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27808.cs @@ -0,0 +1,22 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues +{ + public class Issue27808 : _IssuesUITest + { + public Issue27808(TestDevice testDevice) : base(testDevice) + { + } + + public override string Issue => "CollectionView with header or footer has incorrect height"; + + [Test] + [Category(UITestCategories.CollectionView)] + public void CollectionViewShouldHaveCorrectHeight() + { + App.WaitForElement("item3"); + } + } +} \ No newline at end of file