Fixes #21, Chrome Auto-fill Issue
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.
@fuelpagan could you rebase master and add a test case for this scenario?
sure will
says there are 5 steps to the rebase and having issues with number 2...
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.
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?
@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.
Is this dead? Running into this issue right now and need to get it fixed.
I can create a new PR if this is not going to be merged 🤔