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

Fix GridLayoutManager Layout calculation #7712

Merged
merged 2 commits into from Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Core/src/Layouts/GridLayoutManager.cs
Expand Up @@ -84,11 +84,12 @@ public GridStructure(IGridLayout grid, double widthConstraint, double heightCons
{
_grid = grid;

_gridWidthConstraint = widthConstraint;
_gridHeightConstraint = heightConstraint;

_explicitGridHeight = _grid.Height;
_explicitGridWidth = _grid.Width;

_gridWidthConstraint = _explicitGridWidth > -1 ? _explicitGridWidth : widthConstraint;
rmarinho marked this conversation as resolved.
Show resolved Hide resolved
_gridHeightConstraint = _explicitGridHeight > -1 ? _explicitGridHeight : heightConstraint;

_gridMaxHeight = _grid.MaximumHeight;
_gridMinHeight = _grid.MinimumHeight;
_gridMaxWidth = _grid.MaximumWidth;
Expand Down
17 changes: 17 additions & 0 deletions src/Core/tests/UnitTests/Layouts/GridLayoutManagerTests.cs
Expand Up @@ -1851,6 +1851,23 @@ public void StarCoumnWidthCorrectWhenFirstChildCollapsed()
Assert.Equal(10, measuredSize.Width);
}

[Fact("ArrangeChildren should arranged within measured size")]
[Category(GridStarSizing)]
public void ArrangeChildrenShouldArrangedWithinMeasuredSize()
{
var grid = CreateGridLayout(rows: "*");
grid.Width.Returns(105);
grid.Height.Returns(120);

var view0 = CreateTestView(new Size(20, 20));
SubstituteChildren(grid, view0);

var measuredSize = MeasureAndArrange(grid, 300, double.PositiveInfinity);

// we expect that the child will be arranged within measured size
AssertArranged(view0, 0, 0, measuredSize.Width, measuredSize.Height);
}

[Theory]
[InlineData(LayoutAlignment.Center, true)]
[InlineData(LayoutAlignment.Center, false)]
Expand Down