From 31e6f1dc3f012e7e1a7062f93241cf44aca4ae50 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Wed, 24 Jan 2024 15:59:32 +0500 Subject: [PATCH] fix upload modal loses its content when closed Remove key from `UploadContainer` that causes component data to be destroyed when modal is closed. Also, `eventReset()` the modal when there is an "immediate" drag-drop upload. --- client/src/components/Upload/DefaultBox.vue | 12 ++++++------ client/src/components/Upload/UploadContainer.vue | 2 +- client/src/components/Upload/UploadModal.vue | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/src/components/Upload/DefaultBox.vue b/client/src/components/Upload/DefaultBox.vue index 31722c9184a0..cba474744251 100644 --- a/client/src/components/Upload/DefaultBox.vue +++ b/client/src/components/Upload/DefaultBox.vue @@ -113,15 +113,15 @@ const queue = new UploadQueue({ }); /** Add files to queue */ -function addFiles(files) { +function addFiles(files, immediate = false) { if (!isRunning.value) { + if (immediate || !props.multiple) { + eventReset(); + } if (props.multiple) { queue.add(files); - } else { - eventReset(); - if (files.length > 0) { - queue.add([files[0]]); - } + } else if (files.length > 0) { + queue.add([files[0]]); } } } diff --git a/client/src/components/Upload/UploadContainer.vue b/client/src/components/Upload/UploadContainer.vue index ba4fa08dbcc6..9c7fe5a742dc 100644 --- a/client/src/components/Upload/UploadContainer.vue +++ b/client/src/components/Upload/UploadContainer.vue @@ -112,7 +112,7 @@ const showRegular = computed(() => !props.formats || hasRegularExtension); const showRules = computed(() => !props.formats || props.multiple); function immediateUpload(files) { - regular.value?.addFiles(files); + regular.value?.addFiles(files, true); } function toData(items, history_id, composite = false) { diff --git a/client/src/components/Upload/UploadModal.vue b/client/src/components/Upload/UploadModal.vue index 8aca0acde0dc..762abcc9afc0 100644 --- a/client/src/components/Upload/UploadModal.vue +++ b/client/src/components/Upload/UploadModal.vue @@ -86,7 +86,6 @@ defineExpose({