Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InnerBlocks: fix continuous re-rendering on inner blocks change #58348

Merged
merged 2 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ] );
Copy link
Member Author

Choose a reason for hiding this comment

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

}
Loading