Skip to content

Commit

Permalink
Remove the insert.ref field from insertUsage data
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed May 31, 2023
1 parent 642b1c9 commit 456d570
Showing 1 changed file with 6 additions and 8 deletions.
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

0 comments on commit 456d570

Please sign in to comment.