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

[Bug]: Livewire property not updated when image removed #4

Open
edwinvdpol opened this issue Jul 21, 2024 · 3 comments
Open

[Bug]: Livewire property not updated when image removed #4

edwinvdpol opened this issue Jul 21, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@edwinvdpol
Copy link

edwinvdpol commented Jul 21, 2024

What happened?

When you remove an image from Filepond, the image itself is deleted from the filesystem, but the Livewire property isn't updated.
When you revert an new uploaded image from Filepond, the Livewire property is removed and generates this error:

Property [$image] not found on component: [...]

It also doesn't delete the file from the temporary directory in this case, because this only happens when the $property is an array.

How to reproduce the bug

When the image already exists and is filled (edit form), and I remove the image (click the X icon), it removed the file from the filesystem. When you inspect the Livewire component data, it is still filled.

When the image is empty, and I upload an image, and click the revert image (the X), it gives the error.

Package Version

1.0.2

PHP Version

8.2.21

Laravel Version

v11.16.0

Which operating systems does with happen with?

macOS

Notes

I added the following line in the remove method in my component, which overwrites the one in the WithFilepond trait.
This works for me, as my property is nullable, not sure how to generally fix it tbh.

...

data_set($this, $property, null);

You could also fire an file-removed event for example when a file is deleted.

Not sure about 'the best' solution. 😉

@edwinvdpol edwinvdpol added the bug Something isn't working label Jul 21, 2024
@riasvdv
Copy link
Member

riasvdv commented Jul 22, 2024

I'd accept a PR that sets the property to null (It should work with just doing $this->$property = null, the property needs to be nullable anyway I think if you want to use Livewire file uploads

@rabol
Copy link

rabol commented Jul 26, 2024

I have a similar issue if the validation of the uploaded file fail, then the error messages is not cleared when the file is deleted

@mbs047
Copy link

mbs047 commented Jul 31, 2024

@edwinvdpol check this #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants