Skip to content

Comments

Fix ElasticWrapPanel not skipping hidden children when IsFillHorizontal and ItemWidth are set#896

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-elasticwrappanel-skip-hidden-items
Draft

Fix ElasticWrapPanel not skipping hidden children when IsFillHorizontal and ItemWidth are set#896
Copilot wants to merge 2 commits intomainfrom
copilot/fix-elasticwrappanel-skip-hidden-items

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

When IsFillHorizontal="True" and ItemWidth are set together, ElasticWrapPanel reserves layout space for invisible children. Without these properties the bug is masked because invisible children report DesiredSize of zero — but the fixed ItemWidth path bypasses that natural zero-size shortcut, assigning full slot width to hidden items regardless of visibility.

Changes

  • ElasticWrapPanel.cs — Add if (!child.IsVisible) continue; at the top of the child iteration loop in both MeasureOverride and ArrangeOverride, consistently skipping invisible children before any size calculation or collection placement occurs.
foreach (var child in children)
{
    if (!child.IsVisible) continue;  // ← added
    UVSize sz;
    if (GetIsFixToRB(child)) { ... }
    else
    {
        sz = new UVSize(orientation,
            itemWidthSet ? itemWidth : child.DesiredSize.Width,  // was using itemWidth for hidden children
            ...);
    }
}
  • ElasticWrapPanelTests/Tests.cs — Two new tests asserting hidden items are skipped both with and without ItemWidth/IsFillHorizontal set.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • av-build-tel-api-v1.avaloniaui.net
    • Triggering command: /usr/share/dotnet/dotnet dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.1/tools/netstandard2.0/runtimeconfig.json /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.1/tools/netstandard2.0/Avalonia.BuildServices.Collector.dll (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>ElasticWrapPanel控件不跳过隐藏项问题</issue_title>
<issue_description>ElasticWrapPanel控件,设置了IsFillHorizontal="True" ItemWidth="320"这两项后,隐藏的就不能跳过了,会继续占位。不设置这两个属性可以跳过隐藏项
Image

Image</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…d ArrangeOverride

Co-authored-by: rabbitism <14807942+rabbitism@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ElasticWrapPanel to skip hidden items Fix ElasticWrapPanel not skipping hidden children when IsFillHorizontal and ItemWidth are set Feb 25, 2026
Copilot AI requested a review from rabbitism February 25, 2026 06:14
@rabbitism rabbitism requested a review from zdpcdt February 25, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ElasticWrapPanel控件不跳过隐藏项问题

2 participants