Skip to content
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
2 changes: 2 additions & 0 deletions src/Ursa/Controls/Panels/ElasticWrapPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ protected override Size MeasureOverride(Size constraint)

foreach (var child in children)
{
if (!child.IsVisible) continue;
UVSize sz;
if (GetIsFixToRB(child))
{
Expand Down Expand Up @@ -258,6 +259,7 @@ protected override Size ArrangeOverride(Size finalSize)
var children = Children;
foreach (var child in children)
{
if (!child.IsVisible) continue;
UVSize sz;
if (GetIsFixToRB(child))
{
Expand Down
62 changes: 62 additions & 0 deletions tests/HeadlessTest.Ursa/Controls/ElasticWrapPanelTests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,66 @@ public void ItemSpacing_Does_Not_Affect_LineCount()
window.UpdateLayout();
Assert.Equal(4, panel2.LineCount); // 1 item per line, 4 items total = 4 lines
}

[AvaloniaFact]
public void HiddenItem_IsSkipped_WithItemWidth()
{
var window = new Window();
var panel = new ElasticWrapPanel
{
Width = 400,
Height = 400,
Orientation = Orientation.Horizontal,
ItemWidth = 100,
IsFillHorizontal = true,
};

// Add 4 items: item[1] is hidden
for (int i = 0; i < 4; i++)
{
var rect = new Rectangle
{
Width = 100,
Height = 100,
IsVisible = i != 1,
};
panel.Children.Add(rect);
}

window.Content = panel;
window.Show();

// 3 visible items of width 100 fit on one line in a 400-wide panel
Assert.Equal(1, panel.LineCount);
}

[AvaloniaFact]
public void HiddenItem_IsSkipped_WithoutItemWidth()
{
var window = new Window();
var panel = new ElasticWrapPanel
{
Width = 400,
Height = 400,
Orientation = Orientation.Horizontal,
};

// Add 4 items: item[1] is hidden
for (int i = 0; i < 4; i++)
{
var rect = new Rectangle
{
Width = 100,
Height = 100,
IsVisible = i != 1,
};
panel.Children.Add(rect);
}

window.Content = panel;
window.Show();

// 3 visible items of width 100 fit on one line in a 400-wide panel
Assert.Equal(1, panel.LineCount);
}
}