diff --git a/apps/builder/app/canvas/features/text-editor/text-editor.tsx b/apps/builder/app/canvas/features/text-editor/text-editor.tsx index 81a01dcdf6c9..6746fef9dbb4 100644 --- a/apps/builder/app/canvas/features/text-editor/text-editor.tsx +++ b/apps/builder/app/canvas/features/text-editor/text-editor.tsx @@ -1127,7 +1127,11 @@ const RichTextContentPluginInternal = ({ .get() .get(rootInstanceSelector[0]); - if (currentInstance?.component === "ListItem") { + const rootNodeContent = $getRoot().getTextContent().trim(); + if ( + currentInstance?.component === "ListItem" && + rootNodeContent.length > 0 + ) { // Instead of creating block component we need to add a new ListItem insertListItemAt(rootInstanceSelector); event.preventDefault(); @@ -1183,6 +1187,16 @@ const RichTextContentPluginInternal = ({ insertTemplateAt(templateSelector, rootInstanceSelector, false); + if ( + currentInstance?.component === "ListItem" && + rootNodeContent.length === 0 + ) { + // Pressing Enter within an empty list item deletes the empty item + updateWebstudioData((data) => { + deleteInstanceMutable(data, rootInstanceSelector); + }); + } + event.preventDefault(); return true; }