Skip to content

Commit eb95c9e

Browse files
Abdulqudus001J-Sek
authored andcommitted
fix(VFileUpload): adding/replacing files with dropzone click (#22741)
- drop area should still be clickable after file selection (unless it shows the files within) - accidental click should not clear the field (this behavior is aligned with other UI frameworks) resolves #22737
1 parent 1cdd9c4 commit eb95c9e

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

packages/vuetify/src/labs/VFileUpload/VFileUpload.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,14 @@ export const VFileUpload = genericComponent<VFileUploadSlots>()({
136136

137137
function onFileSelection (e: Event) {
138138
if (!e.target || (e as any).repack) return // prevent loop
139+
const target = e.target as HTMLInputElement
140+
const selectedFiles = [...target.files ?? []]
141+
if (!selectedFiles.length) return
139142

140143
if (!props.filterByType) {
141-
const target = e.target as HTMLInputElement
142-
const newFiles = [...target.files ?? []]
143-
model.value = props.multiple ? [...model.value, ...newFiles] : newFiles
144+
model.value = props.multiple ? [...model.value, ...selectedFiles] : selectedFiles
144145
} else {
145-
selectAccepted([...(e as any).target.files])
146+
selectAccepted(selectedFiles)
146147
}
147148
}
148149

packages/vuetify/src/labs/VFileUpload/VFileUploadDropzone.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export const VFileUploadDropzone = genericComponent<VFileUploadDropzoneSlots>()(
181181
class={[
182182
'v-file-upload-dropzone',
183183
{
184-
'v-file-upload-dropzone--clickable': !hasBrowse && !hasFiles,
184+
'v-file-upload-dropzone--clickable': !hasBrowse,
185185
'v-file-upload-dropzone--disabled': disabled,
186186
'v-file-upload-dropzone--dragging': isDragging.value,
187187
'v-file-upload-dropzone--has-files': hasFiles,
@@ -195,7 +195,7 @@ export const VFileUploadDropzone = genericComponent<VFileUploadDropzoneSlots>()(
195195
onDragleave={ onDragleave }
196196
onDragover={ onDragover }
197197
onDrop={ onDrop }
198-
onClick={ !hasBrowse && !hasFiles ? onClickBrowse : undefined }
198+
onClick={ !hasBrowse && !(isInset && hasFiles) ? onClickBrowse : undefined }
199199
>
200200
{ slots.default?.({
201201
isDragging: isDragging.value,

0 commit comments

Comments
 (0)