diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index 3ba5aca6a35c6d..dee0e654c43c65 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -103,14 +103,26 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support */ if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) { $style .= "justify-content: {$justify_content_options[ $layout['justifyContent'] ]};"; - // --justification-setting allows children to inherit the value regardless or row or column direction. - $style .= "--justification-setting: {$justify_content_options[ $layout['justifyContent'] ]};"; + if ( ! empty( $layout['setCascadingProperties'] ) && $layout['setCascadingProperties'] ) { + // --layout-justification-setting allows children to inherit the value regardless or row or column direction. + $style .= "--layout-justification-setting: {$justify_content_options[ $layout['justifyContent'] ]};"; + $style .= '--layout-direction: row;'; + $style .= "--layout-wrap: $flex_wrap;"; + $style .= "--layout-justify: {$justify_content_options[ $layout['justifyContent'] ]};"; + $style .= '--layout-align: center;'; + } } } else { $style .= 'flex-direction: column;'; if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) { $style .= "align-items: {$justify_content_options[ $layout['justifyContent'] ]};"; - $style .= "--justification-setting: {$justify_content_options[ $layout['justifyContent'] ]};"; + if ( ! empty( $layout['setCascadingProperties'] ) && $layout['setCascadingProperties'] ) { + // --layout-justification-setting allows children to inherit the value regardless or row or column direction. + $style .= "--layout-justification-setting: {$justify_content_options[ $layout['justifyContent'] ]};"; + $style .= '--layout-direction: column;'; + $style .= '--layout-justify: initial;'; + $style .= "--layout-align: {$justify_content_options[ $layout['justifyContent'] ]};"; + } } } $style .= '}'; diff --git a/packages/block-editor/src/layouts/flex.js b/packages/block-editor/src/layouts/flex.js index c929a67440b7a2..968e7694db634d 100644 --- a/packages/block-editor/src/layouts/flex.js +++ b/packages/block-editor/src/layouts/flex.js @@ -85,7 +85,10 @@ export default { ); }, save: function FlexLayoutStyle( { selector, layout } ) { - const { orientation = 'horizontal' } = layout; + const { + orientation = 'horizontal', + setCascadingProperties = false, + } = layout; const blockGapSupport = useSetting( 'spacing.blockGap' ); const hasBlockGapStylesSupport = blockGapSupport !== null; const justifyContent = @@ -94,21 +97,36 @@ export default { const flexWrap = flexWrapOptions.includes( layout.flexWrap ) ? layout.flexWrap : 'wrap'; - // --justification-setting allows children to inherit the value - // regardless or row or column direction. - const rowOrientation = ` + let rowOrientation = ` flex-direction: row; align-items: center; justify-content: ${ justifyContent }; - --justification-setting: ${ justifyContent }; `; + if ( setCascadingProperties ) { + // --layout-justification-setting allows children to inherit the value + // regardless or row or column direction. + rowOrientation += ` + --layout-justification-setting: ${ justifyContent }; + --layout-direction: row; + --layout-wrap: ${ flexWrap }; + --layout-justify: ${ justifyContent }; + --layout-align: center; + `; + } const alignItems = alignItemsMap[ layout.justifyContent ] || alignItemsMap.left; - const columnOrientation = ` + let columnOrientation = ` flex-direction: column; align-items: ${ alignItems }; - --justification-setting: ${ alignItems }; `; + if ( setCascadingProperties ) { + columnOrientation += ` + --layout-justification-setting: ${ alignItems }; + --layout-direction: column; + --layout-justify: initial; + --layout-align: ${ alignItems }; + `; + } return (