🐛 fix: bugs fixed

This commit is contained in:
Paul Valerie GOMA 2025-07-26 15:07:48 +02:00
parent 0ca59dbc59
commit fbfa6e33fc

View File

@ -9,14 +9,12 @@ import VMessage from '../message/VMessage.vue';
import VScrollpanel from '../scrollpanel/VScrollpanel.vue'; import VScrollpanel from '../scrollpanel/VScrollpanel.vue';
import type IVFileUpload from './IVFileUpload.type'; import type IVFileUpload from './IVFileUpload.type';
import type { FileUploadErrorEvent, FileUploadProgressEvent, FileUploadRemoveEvent, FileUploadSelectEvent, FileUploadUploadEvent } from 'primevue/fileupload'; 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'; import styles from '@visua/typography.module.css';
const fileUploadRef = ref(); const fileUploadRef = ref();
const fileProgressMap = ref<Record<string, number>>({}); const fileProgressMap = ref<Record<string, number>>({});
const fileSelected = ref(false);
const hasActiveError = ref(false); const hasActiveError = ref(false);
const lastSelectedFile = ref<File | null>(null);
defineOptions({ defineOptions({
inheritAttrs: false, inheritAttrs: false,
@ -67,15 +65,12 @@ const handleSelect = (event: FileUploadSelectEvent) => {
emit('select', event); emit('select', event);
if (!props.advanced && event.files.length > 0 && fileUploadRef.value) { if (!props.advanced && event.files.length > 0 && fileUploadRef.value) {
fileUploadRef.value.files = [event.files.at(-1)]; fileUploadRef.value.files = [event.files.at(-1)];
lastSelectedFile.value = event.files.at(-1); fileUploadRef.value.uploadedFiles = [];
} }
fileSelected.value = true;
}; };
const handleClear = () => { const handleClear = () => {
emit('clear'); emit('clear');
fileSelected.value = false;
lastSelectedFile.value = null;
hasActiveError.value = false; hasActiveError.value = false;
}; };
@ -85,8 +80,6 @@ const handleUpload = (event: FileUploadUploadEvent) => {
const handleRemove = (event: FileUploadRemoveEvent) => { const handleRemove = (event: FileUploadRemoveEvent) => {
emit('remove', event); emit('remove', event);
fileSelected.value = false;
lastSelectedFile.value = null;
hasActiveError.value =false; hasActiveError.value =false;
}; };
@ -104,15 +97,16 @@ const handleError = (event: FileUploadErrorEvent) => {
hasActiveError.value = true; hasActiveError.value = true;
} }
const lastSelectedFile = computed(() => {
const files = fileUploadRef.value?.files || [];
return files.at(-1) ?? null;
});
const uploadEvent = (callback: () => void) => { const uploadEvent = (callback: () => void) => {
callback(); callback();
}; };
onMounted(() => {
const currentFiles = fileUploadRef.value?.files || [];
fileSelected.value = currentFiles.length > 0;
});
const padding = computed(() => props.advanced ? '1.125rem' : '0rem') const padding = computed(() => props.advanced ? '1.125rem' : '0rem')
const borderColor = computed(() => props.advanced ? 'var(--border-default-grey)' : 'transparent'); const borderColor = computed(() => props.advanced ? 'var(--border-default-grey)' : 'transparent');