Skip to content

Commit

Permalink
Fix unsaved pattern not reflecting on pattern overrides (#57148)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Dec 19, 2023
1 parent 391aef6 commit a4a7feb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/block-library/src/block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default function ReusableBlockEdit( {
} ) {
const registry = useRegistry();
const hasAlreadyRendered = useHasRecursion( ref );
const { record, hasResolved } = useEntityRecord(
const { record, editedRecord, hasResolved } = useEntityRecord(
'postType',
'wp_block',
ref
Expand All @@ -156,9 +156,13 @@ export default function ReusableBlockEdit( {
const { getBlockEditingMode } = useSelect( blockEditorStore );

useEffect( () => {
if ( ! record?.content?.raw ) return;
const initialBlocks = parse( record.content.raw );
const initialBlocks =
editedRecord.blocks ??
( editedRecord.content && typeof editedRecord.content !== 'function'
? parse( editedRecord.content )
: [] );

defaultValuesRef.current = {};
const editingMode = getBlockEditingMode( patternClientId );
registry.batch( () => {
setBlockEditingMode( patternClientId, 'default' );
Expand All @@ -176,7 +180,7 @@ export default function ReusableBlockEdit( {
}, [
__unstableMarkNextChangeAsNotPersistent,
patternClientId,
record,
editedRecord,
replaceInnerBlocks,
registry,
getBlockEditingMode,
Expand Down

0 comments on commit a4a7feb

Please sign in to comment.