You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a Filament resource, and in the create page I have a form with some reactive text fields that perform calculations, and update values on the form. For a little while I was getting odd behaviour like characters being removed, and other 'glitches' as I typed, esp. typing quickly, or deleting characters quickly. I managed to get this under control by using a debounce value of circa 1000ms. This makes sense to me, given the possible clashing of state updates coming from the server if the debounce is too low.
However I've now noticed if I change a reactive text field with the debounce set to 1000ms, and then hit the 'create' or 'save changes' buttons very quickly - as in during that debounce period, I end up not saving the latest data / state. It's fine if I wait over the 1000ms and save but obviously a user will expect to just hit save and all be well.
Is there a way to either force the state on the server to get the latest user entered data and perform any recalculations (things in afterStateUpdated for e.g.) before saving to DB? Or even temp disable the 'create' / 'save changes' buttons on forms until the latest server state is calculated and in the form thus ensuring I always capture the most up-to-date state?
Many thanks!
Lots of love for Filament by the way ❤️
Expected behavior
Always re-calculate the latest state the user can see or disable saving until the state is recalculated.
Steps to reproduce
Here's a little resource form example showing the issue (from the example repo here). The debounce is increased to 10 seconds to more easily show the problem. If you change the text in field 'test' and press save in a FilamentPHP resource before 10 seconds elapse, you will notice no values are saved. If you try again and wait 10 seconds this time, both 'test' and 'test2' fields are saved as expected with 'test2' being a simple copy of 'test' produced from the code in afterStateUpdated.
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('test')
->afterStateUpdated(fn(Set $set, $state) => $set('test2',$state))
->live(debounce: 10000),
Forms\Components\TextInput::make('test2'),
]);
}
Reproduction repository (issue will be closed if this is not valid)
Package
filament/filament
Package Version
v3.2.86
Laravel Version
v11.10.0
Livewire Version
v3.5.0
PHP Version
PHP 8.3.11
Problem description
Hi,
I've got a Filament resource, and in the create page I have a form with some reactive text fields that perform calculations, and update values on the form. For a little while I was getting odd behaviour like characters being removed, and other 'glitches' as I typed, esp. typing quickly, or deleting characters quickly. I managed to get this under control by using a debounce value of circa 1000ms. This makes sense to me, given the possible clashing of state updates coming from the server if the debounce is too low.
However I've now noticed if I change a reactive text field with the debounce set to 1000ms, and then hit the 'create' or 'save changes' buttons very quickly - as in during that debounce period, I end up not saving the latest data / state. It's fine if I wait over the 1000ms and save but obviously a user will expect to just hit save and all be well.
Is there a way to either force the state on the server to get the latest user entered data and perform any recalculations (things in afterStateUpdated for e.g.) before saving to DB? Or even temp disable the 'create' / 'save changes' buttons on forms until the latest server state is calculated and in the form thus ensuring I always capture the most up-to-date state?
Many thanks!
Lots of love for Filament by the way ❤️
Expected behavior
Always re-calculate the latest state the user can see or disable saving until the state is recalculated.
Steps to reproduce
Here's a little resource form example showing the issue (from the example repo here). The debounce is increased to 10 seconds to more easily show the problem. If you change the text in field 'test' and press save in a FilamentPHP resource before 10 seconds elapse, you will notice no values are saved. If you try again and wait 10 seconds this time, both 'test' and 'test2' fields are saved as expected with 'test2' being a simple copy of 'test' produced from the code in afterStateUpdated.
Reproduction repository (issue will be closed if this is not valid)
https://github.com/appymedia/filament-issue
Relevant log output
The text was updated successfully, but these errors were encountered: