Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserter: show all blocks (alternative) #62169

Merged
merged 10 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
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
Fix quick inserter
  • Loading branch information
ellatrix committed May 31, 2024
commit afa0d6e03a76e59bf31bb57c855ae207365bf665
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ import { withRootClientIdOptionKey } from '../../../store/utils';
*
* @param {string=} rootClientId Insertion's root client ID.
* @param {Function} onInsert function called when inserter a list of blocks.
* @param {boolean} isQuick
* @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
*/
const useBlockTypesState = ( rootClientId, onInsert ) => {
const useBlockTypesState = ( rootClientId, onInsert, isQuick ) => {
const [ items ] = useSelect(
( select ) => [
select( blockEditorStore ).getInserterItems( rootClientId, {
[ withRootClientIdOptionKey ]: true,
[ withRootClientIdOptionKey ]: ! isQuick,
} ),
],
[ rootClientId ]
[ rootClientId, isQuick ]
);

const [ categories, collections ] = useSelect( ( select ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export default function QuickInserter( {
} );
const [ blockTypes ] = useBlockTypesState(
destinationRootClientId,
onInsertBlocks
onInsertBlocks,
true
);

const [ patterns ] = usePatternsState(
Expand Down Expand Up @@ -126,6 +127,7 @@ export default function QuickInserter( {
isDraggable={ false }
prioritizePatterns={ prioritizePatterns }
selectBlockOnInsert={ selectBlockOnInsert }
isQuick
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function InserterSearchResults( {
shouldFocusBlock = true,
prioritizePatterns,
selectBlockOnInsert,
isQuick,
} ) {
const debouncedSpeak = useDebounce( speak, 500 );

Expand Down Expand Up @@ -80,7 +81,7 @@ function InserterSearchResults( {
blockTypeCategories,
blockTypeCollections,
onSelectBlockType,
] = useBlockTypesState( destinationRootClientId, onInsertBlocks );
] = useBlockTypesState( destinationRootClientId, onInsertBlocks, isQuick );
const [ patterns, , onClickPattern ] = usePatternsState(
onInsertBlocks,
destinationRootClientId
Expand Down
Loading