From c9a0514b5b760e2956f18662a48bed34e68cd8bd Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Fri, 3 May 2024 16:33:50 +1000 Subject: [PATCH 1/7] Add support for column and row spans in grid children. --- src/wp-includes/block-supports/layout.php | 131 +++++++++++++++++----- src/wp-includes/kses.php | 3 + 2 files changed, 106 insertions(+), 28 deletions(-) diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index f5acd75a72d7c..74c2fe18ad2d6 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -489,7 +489,10 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false $layout_styles[] = array( 'selector' => $selector, - 'declarations' => array( 'grid-template-columns' => 'repeat(auto-fill, minmax(min(' . $minimum_column_width . ', 100%), 1fr))' ), + 'declarations' => array( + 'grid-template-columns' => 'repeat(auto-fill, minmax(min(' . $minimum_column_width . ', 100%), 1fr))', + 'container-type' => 'inline-size', + ), ); } @@ -555,44 +558,97 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false function wp_render_layout_support_flag( $block_content, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); $block_supports_layout = block_has_support( $block_type, 'layout', false ) || block_has_support( $block_type, '__experimentalLayout', false ); - $layout_from_parent = isset( $block['attrs']['style']['layout']['selfStretch'] ) ? $block['attrs']['style']['layout']['selfStretch'] : null; + $child_layout = isset( $block['attrs']['style']['layout'] ) ? $block['attrs']['style']['layout'] : null; - if ( ! $block_supports_layout && ! $layout_from_parent ) { + if ( ! $block_supports_layout && ! $child_layout ) { return $block_content; } - $outer_class_names = array(); + $outer_class_names = array(); + $container_content_class = wp_unique_id( 'wp-container-content-' ); + $child_layout_declarations = array(); + $child_layout_styles = array(); - if ( 'fixed' === $layout_from_parent || 'fill' === $layout_from_parent ) { - $container_content_class = wp_unique_id( 'wp-container-content-' ); + $self_stretch = isset( $child_layout['selfStretch'] ) ? $child_layout['selfStretch'] : null; - $child_layout_styles = array(); + if ( 'fixed' === $self_stretch && isset( $child_layout['flexSize'] ) ) { + $child_layout_declarations['flex-basis'] = $child_layout['flexSize']; + $child_layout_declarations['box-sizing'] = 'border-box'; + } elseif ( 'fill' === $self_stretch ) { + $child_layout_declarations['flex-grow'] = '1'; + } - if ( 'fixed' === $layout_from_parent && isset( $block['attrs']['style']['layout']['flexSize'] ) ) { - $child_layout_styles[] = array( - 'selector' => ".$container_content_class", - 'declarations' => array( - 'flex-basis' => $block['attrs']['style']['layout']['flexSize'], - 'box-sizing' => 'border-box', - ), - ); - } elseif ( 'fill' === $layout_from_parent ) { - $child_layout_styles[] = array( - 'selector' => ".$container_content_class", - 'declarations' => array( - 'flex-grow' => '1', - ), - ); + if ( isset( $child_layout['columnSpan'] ) ) { + $column_span = $child_layout['columnSpan']; + $child_layout_declarations['grid-column'] = "span $column_span"; + } + if ( isset( $child_layout['rowSpan'] ) ) { + $row_span = $child_layout['rowSpan']; + $child_layout_declarations['grid-row'] = "span $row_span"; + } + $child_layout_styles[] = array( + 'selector' => ".$container_content_class", + 'declarations' => $child_layout_declarations, + ); + + /* + * If columnSpan is set, and the parent grid is responsive, i.e. if it has a minimumColumnWidth set, + * the columnSpan should be removed on small grids. If there's a minimumColumnWidth, the grid is responsive. + * But if the minimumColumnWidth value wasn't changed, it won't be set. In that case, if columnCount doesn't + * exist, we can assume that the grid is responsive. + */ + if ( isset( $child_layout['columnSpan'] ) && ( isset( $block['parentLayout']['minimumColumnWidth'] ) || ! isset( $block['parentLayout']['columnCount'] ) ) ) { + $column_span_number = floatval( $child_layout['columnSpan'] ); + $parent_column_width = isset( $block['parentLayout']['minimumColumnWidth'] ) ? $block['parentLayout']['minimumColumnWidth'] : '12rem'; + $parent_column_value = floatval( $parent_column_width ); + $parent_column_unit = explode( $parent_column_value, $parent_column_width ); + + /* + * If there is no unit, the width has somehow been mangled so we reset both unit and value + * to defaults. + * Additionally, the unit should be one of px, rem or em, so that also needs to be checked. + */ + if ( count( $parent_column_unit ) <= 1 ) { + $parent_column_unit = 'rem'; + $parent_column_value = 12; + } else { + $parent_column_unit = $parent_column_unit[1]; + + if ( ! in_array( $parent_column_unit, array( 'px', 'rem', 'em' ), true ) ) { + $parent_column_unit = 'rem'; + } } - wp_style_engine_get_stylesheet_from_css_rules( - $child_layout_styles, - array( - 'context' => 'block-supports', - 'prettify' => false, - ) + /* + * A default gap value is used for this computation because custom gap values may not be + * viable to use in the computation of the container query value. + */ + $default_gap_value = 'px' === $parent_column_unit ? 24 : 1.5; + $container_query_value = $column_span_number * $parent_column_value + ( $column_span_number - 1 ) * $default_gap_value; + $container_query_value = $container_query_value . $parent_column_unit; + + $child_layout_styles[] = array( + 'rules_group' => "@container (max-width: $container_query_value )", + 'selector' => ".$container_content_class", + 'declarations' => array( + 'grid-column' => '1/-1', + ), ); + } + /* + * Add to the style engine store to enqueue and render layout styles. + * Return styles here just to check if any exist. + */ + $child_css = wp_style_engine_get_stylesheet_from_css_rules( + $child_layout_styles, + array( + 'context' => 'block-supports', + 'prettify' => false, + ) + ); + + if ( $child_css ) { $outer_class_names[] = $container_content_class; } @@ -851,6 +907,25 @@ function wp_render_layout_support_flag( $block_content, $block ) { return $processor->get_updated_html(); } +/* + * Add a `render_block_data` filter to fetch the parent block layout data. + */ +add_filter( + 'render_block_data', + function ( $parsed_block, $source_block, $parent_block ) { + /* + * Check if the parent block exists and if it has a layout attribute. + * If it does, add the parent layout to the parsed block. + */ + if ( $parent_block && isset( $parent_block->parsed_block['attrs']['layout'] ) ) { + $parsed_block['parentLayout'] = $parent_block->parsed_block['attrs']['layout']; + } + return $parsed_block; + }, + 10, + 3 +); + // Register the block support. WP_Block_Supports::get_instance()->register( 'layout', diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index cccb1768c2dfd..05a7274f94884 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -2441,11 +2441,13 @@ function safecss_filter_attr( $css, $deprecated = '' ) { 'grid-auto-columns', 'grid-column-start', 'grid-column-end', + 'grid-column', 'grid-column-gap', 'grid-template-rows', 'grid-auto-rows', 'grid-row-start', 'grid-row-end', + 'grid-row', 'grid-row-gap', 'grid-gap', @@ -2475,6 +2477,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) { 'z-index', 'box-shadow', 'aspect-ratio', + 'container-type', // Custom CSS properties. '--*', From 66a06921dbc092686af9f1eef4301a4529207824 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Tue, 7 May 2024 16:56:34 +1000 Subject: [PATCH 2/7] Check child layout exists before generating classname. --- src/wp-includes/block-supports/layout.php | 150 +++++++++++----------- 1 file changed, 77 insertions(+), 73 deletions(-) diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index 74c2fe18ad2d6..72303e0a078e4 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -564,92 +564,96 @@ function wp_render_layout_support_flag( $block_content, $block ) { return $block_content; } - $outer_class_names = array(); - $container_content_class = wp_unique_id( 'wp-container-content-' ); - $child_layout_declarations = array(); - $child_layout_styles = array(); - - $self_stretch = isset( $child_layout['selfStretch'] ) ? $child_layout['selfStretch'] : null; - - if ( 'fixed' === $self_stretch && isset( $child_layout['flexSize'] ) ) { - $child_layout_declarations['flex-basis'] = $child_layout['flexSize']; - $child_layout_declarations['box-sizing'] = 'border-box'; - } elseif ( 'fill' === $self_stretch ) { - $child_layout_declarations['flex-grow'] = '1'; - } + $outer_class_names = array(); - if ( isset( $child_layout['columnSpan'] ) ) { - $column_span = $child_layout['columnSpan']; - $child_layout_declarations['grid-column'] = "span $column_span"; - } - if ( isset( $child_layout['rowSpan'] ) ) { - $row_span = $child_layout['rowSpan']; - $child_layout_declarations['grid-row'] = "span $row_span"; - } - $child_layout_styles[] = array( - 'selector' => ".$container_content_class", - 'declarations' => $child_layout_declarations, - ); + // Child layout specific logic. + if ( $child_layout ) { + $container_content_class = wp_unique_id( 'wp-container-content-' ); + $child_layout_declarations = array(); + $child_layout_styles = array(); - /* - * If columnSpan is set, and the parent grid is responsive, i.e. if it has a minimumColumnWidth set, - * the columnSpan should be removed on small grids. If there's a minimumColumnWidth, the grid is responsive. - * But if the minimumColumnWidth value wasn't changed, it won't be set. In that case, if columnCount doesn't - * exist, we can assume that the grid is responsive. - */ - if ( isset( $child_layout['columnSpan'] ) && ( isset( $block['parentLayout']['minimumColumnWidth'] ) || ! isset( $block['parentLayout']['columnCount'] ) ) ) { - $column_span_number = floatval( $child_layout['columnSpan'] ); - $parent_column_width = isset( $block['parentLayout']['minimumColumnWidth'] ) ? $block['parentLayout']['minimumColumnWidth'] : '12rem'; - $parent_column_value = floatval( $parent_column_width ); - $parent_column_unit = explode( $parent_column_value, $parent_column_width ); + $self_stretch = isset( $child_layout['selfStretch'] ) ? $child_layout['selfStretch'] : null; + + if ( 'fixed' === $self_stretch && isset( $child_layout['flexSize'] ) ) { + $child_layout_declarations['flex-basis'] = $child_layout['flexSize']; + $child_layout_declarations['box-sizing'] = 'border-box'; + } elseif ( 'fill' === $self_stretch ) { + $child_layout_declarations['flex-grow'] = '1'; + } + + if ( isset( $child_layout['columnSpan'] ) ) { + $column_span = $child_layout['columnSpan']; + $child_layout_declarations['grid-column'] = "span $column_span"; + } + if ( isset( $child_layout['rowSpan'] ) ) { + $row_span = $child_layout['rowSpan']; + $child_layout_declarations['grid-row'] = "span $row_span"; + } + $child_layout_styles[] = array( + 'selector' => ".$container_content_class", + 'declarations' => $child_layout_declarations, + ); /* - * If there is no unit, the width has somehow been mangled so we reset both unit and value - * to defaults. - * Additionally, the unit should be one of px, rem or em, so that also needs to be checked. + * If columnSpan is set, and the parent grid is responsive, i.e. if it has a minimumColumnWidth set, + * the columnSpan should be removed on small grids. If there's a minimumColumnWidth, the grid is responsive. + * But if the minimumColumnWidth value wasn't changed, it won't be set. In that case, if columnCount doesn't + * exist, we can assume that the grid is responsive. */ - if ( count( $parent_column_unit ) <= 1 ) { - $parent_column_unit = 'rem'; - $parent_column_value = 12; - } else { - $parent_column_unit = $parent_column_unit[1]; + if ( isset( $child_layout['columnSpan'] ) && ( isset( $block['parentLayout']['minimumColumnWidth'] ) || ! isset( $block['parentLayout']['columnCount'] ) ) ) { + $column_span_number = floatval( $child_layout['columnSpan'] ); + $parent_column_width = isset( $block['parentLayout']['minimumColumnWidth'] ) ? $block['parentLayout']['minimumColumnWidth'] : '12rem'; + $parent_column_value = floatval( $parent_column_width ); + $parent_column_unit = explode( $parent_column_value, $parent_column_width ); + + /* + * If there is no unit, the width has somehow been mangled so we reset both unit and value + * to defaults. + * Additionally, the unit should be one of px, rem or em, so that also needs to be checked. + */ + if ( count( $parent_column_unit ) <= 1 ) { + $parent_column_unit = 'rem'; + $parent_column_value = 12; + } else { + $parent_column_unit = $parent_column_unit[1]; - if ( ! in_array( $parent_column_unit, array( 'px', 'rem', 'em' ), true ) ) { - $parent_column_unit = 'rem'; + if ( ! in_array( $parent_column_unit, array( 'px', 'rem', 'em' ), true ) ) { + $parent_column_unit = 'rem'; + } } + + /* + * A default gap value is used for this computation because custom gap values may not be + * viable to use in the computation of the container query value. + */ + $default_gap_value = 'px' === $parent_column_unit ? 24 : 1.5; + $container_query_value = $column_span_number * $parent_column_value + ( $column_span_number - 1 ) * $default_gap_value; + $container_query_value = $container_query_value . $parent_column_unit; + + $child_layout_styles[] = array( + 'rules_group' => "@container (max-width: $container_query_value )", + 'selector' => ".$container_content_class", + 'declarations' => array( + 'grid-column' => '1/-1', + ), + ); } /* - * A default gap value is used for this computation because custom gap values may not be - * viable to use in the computation of the container query value. + * Add to the style engine store to enqueue and render layout styles. + * Return styles here just to check if any exist. */ - $default_gap_value = 'px' === $parent_column_unit ? 24 : 1.5; - $container_query_value = $column_span_number * $parent_column_value + ( $column_span_number - 1 ) * $default_gap_value; - $container_query_value = $container_query_value . $parent_column_unit; - - $child_layout_styles[] = array( - 'rules_group' => "@container (max-width: $container_query_value )", - 'selector' => ".$container_content_class", - 'declarations' => array( - 'grid-column' => '1/-1', - ), + $child_css = wp_style_engine_get_stylesheet_from_css_rules( + $child_layout_styles, + array( + 'context' => 'block-supports', + 'prettify' => false, + ) ); - } - /* - * Add to the style engine store to enqueue and render layout styles. - * Return styles here just to check if any exist. - */ - $child_css = wp_style_engine_get_stylesheet_from_css_rules( - $child_layout_styles, - array( - 'context' => 'block-supports', - 'prettify' => false, - ) - ); - - if ( $child_css ) { - $outer_class_names[] = $container_content_class; + if ( $child_css ) { + $outer_class_names[] = $container_content_class; + } } // Prep the processor for modifying the block output. From ed8549d51a131ad4f3e5787c2ba3593e310d6852 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Tue, 7 May 2024 17:01:46 +1000 Subject: [PATCH 3/7] Add a test for child layout classes --- tests/phpunit/tests/block-supports/layout.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index a5f67f50f9b11..85cda9f9d51ca 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -181,6 +181,7 @@ public function test_outer_container_not_restored_for_aligned_image_block_with_t * @param string $expected_output The expected output. */ public function test_layout_support_flag_renders_classnames_on_wrapper( $args, $expected_output ) { + switch_theme( 'default' ); $actual_output = wp_render_layout_support_flag( $args['block_content'], $args['block'] ); $this->assertSame( $expected_output, $actual_output ); } @@ -251,6 +252,27 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() { ), 'expected_output' => '
', ), + 'block with child layout' => array( + 'args' => array( + 'block_content' => '

Some text.

', + 'block' => array( + 'blockName' => 'core/paragraph', + 'attrs' => array( + 'style' => array( + 'layout' => array( + 'columnSpan' => '2', + ), + ), + ), + 'innerBlocks' => array(), + 'innerHTML' => '

Some text.

', + 'innerContent' => array( + '

Some text.

', + ), + ), + ), + 'expected_output' => '

Some text.

', // The generated classname number assumes `wp_unique_id` will not have run previously in this test. + ), 'skip classname output if block does not support layout and there are no child layout classes to be output' => array( 'args' => array( 'block_content' => '

A paragraph

', From 0b97584c5850bca54466a8039f3a2dd27dc1b5de Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Wed, 8 May 2024 10:23:52 +1000 Subject: [PATCH 4/7] Use `wp_unique_prefixed_id` instead of `wp_unique_id` --- src/wp-includes/block-supports/layout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index 72303e0a078e4..057cc8b75b181 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -568,7 +568,7 @@ function wp_render_layout_support_flag( $block_content, $block ) { // Child layout specific logic. if ( $child_layout ) { - $container_content_class = wp_unique_id( 'wp-container-content-' ); + $container_content_class = wp_unique_prefixed_id( 'wp-container-content-' ); $child_layout_declarations = array(); $child_layout_styles = array(); From e0c0cbaf9793c547f1d7ea30394b04fa75ef32c9 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Thu, 9 May 2024 14:29:08 +1000 Subject: [PATCH 5/7] Convert filter to named function. --- src/wp-includes/block-supports/layout.php | 36 ++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index 057cc8b75b181..f5ba43fb52dd7 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -911,24 +911,26 @@ function wp_render_layout_support_flag( $block_content, $block ) { return $processor->get_updated_html(); } -/* - * Add a `render_block_data` filter to fetch the parent block layout data. +/** + * Check if the parent block exists and if it has a layout attribute. + * If it does, add the parent layout to the parsed block + * + * @since 6.6.0 + * @access private + * + * @param array $parsed_block The parsed block. + * @param array $source_block The source block. + * @param array $parent_block The parent block. + * @return array The parsed block with parent layout attribute if it exists. */ -add_filter( - 'render_block_data', - function ( $parsed_block, $source_block, $parent_block ) { - /* - * Check if the parent block exists and if it has a layout attribute. - * If it does, add the parent layout to the parsed block. - */ - if ( $parent_block && isset( $parent_block->parsed_block['attrs']['layout'] ) ) { - $parsed_block['parentLayout'] = $parent_block->parsed_block['attrs']['layout']; - } - return $parsed_block; - }, - 10, - 3 -); +function wp_add_parent_layout_to_parsed_block( $parsed_block, $source_block, $parent_block ) { + if ( $parent_block && isset( $parent_block->parsed_block['attrs']['layout'] ) ) { + $parsed_block['parentLayout'] = $parent_block->parsed_block['attrs']['layout']; + } + return $parsed_block; +} + +add_filter( 'render_block_data', 'wp_add_parent_layout_to_parsed_block', 10, 3 ); // Register the block support. WP_Block_Supports::get_instance()->register( From 81a54f5e70864dbdde36d7aa4dc5d2d23f3efb69 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Thu, 9 May 2024 14:33:33 +1000 Subject: [PATCH 6/7] Update comment and ticket annotation. --- tests/phpunit/tests/block-supports/layout.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index 85cda9f9d51ca..2dd6f34ec0619 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -172,6 +172,7 @@ public function test_outer_container_not_restored_for_aligned_image_block_with_t * @ticket 57584 * @ticket 58548 * @ticket 60292 + * @ticket 61111 * * @dataProvider data_layout_support_flag_renders_classnames_on_wrapper * @@ -271,7 +272,7 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() { ), ), ), - 'expected_output' => '

Some text.

', // The generated classname number assumes `wp_unique_id` will not have run previously in this test. + 'expected_output' => '

Some text.

', // The generated classname number assumes `wp_unique_prefixed_id( 'wp-container-content-' )` will not have run previously in this test. ), 'skip classname output if block does not support layout and there are no child layout classes to be output' => array( 'args' => array( From 0926acfd2dff902555289449f8d5da74c05a9329 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Fri, 10 May 2024 17:52:57 +1000 Subject: [PATCH 7/7] Add unit test for `wp_add_parent_layout_to_parsed_block` --- src/wp-includes/block-supports/layout.php | 6 +- tests/phpunit/tests/block-supports/layout.php | 77 +++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index f5ba43fb52dd7..9df5137e8902d 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -918,9 +918,9 @@ function wp_render_layout_support_flag( $block_content, $block ) { * @since 6.6.0 * @access private * - * @param array $parsed_block The parsed block. - * @param array $source_block The source block. - * @param array $parent_block The parent block. + * @param array $parsed_block The parsed block. + * @param array $source_block The source block. + * @param WP_Block $parent_block The parent block. * @return array The parsed block with parent layout attribute if it exists. */ function wp_add_parent_layout_to_parsed_block( $parsed_block, $source_block, $parent_block ) { diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index 2dd6f34ec0619..d0f78a8fd9d2b 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -385,4 +385,81 @@ public function data_restore_group_inner_container() { ), ); } + + /** + * Checks that `wp_add_parent_layout_to_parsed_block` adds the parent layout attribute to the block object. + * + * @ticket 61111 + * + * @covers ::wp_add_parent_layout_to_parsed_block + * + * @dataProvider data_wp_add_parent_layout_to_parsed_block + * + * @param array $block The block object. + * @param WP_Block $parent_block The parent block object. + * @param array $expected The expected block object. + */ + public function test_wp_add_parent_layout_to_parsed_block( $block, $parent_block, $expected ) { + $actual = wp_add_parent_layout_to_parsed_block( $block, array(), $parent_block ); + $this->assertSame( $expected, $actual ); + } + + /** + * Data provider for test_wp_add_parent_layout_to_parsed_block. + * + * @return array + */ + public function data_wp_add_parent_layout_to_parsed_block() { + return array( + 'block with no parent layout' => array( + 'block' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + ), + 'parent_block' => array(), + 'expected' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + ), + ), + 'block with parent layout' => array( + 'block' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + ), + 'parent_block' => new WP_Block( + array( + 'attrs' => array( + 'layout' => array( + 'type' => 'grid', + ), + ), + ) + ), + 'expected' => array( + 'blockName' => 'core/group', + 'attrs' => array( + 'layout' => array( + 'type' => 'default', + ), + ), + 'parentLayout' => array( + 'type' => 'grid', + ), + ), + ), + ); + } }