From 57b98abd2044c1ecf8d3dfe3d603896ccd107b95 Mon Sep 17 00:00:00 2001 From: spaenleh Date: Tue, 21 May 2024 16:26:35 +0200 Subject: [PATCH] fix: update ui --- src/components/item/form/link/LinkForm.tsx | 36 ++-- yarn.lock | 199 +++++++++++---------- 2 files changed, 123 insertions(+), 112 deletions(-) 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}