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

[AutoLayout] Possible Issue: AutoLayout Control Arranges Children with Margins Differently Than StackPanel and Grid #1279

Open
agneszitte opened this issue Nov 7, 2024 · 1 comment
Assignees
Labels
control/auto-layout kind/bug Something isn't working

Comments

@agneszitte
Copy link
Contributor

agneszitte commented Nov 7, 2024

Current behavior

The AutoLayout control seems to arrange children with Margin properties differently than StackPanel and Grid. In scenarios where elements have defined margins, AutoLayout does not produce the same alignment and spacing results as the other two containers.

As seen in the attached image below, with identical child elements and margin configurations, AutoLayout handles margins in a way that varies from StackPanel and Grid.

image

Expected behavior

Warning

Potentially an issue with AutoLayout ? To confirm first!

How to reproduce it (as minimally and precisely as possible)

Sample app to repro: UnoAutoLayoutTests.zip

<Grid Grid.ColumnDefinitions="*,*,*">

    <!-- Examples using Grid -->
    <StackPanel HorizontalAlignment="Center"
                VerticalAlignment="Center">
        <TextBlock Text="Grid"
                   HorizontalAlignment="Center"
                   FontWeight="Bold"
                   FontSize="11" />
        <Grid Background="DeepPink"
              Padding="10,8"
              Grid.RowDefinitions="Auto,Auto">
            <Border Background="Orange"
                    Height="50"
                    Width="50" />
            <Border Grid.Row="1"
                    Background="Purple"
                    Height="50"
                    Width="50" />
        </Grid>
        <Grid Background="Cyan"
              Grid.RowDefinitions="Auto,Auto">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,8" />
            <Border Grid.Row="1"
                    Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,8" />
        </Grid>
        <Grid Background="Yellow"
              Grid.RowDefinitions="Auto,Auto">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="0,8,0,0" />
            <Border Grid.Row="1"
                    Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="0,0,0,8" />
        </Grid>
        <Grid Background="LightGreen"
              Grid.RowDefinitions="Auto,Auto">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,0" />
            <Border Grid.Row="1"
                    Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="10,0,10,8" />
        </Grid>
    </StackPanel>

    <!-- Examples using StackPanel -->
    <StackPanel Grid.Column="1"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">
        <TextBlock Text="StackPanel"
                   HorizontalAlignment="Center"
                   FontWeight="Bold"
                   FontSize="11" />
        <StackPanel Background="DeepPink"
                    Padding="10,8">
            <Border Background="Orange"
                    Height="50"
                    Width="50" />
            <Border Background="Purple"
                    Height="50"
                    Width="50" />
        </StackPanel>
        <StackPanel Background="Cyan">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,8" />
            <Border Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,8" />
        </StackPanel>
        <StackPanel Background="Yellow">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="0,8,0,0" />
            <Border Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="0,0,0,8" />
        </StackPanel>
        <StackPanel Background="LightGreen">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,0" />
            <Border Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="10,0,10,8" />
        </StackPanel>
    </StackPanel>

    <!-- Examples using Toolkit AutoLayout -->
    <StackPanel Grid.Column="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">
        <TextBlock Text="AutoLayout"
                   HorizontalAlignment="Center"
                   FontWeight="Bold"
                   FontSize="11" />
        <utu:AutoLayout Background="DeepPink"
                        Padding="10,8">
            <Border Background="Orange"
                    Height="50"
                    Width="50" />
            <Border Background="Purple"
                    Height="50"
                    Width="50" />
        </utu:AutoLayout>
        <utu:AutoLayout Background="Cyan">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,8" />
            <Border Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,8" />
        </utu:AutoLayout>
        <utu:AutoLayout Background="Yellow">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="0,8,0,0" />
            <Border Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="0,0,0,8" />
        </utu:AutoLayout>
        <utu:AutoLayout Background="LightGreen">
            <Border Background="Orange"
                    Height="50"
                    Width="50"
                    Margin="10,8,10,0" />
            <Border Background="Purple"
                    Height="50"
                    Width="50"
                    Margin="10,0,10,8" />
        </utu:AutoLayout>
    </StackPanel>
    
</Grid>

Nuget Package: Uno.Sdk 5.5.32

Affected platform(s): Same behavior on all platform, including Windows

IDE: Microsoft Visual Studio Professional 2022 (64-bit) - Version 17.11.5

@agneszitte agneszitte added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Nov 7, 2024
@agneszitte
Copy link
Contributor Author

@carldebilly I would like your feedback for this "possible" issue as I have some doubts here for the current behavior

@Xiaoy312 Xiaoy312 added control/auto-layout and removed triage/untriaged Indicates an issue requires triaging or verification. labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
control/auto-layout kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants