From 4136c820362e4f15992c1a1c696adc63c96d1237 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Wed, 11 Nov 2026 15:28:06 +1100 Subject: [PATCH] Ensure canvas cells are always square --- src/wp-includes/block-supports/layout.php | 9 ++++++++- tests/phpunit/tests/block-supports/layout.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index 855b01764d169..a71e6df6485c4 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -976,7 +976,14 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false if ( $should_output_grid_rows ) { $layout_styles[] = array( 'selector' => $selector, - 'declarations' => array( 'grid-template-rows' => 'repeat(' . $row_count . ', minmax(1rem, auto))' ), + /* + * The aspect ratio gives empty rows a height, so cells are roughly square. + * Rows still grow if their content is taller. + */ + 'declarations' => array( + 'grid-template-rows' => 'repeat(' . $row_count . ', minmax(1rem, 1fr))', + 'aspect-ratio' => $column_count . ' / ' . $row_count, + ), ); } diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index c1c121c9e2102..43e460bec73be 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -1658,7 +1658,7 @@ public function test_get_layout_style_with_numeric_string_grid_counts() { ); $this->assertSame( - '.wp-layout{grid-template-columns:repeat(3, minmax(0, 1fr));grid-template-rows:repeat(2, minmax(1rem, auto));}', + '.wp-layout{grid-template-columns:repeat(3, minmax(0, 1fr));grid-template-rows:repeat(2, minmax(1rem, 1fr));aspect-ratio:3 / 2;}', $layout_styles ); }