Skip to content

Commit

Permalink
Block Editor: Optimize 'Layout' controls (WordPress#55754)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored and masperber committed Nov 1, 2023
1 parent ab72fc9 commit a5ef6cd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
}, [] );
const blockEditingMode = useBlockEditingMode();

if ( blockEditingMode !== 'default' ) {
return null;
}

const layoutBlockSupport = getBlockSupport(
blockName,
layoutBlockSupportKey,
Expand Down Expand Up @@ -270,7 +274,7 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
) }
</PanelBody>
</InspectorControls>
{ ! inherit && blockEditingMode === 'default' && layoutType && (
{ ! inherit && layoutType && (
<layoutType.toolBarControls
layout={ usedLayout }
onChange={ onChangeLayout }
Expand Down Expand Up @@ -331,14 +335,10 @@ export function addAttribute( settings ) {
*/
export const withInspectorControls = createHigherOrderComponent(
( BlockEdit ) => ( props ) => {
const { name: blockName } = props;
const supportLayout = hasLayoutBlockSupport( blockName );
const supportLayout = hasLayoutBlockSupport( props.name );

const blockEditingMode = useBlockEditingMode();
return [
supportLayout && blockEditingMode === 'default' && (
<LayoutPanel key="layout" { ...props } />
),
supportLayout && <LayoutPanel key="layout" { ...props } />,
<BlockEdit key="edit" { ...props } />,
];
},
Expand Down

0 comments on commit a5ef6cd

Please sign in to comment.