From 06b52547fca6e75b102ac93f325b1534ee6ac619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Mon, 2 Sep 2019 10:21:13 -0300 Subject: [PATCH 1/3] Fix core/column not having templateLock inherited from posttype template --- packages/block-library/src/column/edit.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/column/edit.js b/packages/block-library/src/column/edit.js index 1664bff4ffeb59..0b35c3a1f15cd2 100644 --- a/packages/block-library/src/column/edit.js +++ b/packages/block-library/src/column/edit.js @@ -23,6 +23,7 @@ function ColumnEdit( { setAttributes, updateAlignment, hasChildBlocks, + parentLock, } ) { const { verticalAlignment, width } = attributes; @@ -60,7 +61,7 @@ function ColumnEdit( { { const { clientId } = ownProps; - const { getBlockOrder } = select( 'core/block-editor' ); + const { getBlockOrder, getBlockRootClientId, getTemplateLock } = select( + 'core/block-editor' + ); + + // Retrieve the parent of the Columns Block. + const rootParentClientId = getBlockRootClientId( + getBlockRootClientId( clientId ) + ); return { hasChildBlocks: getBlockOrder( clientId ).length > 0, + parentLock: getTemplateLock( rootParentClientId ), }; } ), withDispatch( ( dispatch, ownProps, registry ) => { From 82e49da9db99572f4449e9e7030dd8f026127f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Thu, 5 Sep 2019 15:43:02 -0300 Subject: [PATCH 2/3] add inline docs and make code more explicit --- packages/block-library/src/column/edit.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/block-library/src/column/edit.js b/packages/block-library/src/column/edit.js index 0b35c3a1f15cd2..273a2e6ba3a7f9 100644 --- a/packages/block-library/src/column/edit.js +++ b/packages/block-library/src/column/edit.js @@ -23,7 +23,7 @@ function ColumnEdit( { setAttributes, updateAlignment, hasChildBlocks, - parentLock, + columnsParentLock, } ) { const { verticalAlignment, width } = attributes; @@ -61,7 +61,11 @@ function ColumnEdit( { 0, - parentLock: getTemplateLock( rootParentClientId ), + columnsParentLock: getTemplateLock( parentOfColumnsId ), }; } ), withDispatch( ( dispatch, ownProps, registry ) => { From 8697b04899506a6ca314685a7aa53632519caf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Thu, 5 Sep 2019 16:14:33 -0300 Subject: [PATCH 3/3] Fix when editorSettings do not have a default templateLock set --- packages/block-library/src/column/edit.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/column/edit.js b/packages/block-library/src/column/edit.js index 273a2e6ba3a7f9..e815731970d320 100644 --- a/packages/block-library/src/column/edit.js +++ b/packages/block-library/src/column/edit.js @@ -90,10 +90,14 @@ export default compose( const parentColumnsId = getBlockRootClientId( clientId ); const parentOfColumnsId = getBlockRootClientId( parentColumnsId ); + const columnsParentLock = parentOfColumnsId + ? getTemplateLock( parentOfColumnsId ) + : getTemplateLock(); return { hasChildBlocks: getBlockOrder( clientId ).length > 0, - columnsParentLock: getTemplateLock( parentOfColumnsId ), + columnsParentLock: + columnsParentLock !== undefined ? columnsParentLock : false, }; } ), withDispatch( ( dispatch, ownProps, registry ) => {