From 5136f3b329538e2b89a49659e8a58f5f260165da Mon Sep 17 00:00:00 2001 From: Palanikannan1437 <73993394+Palanikannan1437@users.noreply.github.com> Date: Tue, 24 Oct 2023 19:52:50 +0530 Subject: [PATCH] fixed debounce logic and extracted the same --- web/components/issues/comment/add-comment.tsx | 31 +------------------ web/components/issues/description-form.tsx | 21 +++++++++---- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/web/components/issues/comment/add-comment.tsx b/web/components/issues/comment/add-comment.tsx index f836efb01..7baca7d61 100644 --- a/web/components/issues/comment/add-comment.tsx +++ b/web/components/issues/comment/add-comment.tsx @@ -7,7 +7,7 @@ import { FileService } from "services/file.service"; // components import { LiteTextEditorWithRef } from "@plane/lite-text-editor"; // ui -import { Button, Tooltip } from "@plane/ui"; +import { Button } from "@plane/ui"; import { Globe2, Lock } from "lucide-react"; // types @@ -72,35 +72,6 @@ export const AddComment: React.FC = ({ disabled = false, onSubmit, showAc
- {showAccessSpecifier && ( -
- ( -
- {commentAccess.map((access) => ( - - - - ))} -
- )} - /> -
- )} = (props) => { }, }); + const [localValue, setLocalValue] = useState(""); + const nameValue = watch("name"); + + useEffect(() => { + if (localValue === "" && nameValue !== "") { + setLocalValue(nameValue); + } + }, [nameValue, localValue]); + const handleDescriptionFormSubmit = useCallback( async (formData: Partial) => { if (!formData?.name || formData?.name.length === 0 || formData?.name.length > 255) return; @@ -81,7 +90,7 @@ export const IssueDescriptionForm: FC = (props) => { }); }, [issue, reset]); - const debouncedTitleSave = useDebouncedCallback(async () => { + const debouncedFormSave = useDebouncedCallback(async () => { handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted")); }, 1500); @@ -92,18 +101,19 @@ export const IssueDescriptionForm: FC = (props) => { ( + render={({ field: { onChange } }) => (