Skip to content

Commit

Permalink
Fix color and behavior of unsynced patterns in block inserter (#53205)
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz authored and tellthemachines committed Aug 1, 2023
1 parent 2bc0dad commit 1662b7b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ function InserterListItem( {
];
}, [ item.name, item.initialAttributes, item.initialAttributes ] );

const isSynced = isReusableBlock( item ) || isTemplatePart( item );
const isSynced =
( isReusableBlock( item ) && item.syncStatus !== 'unsynced' ) ||
isTemplatePart( item );

return (
<InserterDraggableBlocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createBlock,
createBlocksFromInnerBlocksTemplate,
store as blocksStore,
parse,
} from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
import { useCallback } from '@wordpress/element';
Expand Down Expand Up @@ -37,12 +38,20 @@ const useBlockTypesState = ( rootClientId, onInsert ) => {
);

const onSelectItem = useCallback(
( { name, initialAttributes, innerBlocks }, shouldFocusBlock ) => {
const insertedBlock = createBlock(
name,
initialAttributes,
createBlocksFromInnerBlocksTemplate( innerBlocks )
);
(
{ name, initialAttributes, innerBlocks, syncStatus, content },
shouldFocusBlock
) => {
const insertedBlock =
syncStatus === 'unsynced'
? parse( content, {
__unstableSkipMigrationLogs: true,
} )
: createBlock(
name,
initialAttributes,
createBlocksFromInnerBlocksTemplate( innerBlocks )
);

onInsert( insertedBlock, undefined, shouldFocusBlock );
},
Expand Down

0 comments on commit 1662b7b

Please sign in to comment.