diff --git a/src/algo.rs b/src/algo.rs
index 4845beae2..717bede6f 100644
--- a/src/algo.rs
+++ b/src/algo.rs
@@ -1128,7 +1128,10 @@ fn compute_internal(
children: result.children,
});
- total_offset_main = offset_main + result.size.main(node.flex_direction) + child.main_margin_end;
+ total_offset_main += child.offset_main
+ + child.main_margin_start
+ + result.size.main(node.flex_direction)
+ + child.main_margin_end;
};
if node.flex_direction.is_reverse() {
diff --git a/test_fixtures/relative_position_should_not_nudge_siblings.html b/test_fixtures/relative_position_should_not_nudge_siblings.html
new file mode 100644
index 000000000..26af1b0bc
--- /dev/null
+++ b/test_fixtures/relative_position_should_not_nudge_siblings.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <script src="../scripts/gentest/test_helper.js"></script>
+ <link rel="stylesheet" type="text/css" href="../scripts/gentest/test_base_style.css">
+ <title>
+ Test description
+ </title>
+<head/>
+<body>
+
+<div id="test-root" style="height: 100px; width: 100px; flex-direction: column;">
+ <div style="top: 15px; height: 10px;"></div>
+ <div style="top: 15px; height: 10px;"></div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/tests/generated.rs b/tests/generated.rs
index 9b2c11c8b..22b9c99f1 100644
--- a/tests/generated.rs
+++ b/tests/generated.rs
@@ -8164,6 +8164,43 @@ mod generated {
assert_eq!(layout.children[0].y, 0.0000);
}
+ #[test]
+ fn relative_position_should_not_nudge_siblings() {
+ let layout = stretch::compute(&stretch::style::Node {
+ flex_direction: stretch::style::FlexDirection::Column,
+ width: stretch::style::Dimension::Points(100.0000),
+ height: stretch::style::Dimension::Points(100.0000),
+ children: vec![
+ stretch::style::Node {
+ height: stretch::style::Dimension::Points(10.0000),
+ top: stretch::style::Dimension::Points(15.0000),
+ ..Default::default()
+ },
+ stretch::style::Node {
+ height: stretch::style::Dimension::Points(10.0000),
+ top: stretch::style::Dimension::Points(15.0000),
+ ..Default::default()
+ },
+ ],
+ ..Default::default()
+ });
+
+ assert_eq!(layout.width, 100.0000);
+ assert_eq!(layout.height, 100.0000);
+ assert_eq!(layout.x, 0.0000);
+ assert_eq!(layout.y, 0.0000);
+
+ assert_eq!(layout.children[0].width, 100.0000);
+ assert_eq!(layout.children[0].height, 10.0000);
+ assert_eq!(layout.children[0].x, 0.0000);
+ assert_eq!(layout.children[0].y, 15.0000);
+
+ assert_eq!(layout.children[1].width, 100.0000);
+ assert_eq!(layout.children[1].height, 10.0000);
+ assert_eq!(layout.children[1].x, 0.0000);
+ assert_eq!(layout.children[1].y, 25.0000);
+ }
+
#[test]
fn justify_content_min_width_with_padding_child_width_greater_than_parent() {
let layout = stretch::compute(&stretch::style::Node {