Skip to content

Commit

Permalink
Layout: Fix toggling off inner blocks content width setting for legac…
Browse files Browse the repository at this point in the history
…y markup (#43888)

* Layout: Fix toggling off inner blocks content width setting for legacy markup

* Move common checks to a const
  • Loading branch information
andrewserong committed Sep 8, 2022
1 parent f1ceba2 commit fa80a98
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/block-editor/src/hooks/layout.js
Expand Up @@ -143,11 +143,10 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
return null;
}
const layoutType = getLayoutType( type );

const constrainedType = getLayoutType( 'constrained' );

const displayControlsForLegacyLayouts =
! usedLayout.type && ( contentSize || inherit );
const hasContentSizeOrLegacySettings = !! inherit || !! contentSize;

const onChangeType = ( newType ) =>
setAttributes( { layout: { type: newType } } );
Expand All @@ -164,23 +163,23 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
label={ __( 'Inner blocks use content width' ) }
checked={
layoutType?.name === 'constrained' ||
!! inherit ||
!! contentSize
hasContentSizeOrLegacySettings
}
onChange={ () =>
setAttributes( {
layout: {
type:
layoutType?.name ===
'constrained'
'constrained' ||
hasContentSizeOrLegacySettings
? 'default'
: 'constrained',
},
} )
}
help={
!! inherit ||
layoutType?.name === 'constrained'
layoutType?.name === 'constrained' ||
hasContentSizeOrLegacySettings
? __(
'Nested blocks use content width with options for full and wide widths.'
)
Expand Down

0 comments on commit fa80a98

Please sign in to comment.