diff --git a/src/components/item/form/link/LinkForm.tsx b/src/components/item/form/link/LinkForm.tsx index e2a09d6b8..240477544 100644 --- a/src/components/item/form/link/LinkForm.tsx +++ b/src/components/item/form/link/LinkForm.tsx @@ -161,11 +161,19 @@ const LinkForm = ({ // this is only run once. useEffect( () => { + // this is the object on which we will define the props to be updated + const updatedProps: Partial = {}; + if (!isDescriptionDirty && linkData?.description) { - onChange({ description: linkData?.description }); + updatedProps.description = linkData?.description; } if (linkData?.title) { - onChange({ name: linkData.title }); + updatedProps.name = linkData.title; + } + // update props in one call to remove issue of race updates + if (Object.keys(updatedProps).length) { + // this should be called only once ! + onChange(updatedProps); } }, // eslint-disable-next-line react-hooks/exhaustive-deps @@ -258,17 +266,19 @@ const LinkForm = ({ InputProps={{ endAdornment: ( <> - - - + {isDescriptionDirty ? ( + + + + ) : undefined}