Skip to content

Commit

Permalink
Only allow template part to be replaced if its a header or footer (#4…
Browse files Browse the repository at this point in the history
…0787)

Checks the assigned `area` of a template part before revealing the "Replace" button in the toolbar.
  • Loading branch information
jameskoster authored May 12, 2022
1 parent 5d81dce commit c840e90
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,21 @@ export default function TemplatePartEdit( {
/>
</TagName>
) }
{ isEntityAvailable && hasReplacements && (
<BlockControls>
<ToolbarGroup className="wp-block-template-part__block-control-group">
<ToolbarButton
onClick={ () =>
setIsTemplatePartSelectionOpen( true )
}
>
{ __( 'Replace' ) }
</ToolbarButton>
</ToolbarGroup>
</BlockControls>
) }
{ isEntityAvailable &&
hasReplacements &&
( area === 'header' || area === 'footer' ) && (
<BlockControls>
<ToolbarGroup className="wp-block-template-part__block-control-group">
<ToolbarButton
onClick={ () =>
setIsTemplatePartSelectionOpen( true )
}
>
{ __( 'Replace' ) }
</ToolbarButton>
</ToolbarGroup>
</BlockControls>
) }
{ isEntityAvailable && (
<TemplatePartInnerBlocks
tagName={ TagName }
Expand Down

0 comments on commit c840e90

Please sign in to comment.