leandrocfe / filament-ptbr-form-fields

This package provides custom form fields for Filament (>=v2.17.28) that are commonly used in Brazilian web applications, such as CPF/CNPJ validation, phone number formatting, money with currency symbol, and CEP integration with ViaCep.
MIT License
90 stars 11 forks source link

[Bug]: Utilização do componente Money em live() com Placeholder #10

Open mliell opened 10 months ago

mliell commented 10 months ago

What happened?

Ao utilizar o componente Money e obter um get em um Placeholder o mesmo está retornando valores incorretos.

Segue vídeo demonstrando em uma aplicação teste:

Gravação de tela de 2023-08-31 14-42-04.webm

Como podem ver no vídeo, somente obtendo um get do live() que os valores retornados estão incorretos, ao salvar no banco está ok.

Segue o repositório do código utilizado: https://github.com/mliell/Erro-money-placeholder

How to reproduce the bug

Crie um input tipo Money com live(): Money::make('valor1')->live(),

Retorne os dados em um placeholder:

Placeholder::make('Valor_1')->content(function ($get) { return $get('valor1'); }),

Ou baixe o repósitório https://github.com/mliell/Erro-money-placeholder

Package Version

3.0.1

PHP Version

8.1.12

Laravel Version

10.21.0

Which operating systems does with happen with?

No response

Notes

Banco de dados utilizado: sqlite

leandrocfe commented 10 months ago

Testou live(onBlur:true)?

mliell commented 10 months ago

Sim, retorna o mesmo.

mliell commented 10 months ago

Um detalhe interessante. Se colocar o cursor no lado esquerdo do valor (ficando a esquerda da vírgula, sendo os números inteiros) e adicionar um número, o retorno é correto. Agora se adicionar os números pelo lado esquerdo (decimal) que é o default, acontece o bug.

leandrocfe commented 10 months ago

é por conta do javascript..