`Style.overflow` not hidding overflowed nodes
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
- 0.11.0-dev (7d9cb1c4ab210595c5228af0ed4ec7d095241db5)
## What you did
Given
- **Columns:** grey node containers
- **Children:** orange nodes, which are children of the columns
I set it up like:
- Rework example in #7761 to use `gap/padding` to control spacing between columns.
- This removes explicit `width` for columns, and leverages `width: Val::Auto`, `flex_grow: 1.0` & `flex_basis: Val::Px(0.),` which is a way of **splitting columns in equal widths** with flex.
- The columns have `Overflow::hidden` set.
- The children have a **fixed width**.
### Example code
Reproduction code
```rust
use bevy::prelude::*;
use bevy::winit::WinitSettings;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.insert_resource(WinitSettings::desktop_app())
.add_startup_system(spawn)
.run();
}
fn spawn(mut commands: Commands, asset_server: Res) {
commands.spawn(Camera2dBundle::default());
let gap = Val::Px(8.0);
commands
.spawn(NodeBundle {
style: Style {
flex_direction: FlexDirection::Column,
size: Size::new(Val::Percent(100.), Val::Percent(100.)),
gap: Size::all(gap),
padding: UiRect::all(gap),
..Default::default()
},
background_color: Color::BLACK.into(),
..Default::default()
})
.with_children(|parent| {
for _ in 0..2 {
parent
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(50.)),
gap: Size::all(gap),
..default()
},
..default()
})
.with_children(|parent| {
for _ in 0..5 {
parent
.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Auto, Val::Percent(100.)),
overflow: Overflow::Hidden, // <====
flex_grow: 1.0,
flex_basis: Val::Px(0.),
..default()
},
background_color: Color::GRAY.into(),
..default()
})
.with_children(|parent| {
parent.spawn(NodeBundle {
style: Style {
size: Size::new(Val::Px(150.0), Val::Px(30.0)),
..default()
},
background_color: Color::ORANGE.into(),
..default()
});
});
}
});
}
});
}
```
## What went wrong
When the columns **width** is bigger than the children **width**, then everything is OK:

If the window width is changed, columns shrink. When column **width** is smaller than the children **width**, it should overflow. Instead the column width equals the children width. Columns get pushed off-screen.
**NOTE: Here we should see 5 narrow columns.**

## Additional information
- Originally discussed in #7761
- **WORKAROUND**, set `min_size: Size::new(Val::Px(0.), Val::Auto)` in the columns.

Contributor guide
Research direction
Start by running the Rust reproduction code in the issue and compare the layout with and without min_size: Size::new(Val::Px(0.), Val::Auto). Then trace Bevy's UI layout handling for Style overflow, flex sizing, and min_size; done means narrow columns retain their assigned widths and hide the fixed-width children without being pushed off-screen.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100