Skip to content

Commit

Permalink
fix: update ui
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed May 22, 2024
1 parent f5f42b8 commit 5cc6802
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 112 deletions.
36 changes: 23 additions & 13 deletions src/components/item/form/link/LinkForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DiscriminatedItem> = {};

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
Expand Down Expand Up @@ -258,17 +266,19 @@ const LinkForm = ({
InputProps={{
endAdornment: (
<>
<IconButton
onClick={onClickRestoreDefaultDescription}
sx={{
visibility:
description !== linkData?.description
? 'visible'
: 'hidden',
}}
>
<Undo2Icon size="20" />
</IconButton>
{isDescriptionDirty ? (
<IconButton
onClick={onClickRestoreDefaultDescription}
sx={{
visibility:
description !== linkData?.description
? 'visible'
: 'hidden',
}}
>
<Undo2Icon size="20" />
</IconButton>
) : undefined}
<IconButton
onClick={onClickClearDescription}
sx={{
Expand Down
Loading

0 comments on commit 5cc6802

Please sign in to comment.