koumoul-dev / vuetify-jsonschema-form

Create beautiful and low-effort forms that output valid data. Published on npm as @koumoul/vjsf.
https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/
MIT License
538 stars 154 forks source link

Adding empty/null check for file upload #407

Open harshitkathuria opened 1 year ago

harshitkathuria commented 1 year ago

For a file upload (v-file-input) component, we have an option for removing the selected file. Actual Behaviour: But here, when we remove the selected file from file upload input, we get an error stating TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob', and state remains the same. Expected Behaviour: The new state value should be empty.

This is because of the current code structure in lib/mixins/FileProperty.js, wherein if there is no file selected, an error is thrown (from getFileDataUrl method), and the input and change method of the file input component is not called, and thus the state remains unchanged. Perhaps we can include an empty check case when removing the selected file, so that the new state value is updated accordingly.