fix: description autosave fixes

This commit is contained in:
sriram veeraghanta 2024-02-19 12:54:45 +05:30
parent 170f30c7dd
commit 17e5663e81

View File

@ -38,23 +38,22 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
const workspaceId = getWorkspaceBySlug(workspaceSlug)?.id as string; const workspaceId = getWorkspaceBySlug(workspaceSlug)?.id as string;
useEffect(() => { useEffect(() => {
if (value) setDescriptionHTML(value); setDescriptionHTML(value);
}, [value]); }, [value]);
useEffect(() => { useEffect(() => {
if (debouncedValue && debouncedValue !== value) { if (debouncedValue && debouncedValue !== value) {
setIsSubmitting("submitted");
issueOperations issueOperations
.update(workspaceSlug, projectId, issueId, { description_html: debouncedValue }, false) .update(workspaceSlug, projectId, issueId, { description_html: debouncedValue }, false)
.finally(() => { .finally(() => {
setIsSubmitting("saved"); setIsSubmitting("submitted");
}); });
} }
// DO NOT Add more dependencies here. It will cause multiple requests to be sent. // DO NOT Add more dependencies here. It will cause multiple requests to be sent.
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [debouncedValue]); }, [debouncedValue]);
if (!descriptionHTML && descriptionHTML !== "") { if (!descriptionHTML) {
return ( return (
<Loader> <Loader>
<Loader.Item height="150px" /> <Loader.Item height="150px" />
@ -79,13 +78,13 @@ export const IssueDescriptionInput: FC<IssueDescriptionInputProps> = observer((p
uploadFile={fileService.getUploadFileFunction(workspaceSlug)} uploadFile={fileService.getUploadFileFunction(workspaceSlug)}
deleteFile={fileService.getDeleteImageFunction(workspaceId)} deleteFile={fileService.getDeleteImageFunction(workspaceId)}
restoreFile={fileService.getRestoreImageFunction(workspaceId)} restoreFile={fileService.getRestoreImageFunction(workspaceId)}
value={descriptionHTML} value={descriptionHTML === "" ? "<p></p>" : descriptionHTML}
initialValue={initialValue} initialValue={initialValue}
dragDropEnabled dragDropEnabled
customClassName="min-h-[150px] shadow-sm" customClassName="min-h-[150px] shadow-sm"
onChange={(description: Object, description_html: string) => { onChange={(description: Object, description_html: string) => {
setIsSubmitting("submitting"); setIsSubmitting("submitting");
setDescriptionHTML(description_html); setDescriptionHTML(description_html === "" ? "<p></p>" : description_html);
}} }}
mentionSuggestions={mentionSuggestions} mentionSuggestions={mentionSuggestions}
mentionHighlights={mentionHighlights} mentionHighlights={mentionHighlights}