Skip to content

Commit

Permalink
Fix typing performance issue for container blocks (#46527)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored and fullofcaffeine committed Dec 14, 2022
1 parent ee6097a commit 70e4c14
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { useViewportMatch, useMergeRefs } from '@wordpress/compose';
import { forwardRef } from '@wordpress/element';
import { forwardRef, useMemo } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import {
getBlockSupport,
Expand Down Expand Up @@ -102,6 +102,16 @@ function UncontrolledInnerBlocks( props ) {
const { allowSizingOnChildren = false } =
getBlockSupport( name, '__experimentalLayout' ) || {};

const layout = useMemo(
() => ( {
...__experimentalLayout,
...( allowSizingOnChildren && {
allowSizingOnChildren: true,
} ),
} ),
[ __experimentalLayout, allowSizingOnChildren ]
);

// This component needs to always be synchronous as it's the one changing
// the async mode depending on the block selection.
return (
Expand All @@ -110,12 +120,7 @@ function UncontrolledInnerBlocks( props ) {
rootClientId={ clientId }
renderAppender={ renderAppender }
__experimentalAppenderTagName={ __experimentalAppenderTagName }
__experimentalLayout={ {
...__experimentalLayout,
...( allowSizingOnChildren && {
allowSizingOnChildren: true,
} ),
} }
__experimentalLayout={ layout }
wrapperRef={ wrapperRef }
placeholder={ placeholder }
/>
Expand Down

0 comments on commit 70e4c14

Please sign in to comment.