Skip to content

Commit

Permalink
Fix empty state
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 11, 2023
1 parent 65eb8ab commit 30e14d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/commands/src/components/command-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export function CommandMenuGroup( { group, search, setLoader, close } ) {
[ group, hasSearch ]
);

if ( ! commands.length && ! loaders.length ) {
return null;
}

return (
<Command.Group>
{ commands.map( ( command ) => (
Expand Down Expand Up @@ -230,7 +234,7 @@ export function CommandMenu() {
/>
</div>
<Command.List>
{ ! isLoading && (
{ search && ! isLoading && (
<Command.Empty>
{ __( 'No results found.' ) }
</Command.Empty>
Expand Down
10 changes: 9 additions & 1 deletion packages/commands/src/components/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,15 @@
[cmdk-root] > [cmdk-list] {
max-height: 400px;
overflow: auto;
padding: $grid-unit;

& > [cmdk-list-sizer] {
padding: $grid-unit;

// Hides the padding in empty contexts.
&:empty {
display: none;
}
}
}

[cmdk-empty] {
Expand Down

0 comments on commit 30e14d2

Please sign in to comment.