-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patterns: update the title of Pattern block in the block inspector card #52010
Changes from 7 commits
dbcd8cb
c314e29
f66e163
06535a7
0dbc127
918427b
9ff50d8
f800546
3e92024
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,21 +67,30 @@ 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; | ||
let title = blockType.title; | ||
const attributes = getBlockAttributes( clientId ); | ||
const match = getActiveBlockVariation( blockName, attributes ); | ||
const isSynced = | ||
isReusableBlock( blockType ) || isTemplatePart( blockType ); | ||
const isReusable = isReusableBlock( blockType ); | ||
if ( isReusable ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally optional, but maybe this condition could be rejigged a bit.
What about const resusableTitle = isReusableBlock( blockType ) ? __experimentalGetReusableBlockTitle( attributes.ref ) : '';
const title = resusableTitle || blockType?.title; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seemed like the ternary needed to be set to const resusableTitle = isReusable ? __experimentalGetReusableBlockTitle( attributes.ref ) : undefined;
const title = resusableTitle || blockType.title; also on line 79 the function returns early if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds good. My example was "unrehearsed". I retested and it works as advertised. Thanks @glendaviesnz ! |
||
title = | ||
__experimentalGetReusableBlockTitle( attributes.ref ) || | ||
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, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the
title
property always be present on the object?