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 edge case with Grids, *s, and unconstrained layouts #14114

Merged
merged 2 commits into from
Mar 22, 2023

Conversation

hartez
Copy link
Contributor

@hartez hartez commented Mar 22, 2023

Description of Change

In a layout like this one:

<VerticalStackLayout>
    <Grid RowDefinitions="*,*,*" VerticalOptions="Fill">
        <Border StrokeThickness="2" Stroke="LightBlue">
            <Label Text="Hello"></Label>
        </Border>
        <Border Grid.Row="1" Stroke="Orange" StrokeThickness="5">
            <Label Text="Hello" HeightRequest="25"></Label>
        </Border>
        <Border Grid.Row="2" Stroke="Red" StrokeThickness="10">
            <Label Text="Hello" HeightRequest="50"></Label>
        </Border>
    </Grid>
</VerticalStackLayout>

The Grid is taking the natural stacked size of the rows and trying to distribute the heights evenly (because of the * values), even though the VerticalOptions="Fill" shouldn't have any meaning in a vertically unconstrained layout. This ends up creating some weird layout results. The Grid should be ignoring the "Fill" in this situation and just leaving the rows at their originally measured heights. (A similar issue is present for columns in horizontally unconstrained layouts.)

This PR fixes the issue so the Grid behaves.

@github-actions
Copy link
Contributor

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

@jsuarezruiz jsuarezruiz added layout-grid area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter labels Mar 22, 2023
@rmarinho rmarinho merged commit 1e1ca27 into main Mar 22, 2023
@rmarinho rmarinho deleted the fix-star-grids-in-stacklayouts branch March 22, 2023 12:05
@PureWeen PureWeen added the backport/suggested The PR author or issue review has suggested that the change should be backported. label Mar 31, 2023
@rmarinho
Copy link
Member

rmarinho commented Apr 3, 2023

/backport to net7.0

@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2023

Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/4599366267

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter backport/approved After some discussion or review, this PR or change was approved to be backported. backport/suggested The PR author or issue review has suggested that the change should be backported. fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! layout-grid
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants