fix: debounce logic in issue detail and description

This commit is contained in:
Henit Chobisa 2023-12-08 16:45:04 +05:30 committed by rahulramesha
parent 01874cb2db
commit fffcb2d947
2 changed files with 14 additions and 6 deletions

View File

@ -102,9 +102,13 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = (props) => {
}); });
}, [issue, reset]); }, [issue, reset]);
const debouncedFormSave = debounce(async () => { // ADDING handleDescriptionFormSubmit TO DEPENDENCY ARRAY PRODUCES ADVERSE EFFECTS
handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted")); const debouncedFormSave = useCallback(
}, 1500); debounce(async () => {
handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted"));
}, 1500),
[handleSubmit]
);
return ( return (
<div className="relative"> <div className="relative">

View File

@ -96,9 +96,13 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
} }
}, [issue.id]); }, [issue.id]);
const debouncedFormSave = debounce(async () => { // ADDING handleDescriptionFormSubmit TO DEPENDENCY ARRAY PRODUCES ADVERSE EFFECTS
handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted")); const debouncedFormSave = useCallback(
}, 1500); debounce(async () => {
handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted"));
}, 1500),
[handleSubmit]
);
useEffect(() => { useEffect(() => {
if (isSubmitting === "submitted") { if (isSubmitting === "submitted") {