Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed inappropriate ellipsis will appear when adding more items in collection view #27048

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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 @@ -108,13 +108,15 @@ internal virtual bool UpdateConstraints(CGSize size)
{
if (size.IsCloseTo(_currentSize))
{
// Need to update the constraints when dynamically adding items of different sizes
ConstrainTo(_currentSize);
return false;
}

ClearCellSizeCache();

EstimatedItemSize = CGSize.Empty;

_currentSize = size;

var newSize = new CGSize(Math.Floor(size.Width), Math.Floor(size.Height));
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue26936.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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.Issue26936"
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"
Title="Issue26936">
<VerticalStackLayout>
<Button Text="Add new items"
AutomationId="Button"
Clicked="Button_Clicked"/>
<CollectionView x:Name="collectionView"
HeightRequest="50">
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Horizontal"/>
</CollectionView.ItemsLayout>
</CollectionView>
</VerticalStackLayout>
</ContentPage>
30 changes: 30 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue26936.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 26936, "CollectionView items appear with ellipses or dots when dynamically adding more items.", PlatformAffected.macOS | PlatformAffected.iOS)]
public partial class Issue26936 : ContentPage
{
Issue26936ViewModel _viewModel = new Issue26936ViewModel();

public Issue26936()
{
InitializeComponent();
collectionView.ItemsSource = _viewModel.Items;
this.BindingContext = _viewModel;
}
private void Button_Clicked(object sender, EventArgs e)
{
_viewModel.Items.Add("item: " + this._viewModel.Items.Count);
}
}

public class Issue26936ViewModel
{
public ObservableCollection<string> Items { get; set; }
public Issue26936ViewModel()
{
Items = new ObservableCollection<string>();
Items.Add("item: " + "0");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue26936(TestDevice testDevice) : _IssuesUITest(testDevice)
{
public override string Issue => "CollectionView items appear with ellipses or dots when dynamically adding more items.";

[Test]
[Category(UITestCategories.CollectionView)]
public void ShouldCollectionViewEachItemsAppearWithoutDots()
{
App.WaitForElement("Label");
for (int i = 0; i < 50; i++)
{
App.Tap("Button");
}

VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading