diff --git a/packages/block-library/src/block/edit.js b/packages/block-library/src/block/edit.js index ae1cca181561f3..595e3864a987bc 100644 --- a/packages/block-library/src/block/edit.js +++ b/packages/block-library/src/block/edit.js @@ -121,6 +121,12 @@ function getOverridesFromBlocks( blocks, defaultValues ) { /** @type {Record>} */ const overrides = {}; for ( const block of blocks ) { + if ( + block.name === 'core/block' && + getHasOverridableBlocks( block.innerBlocks ) + ) { + continue; + } Object.assign( overrides, getOverridesFromBlocks( block.innerBlocks, defaultValues ) @@ -185,28 +191,37 @@ export default function ReusableBlockEdit( { } = useDispatch( blockEditorStore ); const { syncDerivedUpdates } = unlock( useDispatch( blockEditorStore ) ); - const { innerBlocks, userCanEdit, getBlockEditingMode, getPostLinkProps } = - useSelect( - ( select ) => { - const { canUser } = select( coreStore ); - const { - getBlocks, - getBlockEditingMode: editingMode, - getSettings, - } = select( blockEditorStore ); - const blocks = getBlocks( patternClientId ); - const canEdit = canUser( 'update', 'blocks', ref ); - - // For editing link to the site editor if the theme and user permissions support it. - return { - innerBlocks: blocks, - userCanEdit: canEdit, - getBlockEditingMode: editingMode, - getPostLinkProps: getSettings().getPostLinkProps, - }; - }, - [ patternClientId, ref ] - ); + const { + innerBlocks, + userCanEdit, + getBlockEditingMode, + getPostLinkProps, + hasParentPattern, + } = useSelect( + ( select ) => { + const { canUser } = select( coreStore ); + const { + getBlocks, + getBlockEditingMode: editingMode, + getSettings, + getBlockParentsByBlockName, + } = select( blockEditorStore ); + const blocks = getBlocks( patternClientId ); + const canEdit = canUser( 'update', 'blocks', ref ); + + // For editing link to the site editor if the theme and user permissions support it. + return { + innerBlocks: blocks, + userCanEdit: canEdit, + getBlockEditingMode: editingMode, + getPostLinkProps: getSettings().getPostLinkProps, + hasParentPattern: + getBlockParentsByBlockName( patternClientId, 'core/block' ) + .length > 0, + }; + }, + [ patternClientId, ref ] + ); const editOriginalProps = getPostLinkProps ? getPostLinkProps( { @@ -215,10 +230,14 @@ export default function ReusableBlockEdit( { } ) : {}; - useEffect( - () => setBlockEditMode( setBlockEditingMode, innerBlocks ), - [ innerBlocks, setBlockEditingMode ] - ); + useEffect( () => { + if ( hasParentPattern ) { + setBlockEditMode( setBlockEditingMode, innerBlocks, 'disabled' ); + return; + } + + setBlockEditMode( setBlockEditingMode, innerBlocks ); + }, [ hasParentPattern, innerBlocks, setBlockEditingMode ] ); const hasOverridableBlocks = useMemo( () => getHasOverridableBlocks( innerBlocks ),