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
  • Loading branch information
draganescu committed Nov 12, 2024
1 parent 54f5ef2 commit e795e30
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const BlockInspectorSingleBlock = ( {
isSectionBlock,
} ) => {
const availableTabs = useInspectorControlsTabs( blockName );

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

const hasBlockStyles = useSelect(
Expand Down
31 changes: 25 additions & 6 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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';
}

Expand Down Expand Up @@ -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';
}

Expand All @@ -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
Expand Down

0 comments on commit e795e30

Please sign in to comment.