<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[55282] trunk: Editor: Add layout controls to children of flex layout blocks.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/55282">55282</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/55282","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>flixos90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-02-07 17:41:11 +0000 (Tue, 07 Feb 2023)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Editor: Add layout controls to children of flex layout blocks.

Props isabel_brison, andrewserong, davidbaumwald, flixos90, mamaduka, ntsekouras, hellofromtonya.
Fixes <a href="https://core.trac.wordpress.org/ticket/57584">#57584</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesblocksupportslayoutphp">trunk/src/wp-includes/block-supports/layout.php</a></li>
<li><a href="#trunktestsphpunitdatablocksfixturescore__columnserverhtml">trunk/tests/phpunit/data/blocks/fixtures/core__column.server.html</a></li>
<li><a href="#trunktestsphpunitdatablocksfixturescore__columnsserverhtml">trunk/tests/phpunit/data/blocks/fixtures/core__columns.server.html</a></li>
<li><a href="#trunktestsphpunitdatablocksfixturescore__columns__deprecatedserverhtml">trunk/tests/phpunit/data/blocks/fixtures/core__columns__deprecated.server.html</a></li>
<li><a href="#trunktestsphpunitdatablocksfixturescore__galleryserverhtml">trunk/tests/phpunit/data/blocks/fixtures/core__gallery.server.html</a></li>
<li><a href="#trunktestsphpunitdatablocksfixturescore__gallery__columnsserverhtml">trunk/tests/phpunit/data/blocks/fixtures/core__gallery__columns.server.html</a></li>
<li><a href="#trunktestsphpunittestsblocksupportslayoutphp">trunk/tests/phpunit/tests/block-supports/layout.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesblocksupportslayoutphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/layout.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/layout.php   2023-02-07 17:40:19 UTC (rev 55281)
+++ trunk/src/wp-includes/block-supports/layout.php     2023-02-07 17:41:11 UTC (rev 55282)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -321,11 +321,54 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_render_layout_support_flag( $block_content, $block ) {
</span><span class="cx" style="display: block; padding: 0 10px">        $block_type     = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
</span><span class="cx" style="display: block; padding: 0 10px">        $support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $has_child_layout = isset( $block['attrs']['style']['layout']['selfStretch'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! $support_layout ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $support_layout && ! $has_child_layout ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $block_content;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $outer_class_names = array();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( $has_child_layout && ( 'fixed' === $block['attrs']['style']['layout']['selfStretch'] || 'fill' === $block['attrs']['style']['layout']['selfStretch'] ) ) {
+               $container_content_class = wp_unique_id( 'wp-container-content-' );
+
+               $child_layout_styles = array();
+
+               if ( 'fixed' === $block['attrs']['style']['layout']['selfStretch'] && 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' === $block['attrs']['style']['layout']['selfStretch'] ) {
+                       $child_layout_styles[] = array(
+                               'selector'     => ".$container_content_class",
+                               'declarations' => array(
+                                       'flex-grow' => '1',
+                               ),
+                       );
+               }
+
+               wp_style_engine_get_stylesheet_from_css_rules(
+                       $child_layout_styles,
+                       array(
+                               'context'  => 'block-supports',
+                               'prettify' => false,
+                       )
+               );
+
+               $outer_class_names[] = $container_content_class;
+       }
+
+       // Return early if only child layout exists.
+       if ( ! $support_layout && ! empty( $outer_class_names ) ) {
+               $content = new WP_HTML_Tag_Processor( $block_content );
+               $content->next_tag();
+               $content->add_class( implode( ' ', $outer_class_names ) );
+               return (string) $content;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         $global_settings               = wp_get_global_settings();
</span><span class="cx" style="display: block; padding: 0 10px">        $block_gap                     = _wp_array_get( $global_settings, array( 'spacing', 'blockGap' ), null );
</span><span class="cx" style="display: block; padding: 0 10px">        $has_block_gap_support         = isset( $block_gap );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -341,7 +384,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $class_names        = array();
</span><span class="cx" style="display: block; padding: 0 10px">        $layout_definitions = _wp_array_get( $global_layout_settings, array( 'definitions' ), array() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $block_classname    = wp_get_block_default_classname( $block['blockName'] );
</del><span class="cx" style="display: block; padding: 0 10px">         $container_class    = wp_unique_id( 'wp-container-' );
</span><span class="cx" style="display: block; padding: 0 10px">        $layout_classname   = '';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -417,7 +459,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $style = wp_get_layout_style(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        ".$block_classname.$container_class",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 ".$container_class.$container_class",
</ins><span class="cx" style="display: block; padding: 0 10px">                         $used_layout,
</span><span class="cx" style="display: block; padding: 0 10px">                        $has_block_gap_support,
</span><span class="cx" style="display: block; padding: 0 10px">                        $gap_value,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -432,18 +474,49 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        /*
-        * This assumes the hook only applies to blocks with a single wrapper.
-        * A limitation of this hook is that nested inner blocks wrappers are not yet supported.
-        */
-       $content = preg_replace(
-               '/' . preg_quote( 'class="', '/' ) . '/',
-               'class="' . esc_attr( implode( ' ', $class_names ) ) . ' ',
-               $block_content,
-               1
-       );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $content_with_outer_classnames = '';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        return $content;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $outer_class_names ) ) {
+               $content_with_outer_classnames = new WP_HTML_Tag_Processor( $block_content );
+               $content_with_outer_classnames->next_tag();
+               foreach ( $outer_class_names as $outer_class_name ) {
+                       $content_with_outer_classnames->add_class( $outer_class_name );
+               }
+
+               $content_with_outer_classnames = (string) $content_with_outer_classnames;
+       }
+
+       /**
+       * The first chunk of innerContent contains the block markup up until the inner blocks start.
+       * This targets the opening tag of the inner blocks wrapper, which is the last tag in that chunk.
+       */
+       $inner_content_classnames = '';
+
+       if ( isset( $block['innerContent'][0] ) && 'string' === gettype( $block['innerContent'][0] ) ) {
+               $tags            = new WP_HTML_Tag_Processor( $block['innerContent'][0] );
+               $last_classnames = '';
+               while ( $tags->next_tag() ) {
+                       $last_classnames = $tags->get_attribute( 'class' );
+               }
+
+               $inner_content_classnames = (string) $last_classnames;
+       }
+
+       $content = $content_with_outer_classnames ? new WP_HTML_Tag_Processor( $content_with_outer_classnames ) : new WP_HTML_Tag_Processor( $block_content );
+
+       if ( $inner_content_classnames ) {
+               $content->next_tag( array( 'class_name' => $inner_content_classnames ) );
+               foreach ( $class_names as $class_name ) {
+                       $content->add_class( $class_name );
+               }
+       } else {
+               $content->next_tag();
+               foreach ( $class_names as $class_name ) {
+                       $content->add_class( $class_name );
+               }
+       }
+
+       return (string) $content;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // Register the block support.
</span></span></pre></div>
<a id="trunktestsphpunitdatablocksfixturescore__columnserverhtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/data/blocks/fixtures/core__column.server.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/blocks/fixtures/core__column.server.html 2023-02-07 17:40:19 UTC (rev 55281)
+++ trunk/tests/phpunit/data/blocks/fixtures/core__column.server.html   2023-02-07 17:41:11 UTC (rev 55282)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,5 +1,5 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div class="is-layout-flow wp-block-column">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<div class="wp-block-column is-layout-flow">
</ins><span class="cx" style="display: block; padding: 0 10px">         
</span><span class="cx" style="display: block; padding: 0 10px">        <p>Column One, Paragraph One</p>
</span><span class="cx" style="display: block; padding: 0 10px">        
</span></span></pre></div>
<a id="trunktestsphpunitdatablocksfixturescore__columnsserverhtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/data/blocks/fixtures/core__columns.server.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/blocks/fixtures/core__columns.server.html        2023-02-07 17:40:19 UTC (rev 55281)
+++ trunk/tests/phpunit/data/blocks/fixtures/core__columns.server.html  2023-02-07 17:41:11 UTC (rev 55282)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,7 +1,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div class="is-layout-flex wp-container-1 wp-block-columns has-3-columns">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<div class="wp-block-columns has-3-columns is-layout-flex wp-container-1">
</ins><span class="cx" style="display: block; padding: 0 10px">         
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <div class="is-layout-flow wp-block-column">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="wp-block-column is-layout-flow">
</ins><span class="cx" style="display: block; padding: 0 10px">                 
</span><span class="cx" style="display: block; padding: 0 10px">                <p>Column One, Paragraph One</p>
</span><span class="cx" style="display: block; padding: 0 10px">                
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,7 +11,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        </div>
</span><span class="cx" style="display: block; padding: 0 10px">        
</span><span class="cx" style="display: block; padding: 0 10px">        
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <div class="is-layout-flow wp-block-column">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="wp-block-column is-layout-flow">
</ins><span class="cx" style="display: block; padding: 0 10px">                 
</span><span class="cx" style="display: block; padding: 0 10px">                <p>Column Two, Paragraph One</p>
</span><span class="cx" style="display: block; padding: 0 10px">                
</span></span></pre></div>
<a id="trunktestsphpunitdatablocksfixturescore__columns__deprecatedserverhtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/data/blocks/fixtures/core__columns__deprecated.server.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/blocks/fixtures/core__columns__deprecated.server.html    2023-02-07 17:40:19 UTC (rev 55281)
+++ trunk/tests/phpunit/data/blocks/fixtures/core__columns__deprecated.server.html      2023-02-07 17:41:11 UTC (rev 55282)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,5 +1,5 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<div class="is-layout-flex wp-container-1 wp-block-columns has-3-columns">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<div class="wp-block-columns has-3-columns is-layout-flex wp-container-1">
</ins><span class="cx" style="display: block; padding: 0 10px">         
</span><span class="cx" style="display: block; padding: 0 10px">        <p class="layout-column-1">Column One, Paragraph One</p>
</span><span class="cx" style="display: block; padding: 0 10px">        
</span></span></pre></div>
<a id="trunktestsphpunitdatablocksfixturescore__galleryserverhtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/data/blocks/fixtures/core__gallery.server.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/blocks/fixtures/core__gallery.server.html        2023-02-07 17:40:19 UTC (rev 55281)
+++ trunk/tests/phpunit/data/blocks/fixtures/core__gallery.server.html  2023-02-07 17:41:11 UTC (rev 55282)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,5 +1,5 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<figure class="is-layout-flex wp-block-gallery has-nested-images columns-default is-cropped columns-2 wp-block-gallery-1">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<figure class="wp-block-gallery has-nested-images columns-default is-cropped columns-2 wp-block-gallery-1 is-layout-flex">
</ins><span class="cx" style="display: block; padding: 0 10px">         
</span><span class="cx" style="display: block; padding: 0 10px">        <figure class="wp-block-image size-large">
</span><span class="cx" style="display: block; padding: 0 10px">                <img src="https://cldup.com/uuUqE_dXzy.jpg" alt="Image gallery image" />
</span></span></pre></div>
<a id="trunktestsphpunitdatablocksfixturescore__gallery__columnsserverhtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/data/blocks/fixtures/core__gallery__columns.server.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/blocks/fixtures/core__gallery__columns.server.html       2023-02-07 17:40:19 UTC (rev 55281)
+++ trunk/tests/phpunit/data/blocks/fixtures/core__gallery__columns.server.html 2023-02-07 17:41:11 UTC (rev 55282)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,5 +1,5 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<figure class="is-layout-flex wp-block-gallery has-nested-images is-cropped columns-1 wp-block-gallery-1" >
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<figure class="wp-block-gallery has-nested-images is-cropped columns-1 wp-block-gallery-1 is-layout-flex" >
</ins><span class="cx" style="display: block; padding: 0 10px">         
</span><span class="cx" style="display: block; padding: 0 10px">        <figure class="wp-block-image size-large">
</span><span class="cx" style="display: block; padding: 0 10px">                <img src="https://cldup.com/uuUqE_dXzy.jpg" alt="Image gallery image" />
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksupportslayoutphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/block-supports/layout.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/layout.php       2023-02-07 17:40:19 UTC (rev 55281)
+++ trunk/tests/phpunit/tests/block-supports/layout.php 2023-02-07 17:41:11 UTC (rev 55282)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -173,4 +173,88 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertSame( $expected, wp_restore_image_outer_container( $block_content, $block ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * @ticket 57584
+        *
+        * @dataProvider data_layout_support_flag_renders_classnames_on_wrapper
+        *
+        * @covers ::wp_render_layout_support_flag
+        *
+        * @param array  $args            Dataset to test.
+        * @param string $expected_output The expected output.
+        */
+       public function test_layout_support_flag_renders_classnames_on_wrapper( $args, $expected_output ) {
+               $actual_output = wp_render_layout_support_flag( $args['block_content'], $args['block'] );
+               $this->assertSame( $expected_output, $actual_output );
+       }
+
+       /**
+        * Data provider for test_layout_support_flag_renders_classnames_on_wrapper.
+        *
+        * @return array
+        */
+       public function data_layout_support_flag_renders_classnames_on_wrapper() {
+               return array(
+                       'single wrapper block layout with flow type'   => array(
+                               'args'            => array(
+                                       'block_content' => '<div class="wp-block-group"></div>',
+                                       'block'         => array(
+                                               'blockName'    => 'core/group',
+                                               'attrs'        => array(
+                                                       'layout' => array(
+                                                               'type' => 'default',
+                                                       ),
+                                               ),
+                                               'innerBlocks'  => array(),
+                                               'innerHTML'    => '<div class="wp-block-group"></div>',
+                                               'innerContent' => array(
+                                                       '<div class="wp-block-group"></div>',
+                                               ),
+                                       ),
+                               ),
+                               'expected_output' => '<div class="wp-block-group is-layout-flow"></div>',
+                       ),
+                       'single wrapper block layout with constrained type' => array(
+                               'args'            => array(
+                                       'block_content' => '<div class="wp-block-group"></div>',
+                                       'block'         => array(
+                                               'blockName'    => 'core/group',
+                                               'attrs'        => array(
+                                                       'layout' => array(
+                                                               'type' => 'constrained',
+                                                       ),
+                                               ),
+                                               'innerBlocks'  => array(),
+                                               'innerHTML'    => '<div class="wp-block-group"></div>',
+                                               'innerContent' => array(
+                                                       '<div class="wp-block-group"></div>',
+                                               ),
+                                       ),
+                               ),
+                               'expected_output' => '<div class="wp-block-group is-layout-constrained"></div>',
+                       ),
+                       'multiple wrapper block layout with flow type' => array(
+                               'args'            => array(
+                                       'block_content' => '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper"></div></div>',
+                                       'block'         => array(
+                                               'blockName'    => 'core/group',
+                                               'attrs'        => array(
+                                                       'layout' => array(
+                                                               'type' => 'default',
+                                                       ),
+                                               ),
+                                               'innerBlocks'  => array(),
+                                               'innerHTML'    => '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper"></div></div>',
+                                               'innerContent' => array(
+                                                       '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper">',
+                                                       ' ',
+                                                       ' </div></div>',
+                                               ),
+                                       ),
+                               ),
+                               'expected_output' => '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper is-layout-flow"></div></div>',
+                       ),
+               );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>