Skip to content

test: Add Skia-only runtime test for Grid ActualSize constraint with large child margin - #23150

Merged
MartinZikmund merged 2 commits into
masterfrom
copilot/fix-grid-size-calculation-bug
Apr 30, 2026
Merged

MartinZikmund merged 2 commits into
masterfrom
copilot/fix-grid-size-calculation-bug

Conversation

Copilot AI commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

A Grid with a child element using a very large margin (e.g., Margin="0,0,0,9999") incorrectly reported ActualHeight/ActualWidth of 9999 instead of being constrained to the parent container's available size. This manifested in the "PushRect" layout pattern commonly used inside ContentDialog.

Changes

  • New runtime test When_Grid_Child_Has_Large_Bottom_Margin_Grid_ActualSize_Constrained added to Given_GridLayouting.cs
    • Reproduces the "PushRect" pattern: a Grid (MaxHeight=9999) inside a fixed 400×400 Border, containing a fully-stretching child with Margin="0,0,0,9999"
    • Asserts Grid.ActualHeight and Grid.ActualWidth equal 400 (parent-constrained), not 9999
    • Scoped to Skia platforms only via [PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.Skia)], where the fix is confirmed present
var container = new Border { Width = 400, Height = 400 };
var SUT = new Grid { MaxWidth = 9999, MaxHeight = 9999 };
var pushRect = new Border
{
    HorizontalAlignment = HorizontalAlignment.Stretch,
    VerticalAlignment = VerticalAlignment.Stretch,
    Margin = new Thickness(0, 0, 0, 9999),
    Opacity = 0,
};
SUT.Children.Add(pushRect);
container.Child = SUT;
// ...
Assert.AreEqual(400, SUT.ActualHeight, 1); // must NOT be 9999
Assert.AreEqual(400, SUT.ActualWidth, 1);

PR Checklist ✅

Please check if your PR fulfills the following requirements:

Copilot AI self-assigned this Apr 28, 2026
Copilot AI review requested due to automatic review settings April 28, 2026 13:28
Copilot AI removed the request for review from Copilot April 28, 2026 13:28
Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 13:48
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix grid calculated actual size bug with child element margins test: Add Skia-only runtime test for Grid ActualSize constraint with large child margin Apr 28, 2026
Copilot AI requested a review from MartinZikmund April 28, 2026 13:51
@MartinZikmund
MartinZikmund marked this pull request as ready for review April 28, 2026 14:48
@MartinZikmund

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Skia-scoped runtime regression test to ensure a Grid inside a fixed-size parent reports ActualWidth/ActualHeight constrained to the parent, even when a stretching child uses an extremely large margin (the “PushRect” pattern seen in ContentDialog scenarios).

Changes:

  • Added When_Grid_Child_Has_Large_Bottom_Margin_Grid_ActualSize_Constrained runtime test targeting Skia platforms.
  • The test reproduces a large-bottom-margin “PushRect” child and asserts the Grid’s ActualWidth/ActualHeight remain constrained to the parent’s 400×400 size.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund merged commit 775513c into master Apr 30, 2026
47 checks passed
@MartinZikmund
MartinZikmund deleted the copilot/fix-grid-size-calculation-bug branch April 30, 2026 12:50
@agneszitte

Copy link
Copy Markdown
Member

/unobot prepare-release --commit-message-pattern "ci: Set version to '{0}'"

@unodevops

Copy link
Copy Markdown
Contributor

The release branch release/stable/6.6 has been created from 9518f13 and the PR #23170 has been created for the version bump.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grid calculated actual size bug (child element margins not used correctly)

7 participants