Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model not updating on Field type file #3911

Closed
devsalsa opened this issue Sep 1, 2022 · 4 comments
Closed

Model not updating on Field type file #3911

devsalsa opened this issue Sep 1, 2022 · 4 comments
Labels
🐛 bug Unintended behavior

Comments

@devsalsa
Copy link

devsalsa commented Sep 1, 2022

We have a cropper component that updates a Field type file each time you resize/move the uploaded image. The Field is pretty basic:

<Field :name="name" id="file-upload" v-model="model" type="file" class="hidden" rules="isImage" />

We are using that same exact component on two different repositories but there is a slight difference:

  • on the first repository, we use vee-validate version 4.5.11 and everything works perfectly, the v-model is correctly updated each time the cropper updates the model.
  • on the second repository, we use vee-validate version 4.6 and the v-model is not updated anymore when the cropper updates the model.

I will take time tomorrow to create a demo to reproduce the issue but any idea that could explain the problem we encounter? I saw a bug fix on the 4.6 release for Field type file, not sure if this could affect in some way our current component.

Here is a demo: https://stackblitz.com/edit/vue-vee-input-file (it is a bit raw but basically you can submit the form to see if the file changes).

@logaretm
Copy link
Owner

logaretm commented Sep 6, 2022

This could be related to the new auto v-model support in this one but for <Field> component it shouldn't break anything, I might be wrong tho.

I'm not sure I understand the issue, can you elaborate more, please? I tried both 4.5 and 4.6 in your example and I'm not sure if there is a difference.

@devsalsa
Copy link
Author

devsalsa commented Sep 6, 2022

Steps to reproduce (the result is noticeable in the browser console):

  • I just load the example, wait for the preview image to appear below the cropper, and submit (first console.log in my screenshots below)
  • I crop the image, wait for the preview to update, and submit it again (second console.log).

With 4.6, the model is not updated, the image size doesn't change even after being cropped:

Desktop-screenshot (2)

With 4.5, the model is updated, the image size changes after being cropped:

Desktop-screenshot-1-

@logaretm logaretm added the 🐛 bug Unintended behavior label Sep 18, 2022
@logaretm
Copy link
Owner

Thanks for the clarification, and sorry about the delay.

This is indeed a bug, because we use 'fast-deep-equal' to test equality which doesn't work well for files.

The fix will be tagged in the next release later today.

@logaretm
Copy link
Owner

closed by #3932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant