diff --git a/src/compute/grid/mod.rs b/src/compute/grid/mod.rs
index 4e691eae5..10d360068 100644
--- a/src/compute/grid/mod.rs
+++ b/src/compute/grid/mod.rs
@@ -449,7 +449,7 @@ pub fn compute(
// Position hidden child
if child_style.display == Display::None {
- *tree.layout_mut(node) = Layout::with_order(order);
+ *tree.layout_mut(child) = Layout::with_order(order);
GenericAlgorithm::perform_layout(
tree,
child,
diff --git a/tests/relayout.rs b/tests/relayout.rs
index 865c21b8e..1f4695127 100644
--- a/tests/relayout.rs
+++ b/tests/relayout.rs
@@ -192,3 +192,95 @@ fn toggle_flex_container_display_none() {
assert_eq!(layout.size.width, 0.0);
assert_eq!(layout.size.height, 0.0);
}
+
+#[test]
+fn toggle_grid_child_display_none() {
+ let hidden_style = Style {
+ display: Display::None,
+ size: Size { width: points(100.0), height: points(100.0) },
+ ..Default::default()
+ };
+
+ let grid_style = Style {
+ display: Display::Grid,
+ size: Size { width: points(100.0), height: points(100.0) },
+ ..Default::default()
+ };
+
+ // Setup
+ let mut taffy = taffy::Taffy::new();
+ let node = taffy.new_leaf(hidden_style.clone()).unwrap();
+ let root = taffy.new_with_children(grid_style.clone(), &[node]).unwrap();
+
+ // Layout 1 (None)
+ taffy.compute_layout(root, Size::MAX_CONTENT).unwrap();
+ let layout = taffy.layout(node).unwrap();
+ assert_eq!(layout.location.x, 0.0);
+ assert_eq!(layout.location.y, 0.0);
+ assert_eq!(layout.size.width, 0.0);
+ assert_eq!(layout.size.height, 0.0);
+
+ // Layout 2 (Flex)
+ taffy.set_style(node, grid_style).unwrap();
+ taffy.compute_layout(root, Size::MAX_CONTENT).unwrap();
+ let layout = taffy.layout(node).unwrap();
+ assert_eq!(layout.location.x, 0.0);
+ assert_eq!(layout.location.y, 0.0);
+ assert_eq!(layout.size.width, 100.0);
+ assert_eq!(layout.size.height, 100.0);
+
+ // Layout 3 (None)
+ taffy.set_style(node, hidden_style).unwrap();
+ taffy.compute_layout(root, Size::MAX_CONTENT).unwrap();
+ let layout = taffy.layout(node).unwrap();
+ assert_eq!(layout.location.x, 0.0);
+ assert_eq!(layout.location.y, 0.0);
+ assert_eq!(layout.size.width, 0.0);
+ assert_eq!(layout.size.height, 0.0);
+}
+
+#[test]
+fn toggle_grid_container_display_none() {
+ let hidden_style = Style {
+ display: Display::None,
+ size: Size { width: points(100.0), height: points(100.0) },
+ ..Default::default()
+ };
+
+ let grid_style = Style {
+ display: Display::Grid,
+ size: Size { width: points(100.0), height: points(100.0) },
+ ..Default::default()
+ };
+
+ // Setup
+ let mut taffy = taffy::Taffy::new();
+ let node = taffy.new_leaf(hidden_style.clone()).unwrap();
+ let root = taffy.new_with_children(hidden_style.clone(), &[node]).unwrap();
+
+ // Layout 1 (None)
+ taffy.compute_layout(root, Size::MAX_CONTENT).unwrap();
+ let layout = taffy.layout(root).unwrap();
+ assert_eq!(layout.location.x, 0.0);
+ assert_eq!(layout.location.y, 0.0);
+ assert_eq!(layout.size.width, 0.0);
+ assert_eq!(layout.size.height, 0.0);
+
+ // Layout 2 (Flex)
+ taffy.set_style(root, grid_style).unwrap();
+ taffy.compute_layout(root, Size::MAX_CONTENT).unwrap();
+ let layout = taffy.layout(root).unwrap();
+ assert_eq!(layout.location.x, 0.0);
+ assert_eq!(layout.location.y, 0.0);
+ assert_eq!(layout.size.width, 100.0);
+ assert_eq!(layout.size.height, 100.0);
+
+ // Layout 3 (None)
+ taffy.set_style(root, hidden_style).unwrap();
+ taffy.compute_layout(root, Size::MAX_CONTENT).unwrap();
+ let layout = taffy.layout(root).unwrap();
+ assert_eq!(layout.location.x, 0.0);
+ assert_eq!(layout.location.y, 0.0);
+ assert_eq!(layout.size.width, 0.0);
+ assert_eq!(layout.size.height, 0.0);
+}