Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update header toolbar media block insertion method
  • Loading branch information
derekblank committed Jun 28, 2023
commit 7cf0e1dc10c1622ead78518e19b5e11714980b02
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function HeaderToolbar( {
showInserter,
showKeyboardHideButton,
getStylesFromColorScheme,
insertBlocks,
insertBlock,
onHideKeyboard,
isRTL,
noContentSelected,
Expand Down Expand Up @@ -90,9 +90,14 @@ function HeaderToolbar( {
return isRTL ? buttons.reverse() : buttons;
};

const onInsertBlock = ( blockType ) => () => {
insertBlocks( [ createBlock( blockType ) ] );
};
const onInsertBlock = useCallback(
( blockType ) => () => {
insertBlock( createBlock( blockType ), undefined, undefined, true, {
source: 'inserter_menu',
} );
},
[ insertBlock ]
);

const renderMediaButtons = (
<>
Expand Down Expand Up @@ -234,7 +239,7 @@ export default compose( [
};
} ),
withDispatch( ( dispatch ) => {
const { clearSelectedBlock, insertBlocks } =
const { clearSelectedBlock, insertBlock } =
dispatch( blockEditorStore );
const { togglePostTitleSelection } = dispatch( editorStore );

Expand All @@ -245,7 +250,7 @@ export default compose( [
clearSelectedBlock();
togglePostTitleSelection( false );
},
insertBlocks,
insertBlock,
};
} ),
withViewportMatch( { isLargeViewport: 'medium' } ),
Expand Down