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

Formatter allows 't' to be typed in for certain patterns

Open sllvn opened this issue 10 years ago • 5 comments

Formatter allows 't' to be typed in credit card demo, but not in phone number demo.

Discovered in Chrome on OS X.

sllvn avatar Oct 07 '14 00:10 sllvn

I ran into the same issue. This is because t returns the keyCode 116 which is mapped to F5 in the isSpecialKeypress method. That makes the t character keypress return true here which subsequently does not prevent the default and does not call _processKey.

I went ahead and simply disabled it in my fork to ensure that was the cause (it was). I am working on providing a better solution that will not break previous functionality required by the F5 mapping. I will submit a PR to this repo once I have gotten that worked out and once my previous PR gets merged (or rejected) so I can clean up my branches.

kyledetella avatar Oct 07 '14 13:10 kyledetella

@kyledetella: is your current solution still to just comment out the mapping for F5? Were you able to come up with something more elegant?

AustinMontoya avatar Oct 27 '14 15:10 AustinMontoya

@grrizzly The quick fix was to comment it out. That is certainly less than ideal. I will get around to working on a more practical fix (hopefully) soon.

Also, it looks like there has been some other work around this in #70. That may be something to keep an eye on.

kyledetella avatar Oct 27 '14 17:10 kyledetella

https://github.com/firstopinion/formatter.js/pull/70 is mine. I've looked into rules about key and ascii codes and this looks like the exact solution. I already use it in my app and it works fine. Although I'm not sure if this library actually needs some processing of F5.

andreyz4k avatar Nov 05 '14 17:11 andreyz4k

Just forked this repository and merged some of pull requests which also fixes this issue: https://github.com/mort3za/formatterjs2

mort3za avatar Aug 03 '16 08:08 mort3za