fixed bugs returning empty editor boxes

This commit is contained in:
Palanikannan1437 2023-10-04 23:06:08 +05:30
parent a6b0ef221f
commit cfadb5a793
3 changed files with 55 additions and 81 deletions

View File

@ -128,10 +128,7 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
<Controller <Controller
name="description_html" name="description_html"
control={control} control={control}
render={({ field: { value, onChange } }) => { render={({ field: { value, onChange } }) => (
if (!value) return <></>;
return (
<RichTextEditor <RichTextEditor
uploadFile={fileService.getUploadFileFunction(workspaceSlug)} uploadFile={fileService.getUploadFileFunction(workspaceSlug)}
deleteFile={fileService.deleteImage} deleteFile={fileService.deleteImage}
@ -139,22 +136,16 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
debouncedUpdatesEnabled={true} debouncedUpdatesEnabled={true}
setShouldShowAlert={setShowAlert} setShouldShowAlert={setShowAlert}
setIsSubmitting={setIsSubmitting} setIsSubmitting={setIsSubmitting}
customClassName={ customClassName={isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200"}
isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200"
}
noBorder={!isAllowed} noBorder={!isAllowed}
onChange={(description: Object, description_html: string) => { onChange={(description: Object, description_html: string) => {
setShowAlert(true); setShowAlert(true);
setIsSubmitting("submitting"); setIsSubmitting("submitting");
onChange(description_html); onChange(description_html);
handleSubmit(handleDescriptionFormSubmit)().finally(() => handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted")
setIsSubmitting("submitted")
); );
}} } } />
editable={isAllowed} )}
/>
);
}}
/> />
<div <div
className={`absolute right-5 bottom-5 text-xs text-custom-text-200 border border-custom-border-400 rounded-xl w-[6.5rem] py-1 z-10 flex items-center justify-center ${isSubmitting === "saved" ? "fadeOut" : "fadeIn" className={`absolute right-5 bottom-5 text-xs text-custom-text-200 border border-custom-border-400 rounded-xl w-[6.5rem] py-1 z-10 flex items-center justify-center ${isSubmitting === "saved" ? "fadeOut" : "fadeIn"

View File

@ -414,30 +414,23 @@ export const DraftIssueForm: FC<IssueFormProps> = (props) => {
<Controller <Controller
name="description_html" name="description_html"
control={control} control={control}
render={({ field: { value, onChange } }) => { render={({ field: { value, onChange } }) => (
if (!value && !watch("description_html")) return <></>;
return (
<RichTextEditorWithRef <RichTextEditorWithRef
uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)} uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)}
deleteFile={fileService.deleteImage} deleteFile={fileService.deleteImage}
ref={editorRef} ref={editorRef}
debouncedUpdatesEnabled={false} debouncedUpdatesEnabled={false}
value={ value={!value ||
!value ||
value === "" || value === "" ||
(typeof value === "object" && Object.keys(value).length === 0) (typeof value === "object" && Object.keys(value).length === 0)
? watch("description_html") ? watch("description_html")
: value : value}
}
customClassName="min-h-[150px]" customClassName="min-h-[150px]"
onChange={(description: Object, description_html: string) => { onChange={(description: Object, description_html: string) => {
onChange(description_html); onChange(description_html);
setValue("description", description); setValue("description", description);
}} } } />
/> )}
);
}}
/> />
<GptAssistantModal <GptAssistantModal
isOpen={gptAssistantModal} isOpen={gptAssistantModal}

View File

@ -119,39 +119,29 @@ export const IssueWebViewForm: React.FC<Props> = (props) => {
<Controller <Controller
name="description_html" name="description_html"
control={control} control={control}
render={({ field: { value, onChange } }) => { render={({ field: { value, onChange } }) => (
if (!value) return <></>;
return (
<RichTextEditor <RichTextEditor
uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)} uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)}
deleteFile={fileService.deleteImage} deleteFile={fileService.deleteImage}
value={ value={!value ||
!value ||
value === "" || value === "" ||
(typeof value === "object" && Object.keys(value).length === 0) (typeof value === "object" && Object.keys(value).length === 0)
? "<p></p>" ? "<p></p>"
: value : value}
}
debouncedUpdatesEnabled={true} debouncedUpdatesEnabled={true}
setShouldShowAlert={setShowAlert} setShouldShowAlert={setShowAlert}
setIsSubmitting={setIsSubmitting} setIsSubmitting={setIsSubmitting}
customClassName={ customClassName={isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200"}
isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200"
}
noBorder={!isAllowed} noBorder={!isAllowed}
onChange={(description: Object, description_html: string) => { onChange={(description: Object, description_html: string) => {
setShowAlert(true); setShowAlert(true);
setIsSubmitting("submitting"); setIsSubmitting("submitting");
onChange(description_html); onChange(description_html);
handleSubmit(handleDescriptionFormSubmit)().finally(() => handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted")
setIsSubmitting("submitted")
);
}}
editable={isAllowed}
/>
); );
} } } }
editable={isAllowed} />
)}
/> />
<div <div
className={`absolute right-5 bottom-5 text-xs text-custom-text-200 border border-custom-border-400 rounded-xl w-[6.5rem] py-1 z-10 flex items-center justify-center ${ className={`absolute right-5 bottom-5 text-xs text-custom-text-200 border border-custom-border-400 rounded-xl w-[6.5rem] py-1 z-10 flex items-center justify-center ${