Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jdhines opened this issue Mar 3, 2016 · 1 comment
Labels

Comments

@jdhines
Copy link

jdhines commented Mar 3, 2016

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')
@brandynbennett
Copy link
Collaborator

This seems to work for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants