Skip to content

Commit

Permalink
add contronlling blocks exception only when the context is content only
Browse files Browse the repository at this point in the history
draganescu committed Nov 12, 2024
1 parent 54f5ef2 commit e795e30
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -215,6 +215,7 @@ const BlockInspectorSingleBlock = ( {
isSectionBlock,
} ) => {
const availableTabs = useInspectorControlsTabs( blockName );

const showTabs = ! isSectionBlock && availableTabs?.length > 1;

const hasBlockStyles = useSelect(
31 changes: 25 additions & 6 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
@@ -3046,12 +3046,6 @@ export const getBlockEditingMode = createRegistrySelector(
clientId = '';
}

// All controlling blocks are treated as content only
// by default.
if ( areInnerBlocksControlled( state, clientId ) ) {
return 'contentOnly';
}

// In zoom-out mode, override the behavior set by
// __unstableSetBlockEditingMode to only allow editing the top-level
// sections.
@@ -3074,6 +3068,12 @@ export const getBlockEditingMode = createRegistrySelector(
return 'contentOnly';
}

// All controlling blocks are treated as content only
// by default.
if ( areInnerBlocksControlled( state, clientId ) ) {
return 'contentOnly';
}

return 'disabled';
}

@@ -3113,6 +3113,15 @@ export const getBlockEditingMode = createRegistrySelector(
);
const isContent = hasContentRoleAttribute( name );

// All controlling blocks are treated as content only
// by default.
if (
! isContent &&
areInnerBlocksControlled( state, clientId )
) {
return 'contentOnly';
}

return isContent ? 'contentOnly' : 'disabled';
}

@@ -3136,6 +3145,16 @@ export const getBlockEditingMode = createRegistrySelector(
select( blocksStore )
);
const isContent = hasContentRoleAttribute( name );

// All controlling blocks are treated as content only
// by default.
if (
! isContent &&
areInnerBlocksControlled( state, clientId )
) {
return 'contentOnly';
}

return isContent ? 'contentOnly' : 'disabled';
}
// Otherwise, check if there's an ancestor that is contentOnly

0 comments on commit e795e30

Please sign in to comment.