Skip to content

Commit

Permalink
Block Editor: Display variation icon in the 'BlockDraggable' component (
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored and tellthemachines committed Jul 12, 2023
1 parent 70fb0f9 commit 5f76704
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/block-editor/src/components/block-draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,25 @@ const BlockDraggable = ( {
} ) => {
const { srcRootClientId, isDraggable, icon } = useSelect(
( select ) => {
const { canMoveBlocks, getBlockRootClientId, getBlockName } =
select( blockEditorStore );
const { getBlockType } = select( blocksStore );
const {
canMoveBlocks,
getBlockRootClientId,
getBlockName,
getBlockAttributes,
} = select( blockEditorStore );
const { getBlockType, getActiveBlockVariation } =
select( blocksStore );
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
const blockName = getBlockName( clientIds[ 0 ] );
const variation = getActiveBlockVariation(
blockName,
getBlockAttributes( clientIds[ 0 ] )
);

return {
srcRootClientId: rootClientId,
isDraggable: canMoveBlocks( clientIds, rootClientId ),
icon: getBlockType( blockName )?.icon,
icon: variation?.icon || getBlockType( blockName )?.icon,
};
},
[ clientIds ]
Expand Down

0 comments on commit 5f76704

Please sign in to comment.