update selection details on change

This commit is contained in:
2023-07-27 15:07:24 +10:00
parent dd8e59cd4f
commit ab25b0f64a

View File

@@ -769,6 +769,7 @@ const handleFilesUpload = (files: FileList) => {
status: "", status: "",
storage: "", storage: "",
url: "", url: "",
thumbnail: "",
description: "", description: "",
dimensions: "", dimensions: "",
variants: {}, variants: {},
@@ -987,6 +988,22 @@ watch(page, () => {
handleLoad(); handleLoad();
}); });
watch(mediaItems, () => {
selected.value = selected.value.map((selectedItem) => {
const matchingMediaItem = mediaItems.value.find(
(mediaItem) => mediaItem.id === selectedItem.id,
);
return matchingMediaItem || selectedItem;
});
if (lastSelected.value) {
lastSelected.value =
mediaItems.value.find(
(mediaItem) => mediaItem.id === lastSelected.value.id,
) || lastSelected.value;
}
});
/** /**
* Determine if the Select button should be disabled * Determine if the Select button should be disabled
*/ */