angular-ui / ui-mask

Mask on an input field so the user can only type pre-determined pattern
https://htmlpreview.github.io/?https://github.com/angular-ui/ui-mask/master/demo/index.html
MIT License
391 stars 258 forks source link

change event fires twice if I replace one selected symbol #208

Open andrymook opened 7 years ago

andrymook commented 7 years ago

I tested it in Chrome 54.0.2840.99 and Firefox 50.0. You can use other versions.

How to repeat:

  1. Open Mask HtmlPreview Page
  2. Open Developer Tools
  3. Add "change" event for the first event: document.querySelector('input').addEventListener('change', function(event){ console.log(event); }); Or add "change" event for document.body: document.body.addEventListener('change', function(event){ console.log(event); });
  4. Select Predefined mask: for example, Set to (999) 999-9999
  5. Fill Masked Input field correctly: (123) 456-7890
  6. Now if you put cursor, for example, between symbols 7 and 8, then press Delete, then press 3: (123) 456-7390,
    • you can see only one event in console - Chrome 54.0.2840.99
    • you can see two events in console - Firefox 50.0 But if you select 8 (only one symbol) in "(123) 456-7890" mask_select8 and press 3,
    • you can see two events - Firefox 50.0 and Chrome 54.0.2840.99 mask_changetwice