Skip to content

Commit 86b90c1

Browse files
author
Rupesh Dabbir
committed
dev: fix: Any occurance of Mask will push the cursor to one position back (AKA Reverse)
Issue: - Any occurance of Mask anywhere, the cursor will go one position to the back! Fix Description: - Basically this fix will make sure the cursor is at the end position of the val.
1 parent b33a432 commit 86b90c1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/jquery.mask.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,14 @@
256256
var keyCode = el.data('mask-keycode');
257257

258258
if ($.inArray(keyCode, jMask.byPassKeys) === -1) {
259-
var newVal = p.getMasked(),
260-
caretPos = p.getCaret();
259+
var newVal = p.getMasked();
261260

262261
setTimeout(function() {
263262
p.setCaret(p.calculateCaretPosition());
264263
}, 10);
265264

266265
p.val(newVal);
267-
p.setCaret(caretPos);
266+
p.setCaret(newVal.length); //For cut/paste, you will return val+mask length
268267
return p.callbacks(e);
269268
}
270269
},
@@ -455,9 +454,8 @@
455454
p.destroyEvents();
456455
p.events();
457456

458-
var caret = p.getCaret();
459457
p.val(p.getMasked());
460-
p.setCaret(caret);
458+
p.setCaret(p.getMasked().length);
461459
}
462460
};
463461

0 commit comments

Comments
 (0)