From 0fe1b315e4460eb03d818365a69c8e05d318e59b Mon Sep 17 00:00:00 2001 From: ZecD Date: Wed, 24 Jan 2024 13:28:21 +0100 Subject: [PATCH 1/2] fixed behaviour when editor is empty --- src/stories/chat/parts/commentBox.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stories/chat/parts/commentBox.tsx b/src/stories/chat/parts/commentBox.tsx index 7117b2e4..52245266 100644 --- a/src/stories/chat/parts/commentBox.tsx +++ b/src/stories/chat/parts/commentBox.tsx @@ -58,8 +58,8 @@ export const CommentBox = ({ ...props, }); - const onKeyDown = (event: ReactKeyboardEvent) => { - if ((event.ctrlKey || event.metaKey) && event.key === "Enter") { + const onKeyDown = (event: ReactKeyboardEvent) => { + if ((event.ctrlKey || event.metaKey) && event.key === "Enter" && !editor?.isEmpty) { triggerSave(); editor?.commands.clearContent(); } From d90f11f480fb4df86ebbde1acb224cbf57785900 Mon Sep 17 00:00:00 2001 From: ZecD Date: Wed, 24 Jan 2024 15:39:58 +0100 Subject: [PATCH 2/2] changed onTriggerSave behaviour --- src/stories/chat/context/chatContext.tsx | 2 +- src/stories/chat/parts/commentBox.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stories/chat/context/chatContext.tsx b/src/stories/chat/context/chatContext.tsx index 03c0e8fd..08673fc9 100644 --- a/src/stories/chat/context/chatContext.tsx +++ b/src/stories/chat/context/chatContext.tsx @@ -45,7 +45,7 @@ export const ChatContextProvider = ({ editor, setEditor, triggerSave: () => { - if (editor && onSave) { + if (editor && onSave && !editor.isEmpty) { onSave(editor, getMentions(editor)); editor.commands.clearContent(); } diff --git a/src/stories/chat/parts/commentBox.tsx b/src/stories/chat/parts/commentBox.tsx index 52245266..608606a0 100644 --- a/src/stories/chat/parts/commentBox.tsx +++ b/src/stories/chat/parts/commentBox.tsx @@ -59,7 +59,7 @@ export const CommentBox = ({ }); const onKeyDown = (event: ReactKeyboardEvent) => { - if ((event.ctrlKey || event.metaKey) && event.key === "Enter" && !editor?.isEmpty) { + if ((event.ctrlKey || event.metaKey) && event.key === "Enter" ) { triggerSave(); editor?.commands.clearContent(); }