Skip to content

Commit 507f1b0

Browse files
fix(VFileInput): trigger onInput after value has changed (#9091)
* fix(VFileInput): trigger onInput after value has changed fixes: #9045 * Update VFileInput.ts * Styling * Update packages/vuetify/src/components/VFileInput/VFileInput.ts Co-Authored-By: John Leider <[email protected]>
1 parent ac7136d commit 507f1b0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/vuetify/src/components/VFileInput/VFileInput.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { VChip } from '../VChip'
1111
import { PropValidator } from 'vue/types/options'
1212

1313
// Utilities
14-
import { humanReadableFileSize, wrapInArray } from '../../util/helpers'
14+
import { deepEqual, humanReadableFileSize, wrapInArray } from '../../util/helpers'
1515
import { consoleError } from '../../util/console'
1616

1717
export default VTextField.extend({
@@ -141,6 +141,17 @@ export default VTextField.extend({
141141
},
142142
immediate: true,
143143
},
144+
value (v) {
145+
const value = this.isMultiple ? v : v ? [v] : []
146+
if (!deepEqual(value, this.$refs.input.files)) {
147+
// When the input value is changed programatically, clear the
148+
// internal input's value so that the `onInput` handler
149+
// can be triggered again if the user re-selects the exact
150+
// same file(s). Ideally, `input.files` should be
151+
// manipulated directly but that property is readonly.
152+
this.$refs.input.value = ''
153+
}
154+
},
144155
},
145156

146157
methods: {

0 commit comments

Comments
 (0)