Skip to content

Commit

Permalink
Merge pull request #40 from ariaieboy/39-bug-using-currencymask-in-a-…
Browse files Browse the repository at this point in the history
…form-inside-a-repeater-that-uses-afterstateupdated-causes-livewire-loop

fix issue #39
  • Loading branch information
ariaieboy authored Aug 12, 2024
2 parents c800e5a + d7dec32 commit a5b0832
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions resources/views/currency-mask.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@
\$watch('masked',()=>this.updateInput());
\$watch('input', () => this.updateMasked());
},
updateMasked(value, oldValue){
updateMasked(){
if(this.input !== undefined && typeof Number(this.input) === 'number') {
if(this.masked?.replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.') !== this.input){
this.masked = this.input?.toString().replaceAll('.','$decimalSeparator');
}
}
},
updateInput(){
this.input = this.masked?.replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.');
updateInput(value, oldValue){
if(value !== oldValue)
this.input = this.masked?.replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.');
}
}
JS;
Expand Down

0 comments on commit a5b0832

Please sign in to comment.