filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.71k stars 2.91k forks source link

afterStateUpdated() is run twice when testing file upload #13776

Open sinnbeck opened 2 months ago

sinnbeck commented 2 months ago

Package

filament/forms

Package Version

v3.2.97

Laravel Version

v10.48.18

Livewire Version

No response

PHP Version

PHP 8.2

Problem description

When testing a component with a file upload component in it, the afterStateUpdated() method gets called twice. It does not, in the browser.

I ran into the issue when removing files on validation errors (scanning for virus). The second time it is then called, it replaces the file with null (another bug I think?), which then breaks the file validation as null isn't allowed in the array.

Expected behavior

Dont call the afterStateUpdated() twice

Steps to reproduce

Use the file upload in a form with afterStateUpdated() and have a test that fills it out.

Run vendor/bin/pest and see that it outputs CALLED twice

Reproduction repository (issue will be closed if this is not valid)

https://github.com/sinnbeck/filament-upload-test-issue

Relevant log output

No response

Donate 💰 to fund this issue

Fund with Polar

sinnbeck commented 2 months ago

If I downgrade to v3.2.76 the issue goes away. I believe it was introduced in v3.2.83 to try and fix a bug introduced in v3.2.77

zepfietje commented 2 months ago

Could you please check if this issue still exists in the latest version of Filament v3.2.97), @sinnbeck?

sinnbeck commented 2 months ago

@zepfietje Sadly it is still an issue in 3.2.97. The repo I linked was tested with that version :)

zepfietje commented 2 months ago

Thanks for checking, @sinnbeck!