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

Fix core/column not having templateLock inherited from posttype template #17301

Closed
wants to merge 3 commits into from
Closed
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
19 changes: 17 additions & 2 deletions packages/block-library/src/column/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function ColumnEdit( {
setAttributes,
updateAlignment,
hasChildBlocks,
columnsParentLock,
} ) {
const { verticalAlignment, width } = attributes;

Expand Down Expand Up @@ -60,7 +61,11 @@ function ColumnEdit( {
</PanelBody>
</InspectorControls>
<InnerBlocks
templateLock={ false }
// It is safe to set an "inherited" locking explicitly because no
// template is set on the column. If a template was set and parent lock
// was equal to "all" the local template set would be forced and other
// templates passed e.g via CPT would be ignored.
templateLock={ columnsParentLock }
renderAppender={
hasChildBlocks
? undefined
Expand All @@ -79,10 +84,20 @@ function ColumnEdit( {
export default compose(
withSelect( ( select, ownProps ) => {
const { clientId } = ownProps;
const { getBlockOrder } = select( 'core/block-editor' );
const { getBlockOrder, getBlockRootClientId, getTemplateLock } = select(
'core/block-editor'
);

const parentColumnsId = getBlockRootClientId( clientId );
const parentOfColumnsId = getBlockRootClientId( parentColumnsId );
const columnsParentLock = parentOfColumnsId
? getTemplateLock( parentOfColumnsId )
: getTemplateLock();

return {
hasChildBlocks: getBlockOrder( clientId ).length > 0,
columnsParentLock:
columnsParentLock !== undefined ? columnsParentLock : false,
};
} ),
withDispatch( ( dispatch, ownProps, registry ) => {
Expand Down