Skip to content

Commit 7711130

Browse files
committed
fix: change Dropzone div to form and add clear function
1 parent fe1bff2 commit 7711130

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

adminforth/spa/src/afcl/Dropzone.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex items-center justify-center w-full"
2+
<form class="flex items-center justify-center w-full"
33
@dragover.prevent="dragging = true"
44
@dragleave.prevent="dragging = false"
55
@drop.prevent="dragging = false; doEmit($event.dataTransfer.files)"
@@ -43,12 +43,12 @@
4343
:multiple="props.multiple || false"
4444
/>
4545
</label>
46-
</div>
46+
</form>
4747
</template>
4848

4949
<script setup lang="ts">
5050
import { humanifySize } from '@/utils';
51-
import { ref, type Ref } from 'vue';
51+
import { ref, defineExpose, type Ref } from 'vue';
5252
import { IconFileSolid } from '@iconify-prerendered/vue-flowbite';
5353
import { watch } from 'vue';
5454
import adminforth from '@/adminforth';
@@ -125,4 +125,14 @@ function doEmit(filesIn: FileList) {
125125
126126
const dragging = ref(false);
127127
128+
function clear() {
129+
selectedFiles.value = [];
130+
emit('update:modelValue', []);
131+
const form = document.getElementById(id)?.closest('form');
132+
form?.reset();
133+
}
134+
135+
defineExpose({
136+
clear,
137+
});
128138
</script>

0 commit comments

Comments
 (0)