From 36320762f4fcf34e05d1c1b7b03b7fc54f5c283b Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Fri, 3 Feb 2023 01:35:06 +0000 Subject: [PATCH] change the default `width` and `height` of `Size` to `Val::Auto` (#7475) # Objective In CSS Flexbox width and height are auto by default, whereas in Bevy their default is `Size::Undefined`. This means that, unlike in CSS, if you elide a height or width value for a node it will be given zero length (unless it has an explicitly sized child node). This has misled users into falsely assuming that they have to explicitly set a value for both height and width all the time. relevant issue: #7120 ## Solution Change the `Size` `width` and `height` default values to `Val::Auto` ## Changelog * Changed the `Size` `width` and `height` default values to `Val::Auto` ## Migration Guide The default values for `Size` `width` and `height` have been changed from `Val::Undefined` to `Val::Auto`. It's unlikely to cause any issues with existing code. --- crates/bevy_ui/src/geometry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ui/src/geometry.rs b/crates/bevy_ui/src/geometry.rs index 8fe46fae47daa..8f80c346e5682 100644 --- a/crates/bevy_ui/src/geometry.rs +++ b/crates/bevy_ui/src/geometry.rs @@ -339,7 +339,7 @@ pub struct Size { } impl Size { - pub const DEFAULT: Self = Self::all(Val::DEFAULT); + pub const DEFAULT: Self = Self::all(Val::Auto); /// Creates a new [`Size`] from a width and a height. ///