Skip to content

Commit

Permalink
Block Editor: Optimize 'Layout' controls (#55754)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Nov 1, 2023
1 parent 0e88a53 commit 995e790
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

1 comment on commit 995e790

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 995e790.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6718261661
📝 Reported issues:

Please sign in to comment.