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

Fixes #21, Chrome Auto-fill Issue #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fuelpagan
Copy link

issue #21

When using the chrome auto-fill feature with mask pattern (111) 111-1111, I found it was firing the _onChange function. By calling this.mask.setValue(e.target.value) before calling this._getDisplayValue() I was able the have the input fill in properly using (234) 234-2342 as well as 2342342342, both filled in correctly with this change.

When pasting, the this.mask.paste(e.clipboardData.getData('Text')) was returning false. With 2342342342 the underlying inputmask-core would return false comparing 2 to (. When pasting (234) 234-2342, inputmask-core would return false when comparing ) with the mask pattern looking for a number. Adding

else {
  this.mask.setValue(e.clipboardData.getData('Text'));
  var value = this._getDisplayValue()
  e.target.value = value
  if (value) {
    this._updateInputSelection()
  }
}

allowed pasting numeric values to work. I also tested with alpha characters and the paste still rejected as expected.

@iamdustan
Copy link
Collaborator

@fuelpagan could you rebase master and add a test case for this scenario?

@fuelpagan
Copy link
Author

sure will

@fuelpagan
Copy link
Author

says there are 5 steps to the rebase and having issues with number 2...

@iamdustan
Copy link
Collaborator

Can you fix the conflict easy enough? I would guess because dist/react-maskedinput.js has been modified in this PR, but we’ve removed it in master.

@christinebrass
Copy link

Hey there, I'm also interested in this patch! However, I noticed that the onChange event wasn't being fired within the new condition inside the onPaste handler. Should we be firing for that case as well?

@iamdustan
Copy link
Collaborator

@Cybrass onChange event isn’t being fired by the browser or by this library? We should be emulating whatever React would do so the behavior is seamless.

@martyphee
Copy link
Contributor

Is this dead? Running into this issue right now and need to get it fixed.

@mertkahyaoglu
Copy link

I can create a new PR if this is not going to be merged 🤔

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

Successfully merging this pull request may close these issues.

5 participants