-
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 Template Part placeholder preview #21623
Conversation
Size Change: -19 B (0%) Total Size: 845 kB
ℹ️ View Unchanged
|
Everything seems to work on this branch, however when I rebased master locally I find that the insertion stops working. That is, the match is found, the preview is shown, but when you press 'Choose' it inserts a blank instead. I am having problems finding the culprit for this regression in behavior. 😞 |
I can't seem to repro the fix on this branch, even if I don't rebase on FWIW, I'm using |
Gotcha. I was doing this with custom template parts. So I create one with a slug and theme name, save it, then try to insert it elsewhere. We do need to figure out a way to include the themes template parts in this request as well. 🤔 |
Ah right, I keep forgetting about the endpoint exposing only the template parts CPTs, whereas the template switcher only shows the ones that come with the theme. (I've been bitten before by this issue tho 😅 ) |
It may make sense to close this in favor of #21766 - but I will leave it open for now just since this is in a state where inserting the template part works, while there is some unidentified regression on master that currently will cause it to insert a blank instead. |
Ok, we can still use this PR to fix the style issue with the preview. #21766 Fixes a handful of the other issues. So lets test this branch to ensure the preview is no longer cut off at the bottom. |
@@ -26,7 +26,7 @@ export default function useTemplatePartPost( postId, slug, theme ) { | |||
'postType', | |||
'wp_template_part', | |||
{ | |||
status: 'auto-draft', | |||
status: [ 'publish', 'auto-draft' ], |
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.
Nice, that one merged. I rebased this =)
fdd2e94
to
326df36
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.
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.
LGTM!
Since this is used in other areas like block preview, I smoke tested that and couldn't notice any visual regressions.
Description
Fixes the preview for and allows custom template parts to appropriately be found by the Template Part placeholder block.
Before this, no match would be found and the placeholder would promt to create a new one.
Also, if a template were found, the preview is cut off at the bottom:

This PR will fix that to properly show the entire template part:

Code changes:
position
style from the BlockPreview content wrapper, this was causing the preview to be cut off at the bottom (Or in the case of small template parts, not show up at all).Testing Instructions
How has this been tested?
Tested on local environment in post and site editors.
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: