spatie / livewire-filepond

Upload files using Filepond in Livewire components
https://spatie.be/open-source
MIT License
232 stars 18 forks source link

[Bug]: Preview image is still on the filepond area after upload. #28

Closed shadhinplanet closed 3 weeks ago

shadhinplanet commented 1 month ago

What happened?

When we use in a component, after creating/uploading the post, the filepond still showing the previous image that is already uploaded. We need to have a system to reset the preview after uploading/post. so that when new post is creating no preview image is shown.

How to reproduce the bug

When i post a new data with image using filepond, its working fine but when i want to create another post then i can see the image of the previous post is already there as preview. its only disappearing when i refresh the page. but in livewire we don't refresh.

Package Version

1.3

PHP Version

8.2

Laravel Version

11.9

Which operating systems does with happen with?

macOS

Notes

Please have a system to reset according the wire:model reset. so that no preview image is display.

ecmrnn commented 3 weeks ago

Not a fix but a workaround, I solved this issue by adding an event listener 'pond-reset' on the x-init in upload.blade.php file like so:

  this.addEventListener('pond-reset', e => {
      pond.removeFile()
  })

then on my livewire component, I dispatch the event

  $this->dispatch('pond-reset');
khirus commented 3 weeks ago

You can use

$this->dispatch('filepond-reset-<>');

shadhinplanet commented 3 weeks ago

I managed to do the event listener very earlier (the day i post the issue) to solve the issue. Thanks everyone for your help