Browse Source

Element keeps the focus to itself in ie11

Fixed issue where in ie11 when setting a value to the input field this was taking focus, this was addressed by updating the selection end and start only when the element is the current element in focus.
Isaac Mercieca 7 years ago
parent
commit
d042709f49
1 changed files with 5 additions and 3 deletions
  1. 5 3
      js/inputmask.js

+ 5 - 3
js/inputmask.js

@@ -2542,8 +2542,10 @@
 
                         input.inputmask.caretPos = {begin: begin, end: end}; //track caret internally
                         if ("selectionStart" in input) {
-                            input.selectionStart = begin;
-                            input.selectionEnd = end;
+                            if (input === document.activeElement) {
+                              input.selectionStart = begin;
+                              input.selectionEnd = end;
+                            }
                         } else if (window.getSelection) {
                             range = document.createRange();
                             if (input.firstChild === undefined || input.firstChild === null) {
@@ -3204,4 +3206,4 @@
         return Inputmask;
     }
 ))
-;
+;