🐛 Fix z-ordering for flex elements

This commit is contained in:
alonso.torres
2025-11-06 17:33:33 +01:00
parent 0a700864c9
commit 76f6f71e02
2 changed files with 26 additions and 0 deletions

View File

@@ -1472,6 +1472,10 @@ impl RenderState {
// Z-index ordering on Layouts
if element.has_layout() {
if element.is_flex() && !element.is_flex_reverse() {
children_ids.reverse();
}
children_ids.sort_by(|id1, id2| {
let z1 = tree.get(id1).map_or_else(|| 0, |s| s.z_index());
let z2 = tree.get(id2).map_or_else(|| 0, |s| s.z_index());

View File

@@ -328,6 +328,28 @@ impl Shape {
)
}
pub fn is_flex(&self) -> bool {
matches!(
self.shape_type,
Type::Frame(Frame {
layout: Some(layouts::Layout::FlexLayout(_, _)),
..
})
)
}
pub fn is_flex_reverse(&self) -> bool {
matches!(
self.shape_type,
Type::Frame(Frame {
layout: Some(layouts::Layout::FlexLayout(_, FlexData {
direction: layouts::FlexDirection::RowReverse | layouts::FlexDirection::ColumnReverse, ..
})),
..
})
)
}
pub fn set_selrect(&mut self, left: f32, top: f32, right: f32, bottom: f32) {
self.invalidate_bounds();
self.invalidate_extrect();