ariaieboy / filament-currency

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

[Bug]: $set does not work, when currencyMask is used #20

Closed dm-lars closed 4 months ago

dm-lars commented 4 months ago

What happened?

I understand that this was an issue in the past (https://github.com/ariaieboy/filament-currency/pull/10?new_signup=true?new_signup=true), but I still can't seem to get it working.

How to reproduce the bug

use ->currencyMask(thousandSeparator: '.', decimalSeparator: ','); on a TextInput component, set the value from a different component using $set.

When inspecting the submitted data after submitting the form I verified that $set indeed adjusted the value on the field, but it's not updated by currencyMask().

Package Version

1.4.0

PHP Version

8.2.0

Laravel Version

10.0.0

Which operating systems does with happen with?

macOS

Notes

No response

ariaieboy commented 4 months ago

If you create a repo that contains minimum code to reproduce this bug I can debug it much much faster. For start, you can use my GitHub.com/ariaieboy/filament-dev-env To create a filament app that contains the codes that reproduce this bug.

dm-lars commented 4 months ago

Hi @ariaieboy ! Thank you for fixing the issue! However, it looks like it created two unwanted (?) side effects.

  1. When I change the value of a TextInput, the thousands separator of the currency mask disappears. So "1.234,56" becomes "1234,56". The currency mask only gets applied again, when the input is loosing focus as I click outside.

  2. If the form now has "managed" input fields (like a disabled "total budget" input, which is updated using $set), there is no way for me to click outside. In that case the currency mask will behave like a toggle. For example, I have two inputs with "1.234,56" and "10,00" and a disabled "total_budget" input that currently displays "1.244,56". When I increment the "10,00" to "20,00" the total budget will be "1254,56" without a thousands separator. If I increment again to "30,00", the total budget becomes "1.264,56" with the separator showing again.

ariaieboy commented 4 months ago

@dm-lars Thanks for your report, I experienced this on my project and will look at it as soon as I find free time.

ariaieboy commented 4 months ago

@dm-lars Test 1.5

dm-lars commented 4 months ago

Seems to work like a charm! Many thanks!