From 814a45986634125050e2eaf1d493abdec436e484 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Mon, 14 Oct 2024 10:00:09 +0200 Subject: [PATCH] fix: added solution to delete asset from image vault fields --- remix/app/components/ImageVaultDAM.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/remix/app/components/ImageVaultDAM.tsx b/remix/app/components/ImageVaultDAM.tsx index c7d90f3..6c1d748 100644 --- a/remix/app/components/ImageVaultDAM.tsx +++ b/remix/app/components/ImageVaultDAM.tsx @@ -136,10 +136,11 @@ export default function ImageVaultDAM({ const handleMedia = useCallback( (result?: InsertResponse) => { - if (field && result) { + if (field) { flushSync(() => { - setMedia(result) - field.setData(result) + setMedia(result || null) + // Data inside the field is supposed to be an empty object if nothing is selected + field.setData(result || {}) document.body.style.overflow = "hidden" }) } @@ -197,14 +198,7 @@ export default function ImageVaultDAM({ {media ? ( - { - setMedia(null) - handleMedia() - }} - onEdit={handleEdit} - /> + ) : ( {