Skip to content

Commit

Permalink
Add check for empty list item
Browse files Browse the repository at this point in the history
  • Loading branch information
nani-samireddy committed Oct 22, 2024
1 parent d0771cd commit 3b5ea15
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/block-library/src/list-item/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import { InnerBlocks, RichText, useBlockProps } from '@wordpress/block-editor';

export default function save( { attributes } ) {
/**
* Render the list item only if there is content.
* This check is to eliminate empty list items from the front end.
*/
if ( attributes.content?.length === 0 ) {
return null;
}

return (
<li { ...useBlockProps.save() }>
<RichText.Content value={ attributes.content } />
Expand Down

0 comments on commit 3b5ea15

Please sign in to comment.