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 Jul 12, 2023
1 parent d233bc2 commit fa85e95
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

1 comment on commit fa85e95

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in fa85e95.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5526251835
📝 Reported issues:

Please sign in to comment.