π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-2233] fix: intake issue comment (#5368)
Anmol Singh Bhatia3e83eed398f0
diff --git a/packages/editor/src/core/extensions/enter-key-extension.tsx b/packages/editor/src/core/extensions/enter-key-extension.tsxindex 311ead4976..d67ceb78b8 100644--- a/packages/editor/src/core/extensions/enter-key-extension.tsx+++ b/packages/editor/src/core/extensions/enter-key-extension.tsx@@ -1,6 +1,6 @@import { Extension } from "@tiptap/core";-export const EnterKeyExtension = (onEnterKeyPress?: (descriptionHTML: string) => void) =>+export const EnterKeyExtension = (onEnterKeyPress?: () => void) =>Extension.create({name: "enterKey",@@ -8,7 +8,9 @@ export const EnterKeyExtension = (onEnterKeyPress?: (descriptionHTML: string) =>return {Enter: () => {if (!this.editor.storage.mentionsOpen) {- onEnterKeyPress?.(this.editor.getHTML());+ if (onEnterKeyPress) {+ onEnterKeyPress();+ }return true;}return false;diff --git a/packages/editor/src/core/types/editor.ts b/packages/editor/src/core/types/editor.tsindex f817969c3e..25a37f0ca3 100644--- a/packages/editor/src/core/types/editor.ts+++ b/packages/editor/src/core/types/editor.ts@@ -35,7 +35,7 @@ export interface IEditorProps {suggestions?: () => Promise<IMentionSuggestion[]>;};onChange?: (json: object, html: string) => void;- onEnterKeyPress?: (descriptionHTML: string) => void;+ onEnterKeyPress?: (e?: any) => void;placeholder?: string | ((isFocused: boolean, value: string) => string);tabIndex?: number;value?: string | null;diff --git a/space/core/components/editor/lite-text-editor.tsx b/space/core/components/editor/lite-text-editor.tsxindex 698a6695c1..3cc8347a17 100644--- a/space/core/components/editor/lite-text-editor.tsx+++ b/space/core/components/editor/lite-text-editor.tsx@@ -64,11 +64,7 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrapp}}isSubmitting={isSubmitting}showSubmitButton={showSubmitButton}- handleSubmit={() => {- if (isMutableRefObject<EditorRefApi>(ref)) {- rest.onEnterKeyPress?.(ref.current?.getHTML() ?? "");- }- }}+ handleSubmit={(e) => rest.onEnterKeyPress?.(e)}isCommentEmpty={isEmpty}editorRef={isMutableRefObject<EditorRefApi>(ref) ? ref : null}/>diff --git a/space/core/components/editor/toolbar.tsx b/space/core/components/editor/toolbar.tsxindex a16cd0e203..3b0942e17a 100644--- a/space/core/components/editor/toolbar.tsx+++ b/space/core/components/editor/toolbar.tsx@@ -12,7 +12,7 @@ import { cn } from "@/helpers/common.helper";type Props = {executeCommand: (commandKey: TEditorCommands) => void;- handleSubmit: () => void;+ handleSubmit: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;isCommentEmpty: boolean;isSubmitting: boolean;showSubmitButton: boolean;diff --git a/space/core/components/issues/peek-overview/comment/add-comment.tsx b/space/core/components/issues/peek-overview/comment/add-comment.tsxindex a602538e00..29b1519f5e 100644--- a/space/core/components/issues/peek-overview/comment/add-comment.tsx+++ b/space/core/components/issues/peek-overview/comment/add-comment.tsx@@ -66,8 +66,8 @@ export const AddComment: React.FC<Props> = observer((props) => {control={control}render={({ field: { value, onChange } }) => (<LiteTextEditor- onEnterKeyPress={() => {- if (currentUser) handleSubmit(onSubmit)();+ onEnterKeyPress={(e) => {+ if (currentUser) handleSubmit(onSubmit)(e);}}workspaceId={workspaceID?.toString() ?? ""}workspaceSlug={workspaceSlug?.toString() ?? ""}diff --git a/space/core/components/issues/peek-overview/comment/comment-detail-card.tsx b/space/core/components/issues/peek-overview/comment/comment-detail-card.tsxindex 67738b524d..47b506b965 100644--- a/space/core/components/issues/peek-overview/comment/comment-detail-card.tsx+++ b/space/core/components/issues/peek-overview/comment/comment-detail-card.tsx@@ -103,7 +103,7 @@ export const CommentCard: React.FC<Props> = observer((props) => {<LiteTextEditorworkspaceId={workspaceID?.toString() ?? ""}workspaceSlug={workspaceSlug?.toString() ?? ""}- onEnterKeyPress={() => handleSubmit(handleCommentUpdate)()}+ onEnterKeyPress={handleSubmit(handleCommentUpdate)}ref={editorRef}id={comment.id}initialValue={value}diff --git a/web/core/components/editor/lite-text-editor/lite-text-editor.tsx b/web/core/components/editor/lite-text-editor/lite-text-editor.tsxindex 447f4f309e..4ded0e84c9 100644--- a/web/core/components/editor/lite-text-editor/lite-text-editor.tsx+++ b/web/core/components/editor/lite-text-editor/lite-text-editor.tsx@@ -94,11 +94,7 @@ export const LiteTextEditor = React.forwardRef<EditorRefApi, LiteTextEditorWrapp}}}handleAccessChange={handleAccessChange}- handleSubmit={() => {- if (isMutableRefObject<EditorRefApi>(ref)) {- rest.onEnterKeyPress?.(ref.current?.getHTML() ?? "");- }- }}+ handleSubmit={(e) => rest.onEnterKeyPress?.(e)}isCommentEmpty={isEmpty}isSubmitting={isSubmitting}showAccessSpecifier={showAccessSpecifier}diff --git a/web/core/components/issues/issue-detail/issue-activity/comments/comment-card.tsx b/web/core/components/issues/issue-detail/issue-activity/comments/comment-card.tsxindex 0ea9e8f15b..798964365e 100644--- a/web/core/components/issues/issue-detail/issue-activity/comments/comment-card.tsx+++ b/web/core/components/issues/issue-detail/issue-activity/comments/comment-card.tsx@@ -137,7 +137,11 @@ export const IssueCommentCard: FC<TIssueCommentCard> = observer((props) => {><><form className={`flex-col gap-2 ${isEditing ? "flex" : "hidden"}`}>- <div>+ <div+ onKeyDown={(e) => {+ if (e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey && !isEmpty) handleSubmit(onEnter)(e);+ }}+ ><LiteTextEditorworkspaceId={workspaceId}projectId={projectId}@@ -147,13 +151,9 @@ export const IssueCommentCard: FC<TIssueCommentCard> = observer((props) => {initialValue={watch("comment_html") ?? ""}value={null}onChange={(comment_json, comment_html) => setValue("comment_html", comment_html)}- onEnterKeyPress={(commentHTML) => {- const isCommentEmpty =- commentHTML?.trim() === "" ||- commentHTML === "<p></p>" ||- (isEmptyHtmlString(commentHTML ?? "") && !commentHTML?.includes("mention-component"));- if (!isCommentEmpty && !isSubmitting) {- handleSubmit(onEnter)();+ onEnterKeyPress={(e) => {+ if (!isEmpty && !isSubmitting) {+ handleSubmit(onEnter)(e);}}}showSubmitButton={false}diff --git a/web/core/components/issues/issue-detail/issue-activity/comments/comment-create.tsx b/web/core/components/issues/issue-detail/issue-activity/comments/comment-create.tsxindex 90df745b39..9040ab268b 100644--- a/web/core/components/issues/issue-detail/issue-activity/comments/comment-create.tsx+++ b/web/core/components/issues/issue-detail/issue-activity/comments/comment-create.tsx@@ -33,6 +33,7 @@ export const IssueCommentCreate: FC<TIssueCommentCreate> = (props) => {const {handleSubmit,control,+ watch,formState: { isSubmitting },reset,} = useForm<Partial<TIssueComment>>({@@ -49,8 +50,19 @@ export const IssueCommentCreate: FC<TIssueCommentCreate> = (props) => {editorRef.current?.clearEditor();});+ const commentHTML = watch("comment_html");+ const isEmpty =+ commentHTML?.trim() === "" ||+ commentHTML === "<p></p>" ||+ (isEmptyHtmlString(commentHTML ?? "") && !commentHTML?.includes("mention-component"));+return (- <div>+ <div+ onKeyDown={(e) => {+ if (e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey && !isEmpty && !isSubmitting)+ handleSubmit(onSubmit)(e);+ }}+ ><Controllername="access"control={control}@@ -65,13 +77,9 @@ export const IssueCommentCreate: FC<TIssueCommentCreate> = (props) => {value={"<p></p>"}projectId={projectId}workspaceSlug={workspaceSlug}- onEnterKeyPress={(commentHTML) => {- const isEmpty =- commentHTML?.trim() === "" ||- commentHTML === "<p></p>" ||- (isEmptyHtmlString(commentHTML ?? "") && !commentHTML?.includes("mention-component"));+ onEnterKeyPress={(e) => {if (!isEmpty && !isSubmitting) {- handleSubmit(onSubmit)();+ handleSubmit(onSubmit)(e);}}}ref={editorRef}