-
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
Template Part - fix labels shown - use title instead of slug #28330
Conversation
Size Change: +636 B (0%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
aba2479
to
c650d48
Compare
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.
Note that this will resolve #28302 by not showing the slugs in user-facing UI. |
@@ -140,6 +141,19 @@ export function normalizeBlockType( blockTypeOrName ) { | |||
* @return {string} The block label. | |||
*/ | |||
export function getBlockLabel( blockType, attributes, context = 'visual' ) { | |||
// Attempt to find entity title if block is a template part. | |||
// Require slug to request, otherwise entity is uncreated and will throw 404. | |||
if ( 'core/template-part' === blockType.name && attributes.slug ) { |
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.
This logic should be added as __experimentalLabel
in the registerBlockType
call for the Template Part block.
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.
Oh, that makes more sense. Thank you for fixing this!
Description
With recent changes to template parts, slugs no longer update along with the title while slug is still used in the interface as a label to show users. This updates some labels shown in the interface to show the title instead of the slug.
Before
Previously - the label in both the sidebar and the selector would show the slug
template-part-*
instead of the user defined title:the notification shown on inserting template parts was not showing any proper label:
And the label in document actions in the top toolbar was based on the slug:
After
After this change - the sidebar and selector should display the proper labels for the template parts:
the notification should be fixed:
and the label in the top toolbar should be based on the title as well:
How has this been tested?
Screenshots
Types of changes
Checklist: