Skip to content

Commit

Permalink
Patterns: update the title of Pattern block in the block inspector ca…
Browse files Browse the repository at this point in the history
…rd (#52010)
  • Loading branch information
glendaviesnz authored and tellthemachines committed Jul 12, 2023
1 parent 8382196 commit 90fbe99
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Add a user’s avatar. ([Source](https://github.com/WordPress/gutenberg/tree/tru

## Pattern

Create and save content to reuse across your site. Update the block, and the changes apply everywhere it’s used. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/block))
Create and save content to reuse across your site. Update the pattern, and the changes apply everywhere it’s used. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/block))

- **Name:** core/block
- **Category:** reusable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,28 @@ export default function useBlockDisplayInformation( clientId ) {
return useSelect(
( select ) => {
if ( ! clientId ) return null;
const { getBlockName, getBlockAttributes } =
select( blockEditorStore );
const {
getBlockName,
getBlockAttributes,
__experimentalGetReusableBlockTitle,
} = select( blockEditorStore );
const { getBlockType, getActiveBlockVariation } =
select( blocksStore );
const blockName = getBlockName( clientId );
const blockType = getBlockType( blockName );
if ( ! blockType ) return null;
const attributes = getBlockAttributes( clientId );
const match = getActiveBlockVariation( blockName, attributes );
const isSynced =
isReusableBlock( blockType ) || isTemplatePart( blockType );
const isReusable = isReusableBlock( blockType );
const resusableTitle = isReusable
? __experimentalGetReusableBlockTitle( attributes.ref )
: undefined;
const title = resusableTitle || blockType.title;
const isSynced = isReusable || isTemplatePart( blockType );
const positionLabel = getPositionTypeLabel( attributes );
const blockTypeInfo = {
isSynced,
title: blockType.title,
title,
icon: blockType.icon,
description: blockType.description,
anchor: attributes?.anchor,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/block/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "core/block",
"title": "Pattern",
"category": "reusable",
"description": "Create and save content to reuse across your site. Update the block, and the changes apply everywhere it’s used.",
"description": "Create and save content to reuse across your site. Update the pattern, and the changes apply everywhere it’s used.",
"textdomain": "default",
"attributes": {
"ref": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ describe( 'Reusable blocks', () => {
expect( reusableBlockWithParagraph ).toBeTruthy();

// Convert back to regular blocks.
await clickBlockToolbarButton( 'Select Pattern' );
await clickBlockToolbarButton( 'Select Edited block' );
await clickBlockToolbarButton( 'Detach pattern' );
await page.waitForXPath( selector, {
hidden: true,
Expand Down

0 comments on commit 90fbe99

Please sign in to comment.