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
3 changes: 2 additions & 1 deletion packages/blocks/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,8 @@ export function isMatchingSearchTerm( state, nameOrType, searchTerm ) {
isSearchMatch( blockType.title ) ||
some( blockType.keywords, isSearchMatch ) ||
isSearchMatch( blockType.category ) ||
isSearchMatch( blockType.description )
( typeof blockType.description === 'string' &&
isSearchMatch( blockType.description ) )
);
}

Expand Down
13 changes: 12 additions & 1 deletion packages/blocks/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ describe( 'selectors', () => {
...blockTypeBase,
category,
};
const blockTypeWithNonStringDescription = {
...blockTypeBase,
description: <div>writing flow</div>,
};

const state = {
blockTypes: {
Expand All @@ -617,6 +621,10 @@ describe( 'selectors', () => {
[ 'block type', blockType ],
[ 'block type without category', blockTypeWithoutCategory ],
[ 'block type without description', blockTypeWithoutDescription ],
[
'block type with non-string description',
blockTypeWithNonStringDescription,
],
] )( 'by %s', ( label, nameOrType ) => {
it( 'should return false if not match', () => {
const result = isMatchingSearchTerm(
Expand Down Expand Up @@ -690,7 +698,10 @@ describe( 'selectors', () => {
} );
}

if ( nameOrType.description ) {
if (
nameOrType.description &&
typeof nameOrType.description === 'string'
) {
it( 'should return true if match using the description', () => {
const result = isMatchingSearchTerm(
state,
Expand Down