From 59b55e40b59c828602e684ad19b4ccf65bd93de3 Mon Sep 17 00:00:00 2001 From: ddoemonn <109994179+ddoemonn@users.noreply.github.com> Date: Wed, 9 Jul 2025 12:39:08 +0300 Subject: [PATCH] fix: allow enter key to create new list items in editor (#22001) * fix: allow enter key to create new list items in editor * remove: unnecessary priority set to low * remove: unnecessary priority set to low --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: Eunjae Lee --- .../ui/components/editor/plugins/customEnterKeyPlugin.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/ui/components/editor/plugins/customEnterKeyPlugin.tsx b/packages/ui/components/editor/plugins/customEnterKeyPlugin.tsx index 177e08e7f8..ba4582be99 100644 --- a/packages/ui/components/editor/plugins/customEnterKeyPlugin.tsx +++ b/packages/ui/components/editor/plugins/customEnterKeyPlugin.tsx @@ -1,5 +1,6 @@ "use client"; +import { $isListItemNode } from "@lexical/list"; import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext"; import { $createLineBreakNode, @@ -19,6 +20,12 @@ const CustomEnterKeyPlugin = () => { (event: any) => { const selection = $getSelection(); if ($isRangeSelection(selection)) { + const anchorNode = selection.anchor.getNode(); + + if ($isListItemNode(anchorNode) || $isListItemNode(anchorNode.getParent())) { + return false; // Don't prevent default - let Lexical handle list behavior + } + event.preventDefault(); const lineBreakNode = $createLineBreakNode(); selection.insertNodes([lineBreakNode]);