forked from github/plane
fix: comment box placeholder (#909)
This commit is contained in:
parent
6f03022f65
commit
62dc6c2f3f
@ -1,4 +1,4 @@
|
|||||||
import React, { useMemo } from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
@ -9,10 +9,10 @@ import { mutate } from "swr";
|
|||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from "react-hook-form";
|
||||||
// services
|
// services
|
||||||
import issuesServices from "services/issues.service";
|
import issuesServices from "services/issues.service";
|
||||||
|
// hooks
|
||||||
|
import useToast from "hooks/use-toast";
|
||||||
// ui
|
// ui
|
||||||
import { Loader, SecondaryButton } from "components/ui";
|
import { Loader, SecondaryButton } from "components/ui";
|
||||||
// helpers
|
|
||||||
import { debounce } from "helpers/common.helper";
|
|
||||||
// types
|
// types
|
||||||
import type { IIssueComment } from "types";
|
import type { IIssueComment } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
@ -28,8 +28,8 @@ const RemirrorRichTextEditor = dynamic(() => import("components/rich-text-editor
|
|||||||
});
|
});
|
||||||
|
|
||||||
const defaultValues: Partial<IIssueComment> = {
|
const defaultValues: Partial<IIssueComment> = {
|
||||||
comment_html: "",
|
|
||||||
comment_json: "",
|
comment_json: "",
|
||||||
|
comment_html: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AddComment: React.FC = () => {
|
export const AddComment: React.FC = () => {
|
||||||
@ -42,9 +42,10 @@ export const AddComment: React.FC = () => {
|
|||||||
} = useForm<IIssueComment>({ defaultValues });
|
} = useForm<IIssueComment>({ defaultValues });
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { workspaceSlug, projectId, issueId } = router.query;
|
const { workspaceSlug, projectId, issueId } = router.query;
|
||||||
|
|
||||||
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
const onSubmit = async (formData: IIssueComment) => {
|
const onSubmit = async (formData: IIssueComment) => {
|
||||||
if (
|
if (
|
||||||
!workspaceSlug ||
|
!workspaceSlug ||
|
||||||
@ -61,41 +62,27 @@ export const AddComment: React.FC = () => {
|
|||||||
mutate(PROJECT_ISSUES_ACTIVITY(issueId as string));
|
mutate(PROJECT_ISSUES_ACTIVITY(issueId as string));
|
||||||
reset(defaultValues);
|
reset(defaultValues);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(() =>
|
||||||
console.error(error);
|
setToastAlert({
|
||||||
});
|
type: "error",
|
||||||
|
title: "Error!",
|
||||||
|
message: "Comment could not be posted. Please try again.",
|
||||||
|
})
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateDescription = useMemo(
|
|
||||||
() =>
|
|
||||||
debounce((key: any, val: any) => {
|
|
||||||
setValue(key, val);
|
|
||||||
}, 1000),
|
|
||||||
[setValue]
|
|
||||||
);
|
|
||||||
|
|
||||||
const updateDescriptionHTML = useMemo(
|
|
||||||
() =>
|
|
||||||
debounce((key: any, val: any) => {
|
|
||||||
setValue(key, val);
|
|
||||||
}, 1000),
|
|
||||||
[setValue]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="issue-comments-section" >
|
<div className="issue-comments-section">
|
||||||
<Controller
|
<Controller
|
||||||
name="comment_html"
|
name="comment_json"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field: { value } }) => (
|
render={({ field: { value } }) => (
|
||||||
<RemirrorRichTextEditor
|
<RemirrorRichTextEditor
|
||||||
value={value}
|
value={value}
|
||||||
onBlur={(jsonValue, htmlValue) => {
|
onJSONChange={(jsonValue) => setValue("comment_json", jsonValue)}
|
||||||
setValue("comment_json", jsonValue);
|
onHTMLChange={(htmlValue) => setValue("comment_html", htmlValue)}
|
||||||
setValue("comment_html", htmlValue);
|
|
||||||
}}
|
|
||||||
placeholder="Enter your comment..."
|
placeholder="Enter your comment..."
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user