Skip to content

Commit

Permalink
InnerBlocks: fix continuous re-rendering on inner blocks change (#58348)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Jan 27, 2024
1 parent dfa9efd commit 9c030aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
6 changes: 0 additions & 6 deletions packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ function UncontrolledInnerBlocks( props ) {
layout,
name,
blockType,
innerBlocks,
parentLock,
} = props;

Expand All @@ -92,7 +91,6 @@ function UncontrolledInnerBlocks( props ) {

useInnerBlockTemplateSync(
clientId,
innerBlocks,
template,
templateLock,
templateInsertUpdatesSelection
Expand Down Expand Up @@ -193,7 +191,6 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
hasOverlay,
name,
blockType,
innerBlocks,
parentLock,
parentClientId,
isDropZoneDisabled,
Expand All @@ -208,7 +205,6 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
isBlockSelected,
hasSelectedInnerBlock,
__unstableGetEditorMode,
getBlocks,
getTemplateLock,
getBlockRootClientId,
__unstableIsWithinBlockOverlay,
Expand All @@ -234,7 +230,6 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
enableClickThrough,
name: blockName,
blockType: getBlockType( blockName ),
innerBlocks: getBlocks( clientId ),
parentLock: getTemplateLock( _parentClientId ),
parentClientId: _parentClientId,
isDropZoneDisabled:
Expand Down Expand Up @@ -263,7 +258,6 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
layout,
name,
blockType,
innerBlocks,
parentLock,
...options,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,12 @@ function UncontrolledInnerBlocks( props ) {

const context = useBlockContext( clientId );

const { nestingLevel, innerBlocks, parentLock } = useSelect(
const { nestingLevel, parentLock } = useSelect(
( select ) => {
const {
getBlockParents,
getBlocks,
getTemplateLock,
getBlockRootClientId,
} = select( blockEditorStore );
const { getBlockParents, getTemplateLock, getBlockRootClientId } =
select( blockEditorStore );
return {
nestingLevel: getBlockParents( clientId )?.length,
innerBlocks: getBlocks( clientId ),
parentLock: getTemplateLock( getBlockRootClientId( clientId ) ),
};
},
Expand All @@ -139,7 +134,6 @@ function UncontrolledInnerBlocks( props ) {

useInnerBlockTemplateSync(
clientId,
innerBlocks,
template,
templateLock,
templateInsertUpdatesSelection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { store as blockEditorStore } from '../../store';
* then we replace the inner blocks with the correct value after synchronizing it with the template.
*
* @param {string} clientId The block client ID.
* @param {Array} innerBlocks
* @param {Object} template The template to match.
* @param {string} templateLock The template lock state for the inner blocks. For
* example, if the template lock is set to "all",
Expand All @@ -37,7 +36,6 @@ import { store as blockEditorStore } from '../../store';
*/
export default function useInnerBlockTemplateSync(
clientId,
innerBlocks,
template,
templateLock,
templateInsertUpdatesSelection
Expand Down Expand Up @@ -112,5 +110,5 @@ export default function useInnerBlockTemplateSync(
return () => {
isCancelled = true;
};
}, [ innerBlocks, template, templateLock, clientId ] );
}, [ template, templateLock, clientId ] );
}

0 comments on commit 9c030aa

Please sign in to comment.