react-maskedinput icon indicating copy to clipboard operation
react-maskedinput copied to clipboard

Fixes #21, Chrome Auto-fill Issue

Open fuelpagan opened this issue 10 years ago • 8 comments

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 avatar Oct 21 '15 21:10 fuelpagan

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

iamdustan avatar May 26 '16 15:05 iamdustan

sure will

fuelpagan avatar Jun 01 '16 14:06 fuelpagan

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

fuelpagan avatar Jun 01 '16 17:06 fuelpagan

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.

iamdustan avatar Jun 01 '16 19:06 iamdustan

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?

christinebrass avatar Jun 14 '16 20:06 christinebrass

@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.

iamdustan avatar Jun 16 '16 15:06 iamdustan

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

martyphee avatar Sep 29 '16 13:09 martyphee

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

mertkahyaoglu avatar Apr 20 '18 06:04 mertkahyaoglu