koumoul-dev / vuetify-jsonschema-form

Create beautiful and low-effort forms that output valid data. Published on npm as @koumoul/vjsf.

Home Page:https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding empty/null check for file upload

harshitkathuria opened this issue · comments

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.