-
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
Fix custom template part theme meta. #26587
Conversation
Size Change: +7 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
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.
🚀
7ee34cf
to
c2182c6
Compare
<PanelGroup | ||
key={ templatePart.id } | ||
title={ templatePart.meta.theme || __( 'Custom' ) } | ||
> |
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.
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.
Yeah, the search results group them individually as they are ordered a bit naively by the priorities:
- index match is found in the slug.
- index match is found in the theme.
I think a lot of this does need to be rethought in the future.
@@ -109,7 +109,8 @@ function TemplatePartsByTheme( { | |||
return templatePartsByTheme.map( ( templatePartList ) => ( | |||
<PanelGroup | |||
key={ templatePartList[ 0 ].meta.theme } |
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.
I think we should add a fallback value here as well, to avoid an empty key. 🤔
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.
Ah I see I was late here 😄
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.
Possibly? I think React doesn't get mad if the key is the empty string, like it does when it is null
/undefined
. So in this case ''
may still be a valid unique key for the group?
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.
Yeah I've noticed React didn't complain about it, so... LGTM then!
Description
As discussed on #26394 (comment) - it makes more sense to create custom template parts with a blank theme name than 'Custom'. This will ensure consistency with template parts created from the wp-admin template-part menu, as well as with how templates themselves denote theme names.
This PR updates the custom template part creation to create with the theme name
''
and updates the selection previews to show'Custom'
when the theme name is empty.How has this been tested?
Screenshots
Types of changes
Checklist: