Skip to content

Commit

Permalink
Layout: Fix has-global-padding classname for constrained layouts with…
Browse files Browse the repository at this point in the history
…out content size (#43689)
  • Loading branch information
andrewserong authored Aug 30, 2022
1 parent 132b86c commit 1940bff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
7 changes: 6 additions & 1 deletion packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}

Expand Down

0 comments on commit 1940bff

Please sign in to comment.