cleave.js icon indicating copy to clipboard operation
cleave.js copied to clipboard

Value stripped when prefix

Open benogle opened this issue 5 years ago • 2 comments

I am trying to mask a US SSN by using prefix. It strips the actual value.

https://jsfiddle.net/cz5vrkmj/

Screen Shot 2019-11-21 at 1 52 24 PM

The last version that works is 1.4.7, which indicates https://github.com/nosir/cleave.js/pull/440 caused the bug

benogle avatar Nov 21 '19 21:11 benogle

This is still a problem for us. I can defeat it on load with noImmediatePrefix. But we are masking this data, our process is

  • User types 123121234
  • We mask it and send in a value of •••••1234 + change the prefix to •••••
  • Then this code block strips it:

https://github.com/nosir/cleave.js/blob/e3fa6f3637fa6d8ea97ef66ac1957950632b72ab/src/utils/Util.js#L104-L113

I'm not understanding why that code should return an empty string in this scenario. Commenting out that entire block fixes it while still allowing all other uses of this lib in our codebase to continue to work. Help me understand what the intended purpose of this code is and I'm happy to submit a PR!

benogle avatar Sep 29 '20 17:09 benogle

@benogle hi! Did you manage to solve this problem? Did they answer you? I can't do onChange in react either.

janaratolonbaeva avatar Jun 05 '23 05:06 janaratolonbaeva