Skip to content

Commit

Permalink
Also set the insertion point in the quick inserter
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Aug 9, 2024
1 parent 71ad64b commit dea7012
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import clsx from 'clsx';
import { useState, useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Button, SearchControl } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -82,6 +82,8 @@ export default function QuickInserter( {
}
}, [ setInserterIsOpened ] );

const { showInsertionPoint } = useDispatch( blockEditorStore );

// When clicking Browse All select the appropriate block so as
// the insertion point can work as expected.
const onBrowseAll = () => {
Expand All @@ -91,6 +93,7 @@ export default function QuickInserter( {
filterValue,
onSelect,
} );
showInsertionPoint( rootClientId, insertionIndex );
};

let maxBlockPatterns = 0;
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,7 @@ export function insertionPoint( state = null, action ) {
}

case 'HIDE_INSERTION_POINT':
case 'CLEAR_SELECTED_BLOCK':
case 'SELECT_BLOCK':
return null;
}
Expand Down
9 changes: 6 additions & 3 deletions packages/editor/src/components/inserter-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ export default function InserterSidebar() {
sidebarIsOpened,
} = useSelect( ( select ) => {
const {
getBlockInsertionPoint,
getInserterSidebarToggleRef,
getInsertionPoint,
isPublishSidebarOpened,
} = unlock( select( editorStore ) );
const { getBlockRootClientId, __unstableGetEditorMode, getSettings } =
select( blockEditorStore );
const {
getBlockInsertionPoint,
getBlockRootClientId,
__unstableGetEditorMode,
getSettings,
} = select( blockEditorStore );
const { get } = select( preferencesStore );
const { getActiveComplementaryArea } = select( interfaceStore );
const getBlockSectionRootClientId = () => {
Expand Down

0 comments on commit dea7012

Please sign in to comment.