Skip to content

Commit

Permalink
fix(dashboardeditor): support clearing the image and changing
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdickerson committed Dec 8, 2020
1 parent 948469b commit 2cc309b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ const ImageCardFormItems = ({ cardConfig, i18n, onChange }) => {
onClick={() =>
// close means clear the image info out of the JSON
onChange(
omit(cardConfig, 'content.id', 'content.src', 'content.alt')
omit(
cardConfig,
'content.id',
'content.src',
'content.alt',
'content.imgState'
)
)
}
/>
Expand Down
10 changes: 6 additions & 4 deletions src/components/DashboardEditor/DashboardEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,12 @@ const DashboardEditor = ({
cardConfig.content.imgState === 'new' &&
!imagesToUpload.some((image) => image.id === cardConfig.content.id)
) {
setImagesToUpload((prevImagesToUpload) => [
...prevImagesToUpload,
{ id: cardConfig.content.id, src: cardConfig.content.src },
]);
if (cardConfig.content.id && cardConfig.content.src) {
setImagesToUpload((prevImagesToUpload) => [
...prevImagesToUpload,
{ id: cardConfig.content.id, src: cardConfig.content.src },
]);
}
}

// TODO: this is really inefficient
Expand Down

0 comments on commit 2cc309b

Please sign in to comment.