diff --git a/web/components/issues/issue-detail/issue-activity/comments/comment-create.tsx b/web/components/issues/issue-detail/issue-activity/comments/comment-create.tsx index f7bce3edc..f666b6c1d 100644 --- a/web/components/issues/issue-detail/issue-activity/comments/comment-create.tsx +++ b/web/components/issues/issue-detail/issue-activity/comments/comment-create.tsx @@ -11,6 +11,8 @@ import { TIssueComment } from "@plane/types"; // icons import { Globe2, Lock } from "lucide-react"; import { useMention, useWorkspace } from "hooks/store"; +// helpers +import { isEmptyHtmlString } from "helpers/string.helper"; const fileService = new FileService(); @@ -51,10 +53,10 @@ export const IssueCommentCreate: FC = (props) => { const { handleSubmit, control, + watch, formState: { isSubmitting }, reset, - watch, - } = useForm>({ defaultValues: { comment_html: "" } }); + } = useForm>({ defaultValues: { comment_html: "

" } }); const onSubmit = async (formData: Partial) => { await activityOperations.createComment(formData).finally(() => { @@ -63,14 +65,19 @@ export const IssueCommentCreate: FC = (props) => { }); }; + const isEmpty = + watch("comment_html") === "" || + watch("comment_html")?.trim() === "" || + watch("comment_html") === "

" || + isEmptyHtmlString(watch("comment_html") ?? ""); + return (
{ - // if (e.key === "Enter" && !e.shiftKey) { - // e.preventDefault(); - // // handleSubmit(onSubmit)(e); - // } - // }} + onKeyDown={(e) => { + if (e.key === "Enter" && !e.shiftKey && !isEmpty) { + handleSubmit(onSubmit)(e); + } + }} > = (props) => { control={control} render={({ field: { value, onChange } }) => ( { - handleSubmit(onSubmit)(e); - }} cancelUploadImage={fileService.cancelUpload} uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)} deleteFile={fileService.getDeleteImageFunction(workspaceId)} restoreFile={fileService.getRestoreImageFunction(workspaceId)} ref={editorRef} - value={value ?? ""} + value={!value ? "

" : value} customClassName="p-2" editorContentCustomClassNames="min-h-[35px]" debouncedUpdatesEnabled={false} @@ -105,7 +109,7 @@ export const IssueCommentCreate: FC = (props) => { } submitButton={