Skip to content

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

Merged
zdpcdt merged 2 commits intomainfrom
copilot/fix-elasticwrappanel-skip-hidden-items
Feb 26, 2026
Merged

Fix ElasticWrapPanel not skipping hidden children when IsFillHorizontal and ItemWidth are set#896
zdpcdt merged 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
@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
Ursa 42% 32% 9055
Ursa.Themes.Semi 62% 68% 1021
Summary 50% (11026 / 22013) 35% (2708 / 7751) 10076

@github-actions
Copy link

Test Results

726 tests  +2   726 ✅ +2   15s ⏱️ ±0s
  2 suites ±0     0 💤 ±0 
  2 files   ±0     0 ❌ ±0 

Results for commit 2287317. ± Comparison against base commit f1c9dc4.

@zdpcdt zdpcdt marked this pull request as ready for review February 26, 2026 12:03
@zdpcdt zdpcdt merged commit 860b832 into main Feb 26, 2026
4 checks passed
@zdpcdt zdpcdt deleted the copilot/fix-elasticwrappanel-skip-hidden-items branch February 26, 2026 12:08
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控件不跳过隐藏项问题

3 participants