-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: block styles preview is not displayed #43837
Conversation
@@ -27,7 +31,7 @@ function InserterPreviewPanel( { item } ) { | |||
viewportWidth={ example?.viewportWidth ?? 500 } | |||
blocks={ | |||
example | |||
? getBlockFromExample( item.name, { | |||
? getBlockFromExample( name, { |
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 is a small improvement 👍
const isReusable = isReusableBlock( item ); | ||
const hoveredItemBlockType = getBlockType( name ); | ||
const example = item.example || hoveredItemBlockType.example; |
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.
As far as I know, it is not explicitly stated that the example can be used for block variations.
To clarify what this code is intended to do, should I leave any comments 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.
It might be worth adding a small comment to explain why you're checking for both, for sure 👍
Size Change: +1.08 kB (0%) Total Size: 1.25 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.
This is working well for me.
I think adding a comment to explain why the fallback example block exists would be a good idea before merge.
Code optimization mentioned in https://github.com/WordPress/gutenberg/pull/43837/files#r963186600 optional, probably not required.
Thanks for working on this. I think it could be a cleaner fix to add the That way every place the |
Thanks for the review!
I think this makes sense. |
Looks good to me too. Thanks for fixing the bug that I made 😄 |
Fix ##43836
Follow-up on #42454
What?
This PR fixes a problem with block style previews not displaying properly.
Why?
In #42454, the block variation
example
is now referenced to enable a preview of template parts.However, to preview regular block styles, the main block
example
must be referenced.How?
If the
example
of the block variation does not exist, theexample
of the main block is referenced. This will ensure that previews of block variations and block styles are displayed correctly.Testing Instructions
Open the Global Inserter and confirm that the template part preview is enabled as before.
Insert a block with a block style and confirm that the preview displays correctly when you mouse over the style button.