Skip to content

fix(VFileInput): respect form state on drop and paste - #23430

Merged
J-Sek merged 1 commit into
vuetifyjs:masterfrom
ValentinYoushkevich:fix/vfileinput-form-state
Nov 24, 2026
Merged

J-Sek merged 1 commit into
vuetifyjs:masterfrom
ValentinYoushkevich:fix/vfileinput-form-state

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

Description

A v-file-input inside <v-form readonly> still accepts dropped and pasted files, and highlights itself while a file is dragged over it. The same field with its own readonly ignores them. For example, this view/edit dialog relies on the form to make every input read-only, but dropping a certificate onto its file input in view mode still replaces the model. Here's a playground: drop a file on both fields, only B picks it up.

The drag, drop and paste handlers only looked at props.disabled and props.readonly. I switched them to the form state from useForm, the same way VFileUpload does it and the select inputs do since #23375. With disabled the browser already stops real drops and pastes, so the visible change is for readonly.

Markup:

<template>
  <v-app theme="dark">
    <v-container max-width="600">
      <!-- Drop a file from the OS onto each field, or focus it and paste a copied image (Ctrl+V) -->
      <div class="d-flex flex-column ga-4">
        <code>A: field readonly — drop/paste ignored</code>
        <v-file-input
          v-model="fieldFiles"
          label="Attachments"
          multiple
          readonly
        />
        <code>model: {{ names(fieldFiles) }}</code>

        <code>B: form readonly — drop/paste changes the model</code>
        <v-form readonly>
          <v-file-input
            v-model="formFiles"
            label="Attachments"
            multiple
          />
        </v-form>
        <code>model: {{ names(formFiles) }}</code>
      </div>
    </v-container>
  </v-app>
</template>

<script setup>
  import { shallowRef } from 'vue'

  const fieldFiles = shallowRef([])
  const formFiles = shallowRef([])

  function names (files) {
    return files.map(file => file.name)
  }
</script>

The drag, drop and paste handlers only checked the field's own
disabled and readonly props, so a VFileInput inside a readonly or
disabled VForm still accepted dropped and pasted files. Use the form
state from useForm, as VFileUpload already does.
@J-Sek
J-Sek merged commit b506d3f into vuetifyjs:master Nov 24, 2026
9 checks passed
@J-Sek J-Sek added T: bug Functionality that does not work as intended/expected C: VFileInput labels Nov 24, 2026
@J-Sek J-Sek added this to the v4.3.x milestone Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: VFileInput T: bug Functionality that does not work as intended/expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants