ui-mask icon indicating copy to clipboard operation
ui-mask copied to clipboard

Duplicate numbers in model value when paste in IE11

Open edieval opened this issue 9 years ago • 1 comments

Hello,

As reproduce in the angular-ui-mask demo page, with Internet Explorer 11 :

  • Mask Definition : 99 99 99 99 99 ?9?9 ?9?9
  • Default placeholder char : space
  • Value to paste : 0608046823

Result :

  • Model value : 060804046823 (bad)
  • NgModelController.$viewValue : 06 08 04 68 23 (good)

Thanks !

edieval avatar May 24 '16 14:05 edieval

What I have found so far is that IE appears to be doing something differently when it fires events after pasting values than what Chrome does.

This causes a different execution path to happen in IE which is causing this issue. Also, the only reason you are seeing this issue is because you are using space as the placeholder character and you have optional characters that extend the length of the string with spaces. This is causing problems because in angular's event listener it trims the value coming from the element. This throws off the unmasking process and leads to your funky model value state.

I'm not sure there is a fix for this but changing your placeholder character from space resolves the issue.

Edit:

If/when #160 is added then that would fix your issue and let you use space as a placeholder character because you could tell the library to not add in the extra placeholder character "slots".

lukepfeiffer10 avatar Jun 16 '16 13:06 lukepfeiffer10