Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1604,18 +1604,17 @@ export function preferences( state = PREFERENCES_DEFAULTS, action ) {
case 'REPLACE_BLOCKS':
return action.blocks.reduce( ( prevState, block ) => {
const { attributes, name: blockName } = block;
let id = blockName;
// If a block variation match is found change the name to be the same with the
// one that is used for block variations in the Inserter (`getItemFromVariation`).
const match = select( blocksStore ).getActiveBlockVariation(
blockName,
attributes
);
// If a block variation match is found change the name to be the same with the
// one that is used for block variations in the Inserter (`getItemFromVariation`).
let id = match?.name
? `${ blockName }/${ match.name }`
: blockName;
const insert = { name: id };
if ( match?.name ) {
id += '/' + match.name;
}
if ( blockName === 'core/block' ) {
insert.ref = attributes.ref;
id += '/' + attributes.ref;
}

Expand All @@ -1628,7 +1627,6 @@ export function preferences( state = PREFERENCES_DEFAULTS, action ) {
count: prevState.insertUsage[ id ]
? prevState.insertUsage[ id ].count + 1
: 1,
insert,
},
},
};
Expand Down
7 changes: 0 additions & 7 deletions packages/block-editor/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2889,7 +2889,6 @@ describe( 'state', () => {
'core/embed': {
time: 123456,
count: 1,
insert: { name: 'core/embed' },
},
},
} );
Expand All @@ -2900,7 +2899,6 @@ describe( 'state', () => {
'core/embed': {
time: 123456,
count: 1,
insert: { name: 'core/embed' },
},
},
} ),
Expand All @@ -2926,12 +2924,10 @@ describe( 'state', () => {
'core/embed': {
time: 123457,
count: 2,
insert: { name: 'core/embed' },
},
'core/block/123': {
time: 123457,
count: 1,
insert: { name: 'core/block', ref: 123 },
},
},
} );
Expand Down Expand Up @@ -2994,17 +2990,14 @@ describe( 'state', () => {
[ orangeVariationName ]: {
time: 123456,
count: 1,
insert: { name: orangeVariationName },
},
[ appleVariationName ]: {
time: 123456,
count: 1,
insert: { name: appleVariationName },
},
[ blockWithVariations ]: {
time: 123456,
count: 2,
insert: { name: blockWithVariations },
},
} ),
} );
Expand Down