From fbfa6e33fcceb06d8971df4fdd3b5868926fe575 Mon Sep 17 00:00:00 2001 From: Paul Valerie GOMA Date: Sat, 26 Jul 2025 15:07:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20bugs=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/file/VFileUpload.vue | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/components/file/VFileUpload.vue b/src/components/file/VFileUpload.vue index 31f596c..cf6cfbf 100644 --- a/src/components/file/VFileUpload.vue +++ b/src/components/file/VFileUpload.vue @@ -9,14 +9,12 @@ import VMessage from '../message/VMessage.vue'; import VScrollpanel from '../scrollpanel/VScrollpanel.vue'; import type IVFileUpload from './IVFileUpload.type'; import type { FileUploadErrorEvent, FileUploadProgressEvent, FileUploadRemoveEvent, FileUploadSelectEvent, FileUploadUploadEvent } from 'primevue/fileupload'; -import { computed, useId, ref, onMounted } from 'vue'; +import { computed, useId, ref } from 'vue'; import styles from '@visua/typography.module.css'; const fileUploadRef = ref(); const fileProgressMap = ref>({}); -const fileSelected = ref(false); const hasActiveError = ref(false); -const lastSelectedFile = ref(null); defineOptions({ inheritAttrs: false, @@ -67,15 +65,12 @@ const handleSelect = (event: FileUploadSelectEvent) => { emit('select', event); if (!props.advanced && event.files.length > 0 && fileUploadRef.value) { fileUploadRef.value.files = [event.files.at(-1)]; - lastSelectedFile.value = event.files.at(-1); + fileUploadRef.value.uploadedFiles = []; } - fileSelected.value = true; }; const handleClear = () => { emit('clear'); - fileSelected.value = false; - lastSelectedFile.value = null; hasActiveError.value = false; }; @@ -85,8 +80,6 @@ const handleUpload = (event: FileUploadUploadEvent) => { const handleRemove = (event: FileUploadRemoveEvent) => { emit('remove', event); - fileSelected.value = false; - lastSelectedFile.value = null; hasActiveError.value =false; }; @@ -104,15 +97,16 @@ const handleError = (event: FileUploadErrorEvent) => { hasActiveError.value = true; } +const lastSelectedFile = computed(() => { + const files = fileUploadRef.value?.files || []; + return files.at(-1) ?? null; +}); + + const uploadEvent = (callback: () => void) => { callback(); }; -onMounted(() => { - const currentFiles = fileUploadRef.value?.files || []; - fileSelected.value = currentFiles.length > 0; -}); - const padding = computed(() => props.advanced ? '1.125rem' : '0rem') const borderColor = computed(() => props.advanced ? 'var(--border-default-grey)' : 'transparent');