Skip to content

style.min_size doesn't override max_size on the cross axis #6737

@ickshonpe

Description

@ickshonpe

Bevy version

0.9

What you did

use bevy::prelude::*;

pub fn setup(
    mut commands: Commands,
) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(NodeBundle {
        style: Style {
            min_size: Size::new(Val::Px(100.0), Val::Px(100.0)),
            size: Size::new(Val::Px(50.0), Val::Px(50.0)),
            max_size: Size::new(Val::Px(10.0), Val::Px(10.0)),
            ..Default::default()
        },
        background_color: BackgroundColor(Color::RED),
        ..Default::default()
    });
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

What went wrong

It should draw a 100 x 100 square.
Instead, a 100 wide x 10 tall rectangle is drawn.

Additional information

According to the Flexbox spec, min_size is supposed to override max_size if max_size < min_size.

The problem is with the calculation of the length of the cross-axis, if the Flex direction is set to FlexDirection::Column you get a 10 wide x 100 tall box instead.

related issue: #5502

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorS-BlockedThis cannot move forward until something else changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions