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

Two clicks are required to Save the form on Simple resource with live and placeholder fields #13105

Open skills-up opened 4 months ago

skills-up commented 4 months ago

Package

filament/filament

Package Version

v3.2.82

Laravel Version

v11.8.0

Livewire Version

v3.5.0

PHP Version

PHP 8.2.18

Problem description

When I'm using a simple resource with a few live fields and a Placeholder field, I need to click on Save button twice to save the changes and close the pop-up.

Expected behavior

Single click on Save button should suffice for saving the record and closing the modal.

Steps to reproduce

Create a resource with a few live fields and a Placeholder field whose value is changed on update on any of these live fields. Both live and placeholder fields must be present on the form as there is no issue if either of these are absent. Now change the value of a live field (which will trigger the update of placeholder field). Now edit a record of this resource. Click on Save button (nothing happens). Click on Save button again to save the record and close the modal.

Alternatively, in the linked repository, updated an Order Item.

Reproduction repository

https://github.com/skills-up/demo

Relevant log output

No response

Donate 💰 to fund this issue

Fund with Polar

alexmanase commented 4 months ago

The link to the reproduction repo is not working.

skills-up commented 4 months ago

I've created a new repo for reproduction at https://github.com/skills-up/demo The issue will arise in Order Items on update (not on create).

alexmanase commented 4 months ago

I added a debounce: 200 to the live method, instead of onBlur: true.

skills-up commented 4 months ago

That indeed solved the issue. Though I'm worried about performance impact.

alexmanase commented 4 months ago

The state on the server will be updated after 200ms, after you finished typing on the input.

So you are fine with the performance.

zepfietje commented 4 months ago

Next time please add an actual reproduction repository with clear steps for that specific reproduction project, @skills-up.

I've personally run into this issue too, so I can confirm this is something that needs to be fixed.

skills-up commented 4 months ago

Next time please add an actual reproduction repository with clear steps for that specific reproduction project, @skills-up.

I've personally run into this issue too, so I can confirm this is something that needs to be fixed.

I've updated the original bug report to include the link and step that I had added via a comment.

dmitry-udod commented 4 months ago

The main reason why this happens is because Filament disables the button while your calculation is in progress. And not provide any visual feedback about loading.

https://github.com/filamentphp/filament/assets/4639175/62979ed4-e98a-4b34-92c5-a5e65c6300c8

One possible solution is to preload the price of the item in a hidden field, for example, to speed up calculations.