Skip to content

Commit

Permalink
Fix: block styles preview is not displayed (#43837)
Browse files Browse the repository at this point in the history
* Fix: block styles preview is not displayed

* Apply clearer fixes

* Revert unnecessary line breaks
  • Loading branch information
t-hamano authored Sep 6, 2022
1 parent ecf6417 commit 6e31076
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { getBlockType } from '@wordpress/blocks';
import { useMemo } from '@wordpress/element';

/**
Expand All @@ -15,6 +16,7 @@ export default function BlockStylesPreviewPanel( {
className,
activeStyle,
} ) {
const example = getBlockType( genericPreviewBlock.name )?.example;
const styleClassName = replaceActiveStyle( className, activeStyle, style );
const previewBlocks = useMemo( () => {
return {
Expand All @@ -27,6 +29,7 @@ export default function BlockStylesPreviewPanel( {
styleClassName +
' block-editor-block-styles__block-preview-container',
},
example,
};
}, [ genericPreviewBlock, styleClassName ] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function InserterPreviewPanel( { item } ) {
viewportWidth={ example?.viewportWidth ?? 500 }
blocks={
example
? getBlockFromExample( item.name, {
? getBlockFromExample( name, {
attributes: {
...example.attributes,
...initialAttributes,
Expand Down

0 comments on commit 6e31076

Please sign in to comment.