From 1940bff97027180842d3e3551dc88da9c9784885 Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Wed, 31 Aug 2022 06:58:30 +1000 Subject: [PATCH] Layout: Fix has-global-padding classname for constrained layouts without content size (#43689) --- lib/block-supports/layout.php | 3 +-- packages/block-editor/src/hooks/layout.js | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index 2581b986508aa9..5d52a998fadcb7 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -291,14 +291,13 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) { $block_classname = wp_get_block_default_classname( $block['blockName'] ); $container_class = wp_unique_id( 'wp-container-' ); $layout_classname = ''; - $use_global_padding = gutenberg_get_global_settings( array( 'useRootPaddingAwareAlignments' ) ) && ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] ); // Set the correct layout type for blocks using legacy content width. if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] ) { $used_layout['type'] = 'constrained'; } - if ( $use_global_padding ) { + if ( gutenberg_get_global_settings( array( 'useRootPaddingAwareAlignments' ) ) && 'constrained' === $used_layout['type'] ) { $class_names[] = 'has-global-padding'; } diff --git a/packages/block-editor/src/hooks/layout.js b/packages/block-editor/src/hooks/layout.js index c4d4af0b95d4c3..0bc43343a6c288 100644 --- a/packages/block-editor/src/hooks/layout.js +++ b/packages/block-editor/src/hooks/layout.js @@ -63,7 +63,12 @@ function useLayoutClasses( layout, layoutDefinitions ) { ); } - if ( ( layout?.inherit || layout?.contentSize ) && rootPaddingAlignment ) { + if ( + ( layout?.inherit || + layout?.contentSize || + layout?.type === 'constrained' ) && + rootPaddingAlignment + ) { layoutClassnames.push( 'has-global-padding' ); }