Skip to content

Commit

Permalink
fix upload modal loses its content when closed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ahmedhamidawan committed Jan 24, 2024
1 parent 77d57ec commit 31e6f1d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions client/src/components/Upload/DefaultBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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]]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Upload/UploadContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion client/src/components/Upload/UploadModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ defineExpose({
<UploadContainer
v-if="currentHistoryId"
ref="content"
:key="showModal"
:current-user-id="currentUser?.id"
:current-history-id="currentHistoryId"
v-bind="options"
Expand Down

0 comments on commit 31e6f1d

Please sign in to comment.