Skip to content

Commit

Permalink
Block Library: Fix issue with Post Tags block when there are no tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras authored and ockham committed Feb 24, 2020
1 parent bf4b537 commit abc53bc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/block-library/src/post-tags/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { useEntityProp, useEntityId } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

function PostTagsDisplay() {
const [ tags ] = useEntityProp( 'postType', 'post', 'tags' );
Expand All @@ -25,7 +26,12 @@ function PostTagsDisplay() {
},
[ tags ]
);
return tagLinks && tagLinks.reduce( ( prev, curr ) => [ prev, ' | ', curr ] );
return (
tagLinks &&
( tagLinks.length === 0 ?
__( 'No tags.' ) :
tagLinks.reduce( ( prev, curr ) => [ prev, ' | ', curr ] ) )
);
}

export default function PostTagsEdit() {
Expand Down

0 comments on commit abc53bc

Please sign in to comment.