Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions packages/editor/src/components/autocompleters/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export function createBlockCompleter( {
);
},
getOptionKeywords( inserterItem ) {
const { title, keywords = [] } = inserterItem;
return [ ...keywords, title ];
const { title, keywords = [], category } = inserterItem;
return [ category, ...keywords, title ];
},
getOptionLabel( inserterItem ) {
const { icon, title } = inserterItem;
Expand Down
11 changes: 7 additions & 4 deletions packages/editor/src/components/autocompleters/test/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,33 @@ describe( 'block', () => {
expect( completer.options() ).toEqual( [ option1, option3 ] );
} );

it( 'should derive option keywords from block keywords and block title', () => {
it( 'should derive option keywords from block category, block keywords and block title', () => {
const inserterItemWithTitleAndKeywords = {
name: 'core/foo',
title: 'foo',
keywords: [ 'foo-keyword-1', 'foo-keyword-2' ],
category: 'formatting',
};
const inserterItemWithTitleAndEmptyKeywords = {
name: 'core/bar',
title: 'bar',
// Intentionally empty keyword list
keywords: [],
category: 'common',
};
const inserterItemWithTitleAndUndefinedKeywords = {
name: 'core/baz',
title: 'baz',
category: 'widgets',
// Intentionally omitted keyword list
};

expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndKeywords ) )
.toEqual( [ 'foo-keyword-1', 'foo-keyword-2', 'foo' ] );
.toEqual( [ 'formatting', 'foo-keyword-1', 'foo-keyword-2', 'foo' ] );
expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndEmptyKeywords ) )
.toEqual( [ 'bar' ] );
.toEqual( [ 'common', 'bar' ] );
expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndUndefinedKeywords ) )
.toEqual( [ 'baz' ] );
.toEqual( [ 'widgets', 'baz' ] );
} );

it( 'should render a block option label', () => {
Expand Down