Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/api-generator/src/locale/en/VFileUpload.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"props": {
"allowPaste": "Enables pasting files directly into the dropzone via Ctrl+V / Cmd+V.",
"browseText": "Text for the browse button.",
"dividerText": "Text in the divider.",
"hideBrowse": "Hides the browse button.",
Expand Down
10 changes: 10 additions & 0 deletions packages/vuetify/src/labs/VFileUpload/VFileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const makeVFileUploadProps = propsFactory({
type: IconValue,
default: '$upload',
},
allowPaste: Boolean,
clearable: Boolean,
insetFileList: Boolean,
hideBrowse: Boolean,
Expand Down Expand Up @@ -181,6 +182,14 @@ export const VFileUpload = genericComponent<VFileUploadSlots>()({
inputRef.value.value = ''
}

function onPaste (e: ClipboardEvent) {
if (!props.allowPaste || props.disabled) return
const files = Array.from(e.clipboardData?.files ?? [])
if (!files.length) return
e.preventDefault()
selectAccepted(files)
}

useRender(() => {
const { modelValue: _, ...inputProps } = VInput.filterProps(props)
const { modelValue: __, ...dropzoneProps } = VFileUploadDropzone.filterProps(props as any)
Expand Down Expand Up @@ -220,6 +229,7 @@ export const VFileUpload = genericComponent<VFileUploadSlots>()({
focused={ isFocused.value }
{ ...rootAttrs }
{ ...inputProps }
onPaste={ props.allowPaste ? onPaste : undefined }
>
{{
...slots,
Expand Down
Loading