Skip to content
Merged
Show file tree
Hide file tree
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
42 changes: 12 additions & 30 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ function StyleInspectorSlots( {
function BlockInspector() {
const {
selectedBlockCount,
selectedBlockClientId,
renderedBlockName,
renderedBlockClientId,
blockType,
Expand Down Expand Up @@ -119,7 +118,6 @@ function BlockInspector() {

return {
selectedBlockCount: getSelectedBlockCount(),
selectedBlockClientId: _selectedBlockClientId,
renderedBlockClientId: _renderedBlockClientId,
renderedBlockName: _renderedBlockName,
blockType: _blockType,
Expand Down Expand Up @@ -257,7 +255,6 @@ function BlockInspector() {
>
<BlockInspectorSingleBlock
renderedBlockClientId={ renderedBlockClientId }
selectedBlockClientId={ selectedBlockClientId }
blockName={ blockType.name }
isSectionBlock={ isSectionBlock }
availableTabs={ availableTabs }
Expand Down Expand Up @@ -309,10 +306,6 @@ const BlockInspectorSingleBlock = ( {
// The block that is displayed in the inspector. This is the block whose
// controls and information are shown to the user.
renderedBlockClientId,
// The actual block that is selected in the editor. This may or may not
// be the same as the rendered block (e.g., when a child block is selected
// but its parent section block is the main one rendered in the inspector).
selectedBlockClientId,
blockName,
isSectionBlock,
availableTabs,
Expand All @@ -332,10 +325,6 @@ const BlockInspectorSingleBlock = ( {
renderedBlockClientId
);
const isBlockSynced = blockInformation.isSynced;
const shouldShowTabs = ! isBlockSynced && hasMultipleTabs;
const isSectionBlockSelected =
window?.__experimentalContentOnlyPatternInsertion &&
selectedBlockClientId === renderedBlockClientId;

return (
<div className="block-editor-block-inspector">
Expand All @@ -358,17 +347,19 @@ const BlockInspectorSingleBlock = ( {
<EditContents clientId={ renderedBlockClientId } />
) }
<BlockVariationTransforms blockClientId={ renderedBlockClientId } />
{ shouldShowTabs && (
<InspectorControlsTabs
hasBlockStyles={ hasBlockStyles }
clientId={ renderedBlockClientId }
blockName={ blockName }
tabs={ availableTabs }
isSectionBlock={ isSectionBlock }
contentClientIds={ contentClientIds }
/>
{ hasMultipleTabs && (
<>
<InspectorControlsTabs
hasBlockStyles={ hasBlockStyles }
clientId={ renderedBlockClientId }
blockName={ blockName }
tabs={ availableTabs }
isSectionBlock={ isSectionBlock }
contentClientIds={ contentClientIds }
/>
</>
) }
{ ! shouldShowTabs && (
{ ! hasMultipleTabs && (
<>
{ hasBlockStyles && (
<BlockStyles clientId={ renderedBlockClientId } />
Expand All @@ -379,15 +370,6 @@ const BlockInspectorSingleBlock = ( {
{ ! isSectionBlock && (
<StyleInspectorSlots blockName={ blockName } />
) }
{ isSectionBlock &&
isBlockSynced &&
isSectionBlockSelected && (
<>
<InspectorControls.Slot />
{ /* Allow AdvancedControls so users can adjust local attributes (e.g. additional CSS classes, HTML element). */ }
<AdvancedControls />
</>
) }
</>
) }
<SkipToSelectedBlock key="back" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ export default function useInspectorControlsTabs(
}

if (
( settingsFills.length ||
// Advanded fills who up in settings tab if available or they blend into the default tab, if there's only one tab.
( advancedFills.length && ( hasContentTab || hasListFills ) ) ) &&
! isSectionBlock
settingsFills.length ||
// Advanced fills show up in settings tab if available or they blend into the default tab, if there's only one tab.
( advancedFills.length && ( hasContentTab || hasListFills ) )
) {
tabs.push( TAB_SETTINGS );
}
Expand Down
30 changes: 25 additions & 5 deletions packages/block-editor/src/components/inspector-controls/fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import {
} from '../block-edit/context';
import groups from './groups';

const PATTERN_EDITING_GROUPS = [ 'content', 'list' ];
const TEMPLATE_PART_GROUPS = [ 'default', 'settings', 'advanced' ];

export default function InspectorControlsFill( {
children,
group = 'default',
Expand All @@ -43,13 +46,30 @@ export default function InspectorControlsFill( {
warning( `Unknown InspectorControls group "${ group }" provided.` );
return null;
}
const shouldDisplayForPatternEditing =
context[ mayDisplayPatternEditingControlsKey ] &&
( group === 'list' || group === 'content' );

// During pattern editing:
// - All blocks can show pattern editing groups (content, list).
// - Template parts can show a settings tab (default, settings, advanced groups).
// - Other blocks cannot show a settings tab.
if ( context[ mayDisplayPatternEditingControlsKey ] ) {
// Template parts are allowed to show a settings tab to allow access to the
// 'Design' and 'Advanced' panels.
const isTemplatePart = context.name === 'core/template-part';
const isTemplatePartGroup = TEMPLATE_PART_GROUPS.includes( group );
const isPatternEditingGroup = PATTERN_EDITING_GROUPS.includes( group );

const canShowGroup =
( isTemplatePart && isTemplatePartGroup ) || isPatternEditingGroup;

if ( ! canShowGroup ) {
return null;
}
}

// Outside pattern editing, use the standard rules for displaying controls.
if (
! context[ mayDisplayControlsKey ] &&
! shouldDisplayForPatternEditing
! context[ mayDisplayPatternEditingControlsKey ] &&
! context[ mayDisplayControlsKey ]
) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export default function TemplatePartEdit( {
} }
</BlockSettingsMenuControls>

<InspectorControls>
<InspectorControls group="settings">
<TemplatesList
area={ area }
clientId={ clientId }
Expand Down
Loading