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,33 +128,24 @@ 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}
value={value} 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}
} onChange={(description: Object, description_html: string) => {
noBorder={!isAllowed} setShowAlert(true);
onChange={(description: Object, description_html: string) => { setIsSubmitting("submitting");
setShowAlert(true); onChange(description_html);
setIsSubmitting("submitting"); handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted")
onChange(description_html); );
handleSubmit(handleDescriptionFormSubmit)().finally(() => } } />
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]"
} onChange={(description: Object, description_html: string) => {
customClassName="min-h-[150px]" onChange(description_html);
onChange={(description: Object, description_html: string) => { setValue("description", description);
onChange(description_html); } } />
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}
} setShouldShowAlert={setShowAlert}
debouncedUpdatesEnabled={true} setIsSubmitting={setIsSubmitting}
setShouldShowAlert={setShowAlert} customClassName={isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200"}
setIsSubmitting={setIsSubmitting} noBorder={!isAllowed}
customClassName={ onChange={(description: Object, description_html: string) => {
isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200" setShowAlert(true);
} setIsSubmitting("submitting");
noBorder={!isAllowed} onChange(description_html);
onChange={(description: Object, description_html: string) => { handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted")
setShowAlert(true); );
setIsSubmitting("submitting"); } }
onChange(description_html); editable={isAllowed} />
handleSubmit(handleDescriptionFormSubmit)().finally(() => )}
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 ${ 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 ${