Skip to content

Commit

Permalink
Merge pull request #4040 from WordPress/update/inserter-no-blocks-found
Browse files Browse the repository at this point in the history
Inserter: Show messaging when no blocks found
  • Loading branch information
aduth authored Jan 2, 2018
2 parents d931e5f + 06a4f8c commit 266247d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions editor/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
pick,
some,
sortBy,
isEmpty,
} from 'lodash';
import { connect } from 'react-redux';

Expand Down Expand Up @@ -253,6 +254,14 @@ export class InserterMenu extends Component {
}

renderCategories( visibleBlocksByCategory ) {
if ( isEmpty( visibleBlocksByCategory ) ) {
return (
<span className="editor-inserter__no-results">
{ __( 'No blocks found' ) }
</span>
);
}

return getCategories().map(
( category ) => this.renderCategory( category, visibleBlocksByCategory[ category.slug ] )
);
Expand Down
7 changes: 7 additions & 0 deletions editor/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ input[type="search"].editor-inserter__search {
overflow: auto;
}

.editor-inserter__no-results {
display: block;
text-align: center;
font-style: italic;
padding: 8px;
}

.editor-inserter__tabs {
display: flex;
flex-direction: column;
Expand Down

0 comments on commit 266247d

Please sign in to comment.