There should be a way to position bevy_ui children independently of parent Flex parameters
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
main: ede5848bf
## What you did
I set the border of a node with a `PositionType::Absolute` child.
## What went wrong
The child's position changed according to the border width, while it shouldn't, as `Absolute` implies.
## Additional information
Click to see Minimal reproducible example
```rust
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, update_border)
.run();
}
#[derive(Component)]
struct UpdateBorder;
fn update_border(
mut q: Query<&mut Style, With>,
input: Res>,
mut expanded: Local,
) {
if !input.just_pressed(KeyCode::Space) { return; }
if let Ok(mut style) = q.get_single_mut() {
let border = if *expanded { 0.0 } else { 10.0 };
style.border = UiRect::all(Val::Px(border));
*expanded = !*expanded;
}
}
fn setup(mut cmds: Commands) {
cmds.spawn(Camera2dBundle::default());
let style = TextStyle { color: Color::BLACK, ..default() };
cmds
.spawn((
NodeBundle {
border_color: Color::RED.into(),
background_color: Color::YELLOW.into(),
style: Style { width: Val::Px(300.0), height: Val::Px(50.0), ..default() },
..default()
},
UpdateBorder,
))
.with_children(|cmds| {
cmds.spawn(TextBundle {
style: Style {
position_type: PositionType::Absolute,
left: Val::Px(0.),
right: Val::Px(0.),
top: Val::Px(0.),
bottom: Val::Px(0.),
..default()
},
..TextBundle::from_section("Bad border!", style)
});
});
}
```


Contributor guide
Research direction
Reproduce the behavior using the setup and update_border entry points in the issue, toggling the border while observing the absolutely positioned child. Trace Bevy's UI Style and layout handling for PositionType::Absolute and border changes. Done means the child no longer shifts when the parent's border width changes, with the minimal example behavior verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- design, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100