adopted-ember-addons / adopted-ember-addons/ember-inputmask

Pasting a value with decimal=false results in the radix being removed, but not the decimal portion

Aperta
#17 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
JavaScript
Stelle
67
Fork
43
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I had a `number-input` with `decimal=false` and though that does prevent a user from entering a decimal point, if the user instead pastes in a value like 100.32, the decimal point is just removed, leaving 10032, which is obviously way bigger. The expected behavior is that the decimal portion be trimmed off.

It works fine, however, if decimals are allowed and the user pastes in a number with more decimal digits. For example, if they paste in 100.321, with default options, the input will show just 100.32.

I tried setting `decimal=0` but that didn't fix it. I'm happy to submit a PR, but I don't know what to change to allow this. I'm guessing an `else` condition here, but I'm not sure:

```
//ember-inputmask/components/input-mask
...
updateMask: function() {
this.setProperties({
'options.autoGroup': this.get('group'),
'options.groupSeparator': this.get('separator'),
'options.radixPoint': this.get('radix'),
'options.groupSize': this.get('groupSize')
});

if (this.get('decimal') === true) {
this.set('mask', 'decimal');
this.set('options.digits', 2);
} else if (this.get('decimal')) {
this.set('mask', 'decimal');
this.set('options.digits', this.get('decimal'));
}

this._super();
}.observes('mask', 'group', 'decimal', 'separator', 'radix', 'groupSize')
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.