From cfadb5a79393f2287b61a1f29fa6d4b5b319fffb Mon Sep 17 00:00:00 2001 From: Palanikannan1437 <73993394+Palanikannan1437@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:06:08 +0530 Subject: [PATCH] fixed bugs returning empty editor boxes --- web/components/issues/description-form.tsx | 43 ++++++--------- web/components/issues/draft-issue-form.tsx | 39 ++++++-------- .../web-view/issue-web-view-form.tsx | 54 ++++++++----------- 3 files changed, 55 insertions(+), 81 deletions(-) diff --git a/web/components/issues/description-form.tsx b/web/components/issues/description-form.tsx index 505030945..8596d5fe8 100644 --- a/web/components/issues/description-form.tsx +++ b/web/components/issues/description-form.tsx @@ -128,33 +128,24 @@ export const IssueDescriptionForm: FC = ({ { - if (!value) return <>; - - return ( + render={({ field: { value, onChange } }) => ( { - setShowAlert(true); - setIsSubmitting("submitting"); - onChange(description_html); - handleSubmit(handleDescriptionFormSubmit)().finally(() => - setIsSubmitting("submitted") - ); - }} - editable={isAllowed} - /> - ); - }} + uploadFile={fileService.getUploadFileFunction(workspaceSlug)} + deleteFile={fileService.deleteImage} + value={value} + debouncedUpdatesEnabled={true} + setShouldShowAlert={setShowAlert} + setIsSubmitting={setIsSubmitting} + customClassName={isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200"} + noBorder={!isAllowed} + onChange={(description: Object, description_html: string) => { + setShowAlert(true); + setIsSubmitting("submitting"); + onChange(description_html); + handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted") + ); + } } /> + )} />
= (props) => { { - if (!value && !watch("description_html")) return <>; - - return ( + render={({ field: { value, onChange } }) => ( { - onChange(description_html); - setValue("description", description); - }} - /> - ); - }} + uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)} + deleteFile={fileService.deleteImage} + ref={editorRef} + debouncedUpdatesEnabled={false} + value={!value || + value === "" || + (typeof value === "object" && Object.keys(value).length === 0) + ? watch("description_html") + : value} + customClassName="min-h-[150px]" + onChange={(description: Object, description_html: string) => { + onChange(description_html); + setValue("description", description); + } } /> + )} /> = (props) => { { - if (!value) return <>; - - return ( + render={({ field: { value, onChange } }) => (

" - : value - } - debouncedUpdatesEnabled={true} - setShouldShowAlert={setShowAlert} - setIsSubmitting={setIsSubmitting} - customClassName={ - isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200" - } - noBorder={!isAllowed} - onChange={(description: Object, description_html: string) => { - setShowAlert(true); - setIsSubmitting("submitting"); - onChange(description_html); - handleSubmit(handleDescriptionFormSubmit)().finally(() => - setIsSubmitting("submitted") - ); - }} - editable={isAllowed} - /> - ); - }} + uploadFile={fileService.getUploadFileFunction(workspaceSlug as string)} + deleteFile={fileService.deleteImage} + value={!value || + value === "" || + (typeof value === "object" && Object.keys(value).length === 0) + ? "

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