diff --git a/packages/block-editor/src/components/inserter/menu.native.js b/packages/block-editor/src/components/inserter/menu.native.js index 782017a527d88..b7b9711841da1 100644 --- a/packages/block-editor/src/components/inserter/menu.native.js +++ b/packages/block-editor/src/components/inserter/menu.native.js @@ -116,6 +116,7 @@ export default compose( getBlockName, getBlockRootClientId, getBlockSelectionEnd, + getSettings, } = select( 'core/block-editor' ); const { getChildBlockNames, @@ -130,10 +131,13 @@ export default compose( } const destinationRootBlockName = getBlockName( destinationRootClientId ); + const { __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop } = getSettings(); + return { rootChildBlocks: getChildBlockNames( destinationRootBlockName ), items: getInserterItems( destinationRootClientId ), destinationRootClientId, + shouldInsertAtTheTop, }; } ), withDispatch( ( dispatch, ownProps, { select } ) => { @@ -154,13 +158,10 @@ export default compose( getBlockSelectionEnd, getBlockOrder, } = select( 'core/block-editor' ); - const { - isPostTitleSelected, - } = select( 'core/editor' ); - const { clientId, destinationRootClientId, isAppender } = ownProps; + const { clientId, destinationRootClientId, isAppender, shouldInsertAtTheTop } = ownProps; // if post title is selected insert as first block - if ( isPostTitleSelected() ) { + if ( shouldInsertAtTheTop ) { return 0; } diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index 13bf0f09c2bf9..297efffe37efb 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -81,6 +81,7 @@ class EditorProvider extends Component { hasUploadPermissions, canUserUseUnfilteredHTML, undo, + shouldInsertAtTheTop, ) { return { ...pick( settings, [ @@ -120,6 +121,7 @@ class EditorProvider extends Component { __experimentalFetchLinkSuggestions: fetchLinkSuggestions, __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML, __experimentalUndo: undo, + __experimentalShouldInsertAtTheTop: shouldInsertAtTheTop, }; } @@ -165,6 +167,7 @@ class EditorProvider extends Component { reusableBlocks, resetEditorBlocksWithoutUndoLevel, hasUploadPermissions, + isPostTitleSelected, __experimentalFetchReusableBlocks, undo, } = this.props; @@ -180,6 +183,7 @@ class EditorProvider extends Component { hasUploadPermissions, canUserUseUnfilteredHTML, undo, + isPostTitleSelected, ); return ( @@ -214,6 +218,7 @@ export default compose( [ getEditorSelectionStart, getEditorSelectionEnd, __experimentalGetReusableBlocks, + isPostTitleSelected, } = select( 'core/editor' ); const { canUser } = select( 'core' ); @@ -225,6 +230,8 @@ export default compose( [ selectionEnd: getEditorSelectionEnd(), reusableBlocks: __experimentalGetReusableBlocks(), hasUploadPermissions: defaultTo( canUser( 'create', 'media' ), true ), + // This selector is only defined on mobile. + isPostTitleSelected: isPostTitleSelected && isPostTitleSelected(), }; } ), withDispatch( ( dispatch ) => {