ariaieboy / filament-currency

Enhanced Currency Related stuff for Filament
MIT License
49 stars 8 forks source link

[Bug]: Losing live attribute when using currencyMask #8

Closed danielreales7 closed 1 year ago

danielreales7 commented 1 year ago

What happened?

When you use the ->currencyMask attribute you lose the ->live attribute

Without ->currencyMask() image

With ->currencyMask() image

How to reproduce the bug

When you use the ->currencyMask attribute you lose the ->live attribute

Package Version

1.1.3

PHP Version

8.1

Laravel Version

10.10

Which operating systems does with happen with?

No response

Notes

No response

ariaieboy commented 1 year ago

We are using the internal filamentpho methods to create our input entangle according to your screenshots the code that genretade passes true as the second option of the entangle that means that the data must be synced live with backend Here is the livewire documentation https://livewire.laravel.com/docs/javascript

If the value is not updating you should create an issue in livewire repository

danielreales7 commented 1 year ago

@ariaieboy It syncs well with the backend but I need it to have a debounce of 500 and it doesn't work.

ariaieboy commented 1 year ago

Did you set the debounce amount in the live method ? https://filamentphp.com/docs/3.x/forms/advanced#debouncing-reactive-fields

danielreales7 commented 1 year ago

Yes @ariaieboy !

TextInput::make('priceWithTax')
                    ->numeric()
                    ->live(debounce: 500)
                    ->suffix('€')
                    ->currencyMask(thousandSeparator: '.',decimalSeparator: ',',precision: 2)

Always makes the call to the backend when I press a key without taking into account the debounce. If I delete ->currencyMask() it's works correctly

ariaieboy commented 1 year ago

We currently use Filament applyStateBindingModifiers helper to create our state binding modifiers. Since Livewire doesn't have the option to change the debounce amount in the entangle method the debounce amount is not used in entangled fields for example the filament markdown editor does not support debouncing too.

danielreales7 commented 1 year ago

@ariaieboy It's curious. I didn't know that. Thank you also for the help, but for example if I want to calculate a price refund automatically when the user writes the quantity, if the user writes too quickly errors occur and the calculation is not done correctly. That's why I wanted to use debounce.

ahmetkocabiyik commented 12 months ago

Same problem i have. If i use live method in any form element to update price field, can't use currenyMask method in price input. If you solve this it will be great.

ariaieboy commented 12 months ago

Same problem i have. If i use live method in any form element to update price field, can't use currenyMask method in price input. If you solve this it will be great.

What is the error ? Create a repo and reproduce the problem