Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/wp-includes/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
Loading