Skip to content

Commit

Permalink
fix: reset button undefined when no target
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Jun 23, 2024
1 parent 13012ae commit 2d0026c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions packages/volto/src/components/manage/Blocks/Teaser/Data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,20 @@ const TeaserData = (props) => {
};

const refresh = () => {
dispatch(
getContent(flattenToAppURL(data.href[0]['@id']), null, `${block}-teaser`),
).then((resp) => {
if (resp) {
let blockData = dataTransformer(resp, data);
onChangeBlock(block, blockData);
}
});
if (data.href?.[0]?.['@id']) {
dispatch(
getContent(
flattenToAppURL(data.href[0]['@id']),
null,
`${block}-teaser`,
),
).then((resp) => {
if (resp) {
let blockData = dataTransformer(resp, data);
onChangeBlock(block, blockData);
}
});
}
};

const isReseteable =
Expand All @@ -102,6 +108,7 @@ const TeaserData = (props) => {
aria-label={intl.formatMessage(messages.refreshTeaser)}
basic
onClick={() => refresh()}
disabled={isEmpty(data.href)}
>
{intl.formatMessage(messages.refreshTeaser)}
<Icon name={reloadSVG} size="20px" color="#00000099" />
Expand Down

0 comments on commit 2d0026c

Please sign in to comment.