Skip to content

Scheduling infrastructure for absolutely everyone.

fix: allow enter key to create new list items in editor (#22001)

ddoemonn59b55e40b59c
diff --git a/packages/ui/components/editor/plugins/customEnterKeyPlugin.tsx b/packages/ui/components/editor/plugins/customEnterKeyPlugin.tsx
index 177e08e7f8a..ba4582be998 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]);