fix: remirror image not updating (#294)

This commit is contained in:
Aaryan Khandelwal 2023-02-17 16:57:31 +05:30 committed by GitHub
parent 1665863bd9
commit 4b068398bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 37 deletions

View file

@ -49,7 +49,7 @@ const defaultValues: Partial<IIssue> = {
};
export interface IssueFormProps {
handleFormSubmit: (values: Partial<IIssue>) => void;
handleFormSubmit: (values: Partial<IIssue>) => Promise<void>;
initialData?: Partial<IIssue>;
issues: IIssue[];
projectId: string;
@ -107,17 +107,18 @@ export const IssueForm: FC<IssueFormProps> = ({
reset({
...defaultValues,
project: projectId,
description: "",
description_html: "<p></p>",
});
};
useEffect(() => {
reset({
...defaultValues,
...watch(),
project: projectId,
...initialData,
project: projectId,
});
}, [initialData, reset, watch, projectId]);
}, [initialData, reset, projectId]);
return (
<>
@ -238,13 +239,11 @@ export const IssueForm: FC<IssueFormProps> = ({
<Controller
name="description"
control={control}
render={({ field: { value, onChange } }) => (
render={({ field: { value } }) => (
<RemirrorRichTextEditor
value={value}
onBlur={(jsonValue, htmlValue) => {
setValue("description", jsonValue);
setValue("description_html", htmlValue);
}}
onJSONChange={(jsonValue) => setValue("description", jsonValue)}
onHTMLChange={(htmlValue) => setValue("description_html", htmlValue)}
placeholder="Enter Your Text..."
/>
)}